Address review comments
This commit is contained in:
parent
17aef21b30
commit
62aea8c913
4 changed files with 578 additions and 854 deletions
|
@ -251,7 +251,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||||
// Modules, prelude, and resolution:
|
// Modules, prelude, and resolution:
|
||||||
ungated!(path, Normal, template!(NameValueStr: "file")),
|
ungated!(path, Normal, template!(NameValueStr: "file")),
|
||||||
ungated!(no_std, CrateLevel, template!(Word)),
|
ungated!(no_std, CrateLevel, template!(Word)),
|
||||||
ungated!(no_implicit_prelude, CrateLevel, template!(Word)),
|
ungated!(no_implicit_prelude, Normal, template!(Word)),
|
||||||
ungated!(non_exhaustive, Normal, template!(Word)),
|
ungated!(non_exhaustive, Normal, template!(Word)),
|
||||||
|
|
||||||
// Runtime
|
// Runtime
|
||||||
|
|
|
@ -130,6 +130,12 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
sym::ignore | sym::should_panic | sym::proc_macro_derive => {
|
sym::ignore | sym::should_panic | sym::proc_macro_derive => {
|
||||||
self.check_generic_attr(hir_id, attr, target, &[Target::Fn])
|
self.check_generic_attr(hir_id, attr, target, &[Target::Fn])
|
||||||
}
|
}
|
||||||
|
sym::automatically_derived => {
|
||||||
|
self.check_generic_attr(hir_id, attr, target, &[Target::Impl])
|
||||||
|
}
|
||||||
|
sym::no_implicit_prelude => {
|
||||||
|
self.check_generic_attr(hir_id, attr, target, &[Target::Mod])
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +296,6 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
b.push_str(&(allowed_target.to_string() + "s"));
|
b.push_str(&(allowed_target.to_string() + "s"));
|
||||||
b
|
b
|
||||||
});
|
});
|
||||||
//let supported_names = allowed_targets.iter().fold(String::new(), |msg, t| msg + ", " + &t.to_string());
|
|
||||||
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
||||||
lint.build(&format!("`#[{name}]` only has an effect on {}", supported_names))
|
lint.build(&format!("`#[{name}]` only has an effect on {}", supported_names))
|
||||||
.emit();
|
.emit();
|
||||||
|
|
|
@ -275,18 +275,20 @@ mod path {
|
||||||
//~^ WARN `#[path]` only has an effect
|
//~^ WARN `#[path]` only has an effect
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't warn on `automatically_derived` - a custom derive
|
|
||||||
// could reasonally annotate anything that it emits with
|
|
||||||
// this attribute
|
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
//~^ WARN `#[automatically_derived]` only has an effect
|
||||||
mod automatically_derived {
|
mod automatically_derived {
|
||||||
mod inner { #![automatically_derived] }
|
mod inner { #![automatically_derived] }
|
||||||
|
//~^ WARN `#[automatically_derived]
|
||||||
|
|
||||||
#[automatically_derived] fn f() { }
|
#[automatically_derived] fn f() { }
|
||||||
|
//~^ WARN `#[automatically_derived]
|
||||||
|
|
||||||
#[automatically_derived] struct S;
|
#[automatically_derived] struct S;
|
||||||
|
//~^ WARN `#[automatically_derived]
|
||||||
|
|
||||||
#[automatically_derived] type T = S;
|
#[automatically_derived] type T = S;
|
||||||
|
//~^ WARN `#[automatically_derived]
|
||||||
|
|
||||||
#[automatically_derived] impl S { }
|
#[automatically_derived] impl S { }
|
||||||
}
|
}
|
||||||
|
@ -368,22 +370,20 @@ mod ignore {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_implicit_prelude]
|
#[no_implicit_prelude]
|
||||||
//~^ WARN crate-level attribute
|
|
||||||
mod no_implicit_prelude {
|
mod no_implicit_prelude {
|
||||||
mod inner { #![no_implicit_prelude] }
|
mod inner { #![no_implicit_prelude] }
|
||||||
//~^ WARN crate-level attribute
|
|
||||||
|
|
||||||
#[no_implicit_prelude] fn f() { }
|
#[no_implicit_prelude] fn f() { }
|
||||||
//~^ WARN crate-level attribute
|
//~^ WARN `#[no_implicit_prelude]` only has an effect
|
||||||
|
|
||||||
#[no_implicit_prelude] struct S;
|
#[no_implicit_prelude] struct S;
|
||||||
//~^ WARN crate-level attribute
|
//~^ WARN `#[no_implicit_prelude]` only has an effect
|
||||||
|
|
||||||
#[no_implicit_prelude] type T = S;
|
#[no_implicit_prelude] type T = S;
|
||||||
//~^ WARN crate-level attribute
|
//~^ WARN `#[no_implicit_prelude]` only has an effect
|
||||||
|
|
||||||
#[no_implicit_prelude] impl S { }
|
#[no_implicit_prelude] impl S { }
|
||||||
//~^ WARN crate-level attribute
|
//~^ WARN `#[no_implicit_prelude]` only has an effect
|
||||||
}
|
}
|
||||||
|
|
||||||
#[reexport_test_harness_main = "2900"]
|
#[reexport_test_harness_main = "2900"]
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue