Don't warn when underscore is passed to macro
This commit is contained in:
parent
4cc2f952e4
commit
6b5da2f177
4 changed files with 47 additions and 1 deletions
|
|
@ -1349,6 +1349,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
if ident.name == kw::Underscore
|
||||
&& !matches!(item.vis.kind, VisibilityKind::Inherited)
|
||||
&& ident.span.eq_ctxt(item.vis.span)
|
||||
{
|
||||
self.lint_buffer.buffer_lint(
|
||||
UNUSED_VISIBILITIES,
|
||||
|
|
|
|||
|
|
@ -9,4 +9,21 @@
|
|||
const _: () = {};
|
||||
//~^WARN visibility qualifiers have no effect on `const _` declarations
|
||||
|
||||
macro_rules! foo {
|
||||
() => {
|
||||
const _: () = {};
|
||||
//~^WARN visibility qualifiers have no effect on `const _` declarations
|
||||
};
|
||||
}
|
||||
|
||||
foo!();
|
||||
|
||||
macro_rules! bar {
|
||||
($tt:tt) => {
|
||||
pub const $tt: () = {};
|
||||
};
|
||||
}
|
||||
|
||||
bar!(_);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,21 @@ pub const _: () = {};
|
|||
pub(self) const _: () = {};
|
||||
//~^WARN visibility qualifiers have no effect on `const _` declarations
|
||||
|
||||
macro_rules! foo {
|
||||
() => {
|
||||
pub const _: () = {};
|
||||
//~^WARN visibility qualifiers have no effect on `const _` declarations
|
||||
};
|
||||
}
|
||||
|
||||
foo!();
|
||||
|
||||
macro_rules! bar {
|
||||
($tt:tt) => {
|
||||
pub const $tt: () = {};
|
||||
};
|
||||
}
|
||||
|
||||
bar!(_);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -16,5 +16,16 @@ warning: visibility qualifiers have no effect on `const _` declarations
|
|||
LL | pub(self) const _: () = {};
|
||||
| ^^^^^^^^^ help: remove the qualifier
|
||||
|
||||
warning: 2 warnings emitted
|
||||
warning: visibility qualifiers have no effect on `const _` declarations
|
||||
--> $DIR/unused-visibilities.rs:14:9
|
||||
|
|
||||
LL | pub const _: () = {};
|
||||
| ^^^ help: remove the qualifier
|
||||
...
|
||||
LL | foo!();
|
||||
| ------ in this macro invocation
|
||||
|
|
||||
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue