@@ -92,7 +92,6 @@ pub enum Lint {
9292 TypeOverflow ,
9393 UnusedUnsafe ,
9494 UnsafeBlock ,
95- AttributeUsage ,
9695 UnusedAttribute ,
9796 UnknownFeatures ,
9897 UnknownCrateType ,
@@ -294,13 +293,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
294293 default : Allow
295294 } ) ,
296295
297- ( "attribute_usage" ,
298- LintSpec {
299- lint : AttributeUsage ,
300- desc : "detects bad use of attributes" ,
301- default : Warn
302- } ) ,
303-
304296 ( "unused_attribute" ,
305297 LintSpec {
306298 lint : UnusedAttribute ,
@@ -1096,93 +1088,6 @@ fn check_raw_ptr_deriving(cx: &mut Context, item: &ast::Item) {
10961088 }
10971089}
10981090
1099- static crate_attrs: & ' static [ & ' static str ] = & [
1100- "crate_type" , "feature" , "no_start" , "no_main" , "no_std" , "crate_id" ,
1101- "desc" , "comment" , "license" , "copyright" , // not used in rustc now
1102- "no_builtins" ,
1103- ] ;
1104-
1105-
1106- static obsolete_attrs: & ' static [ ( & ' static str , & ' static str ) ] = & [
1107- ( "abi" , "Use `extern \" abi\" fn` instead" ) ,
1108- ( "auto_encode" , "Use `#[deriving(Encodable)]` instead" ) ,
1109- ( "auto_decode" , "Use `#[deriving(Decodable)]` instead" ) ,
1110- ( "fast_ffi" , "Remove it" ) ,
1111- ( "fixed_stack_segment" , "Remove it" ) ,
1112- ( "rust_stack" , "Remove it" ) ,
1113- ] ;
1114-
1115- static other_attrs: & ' static [ & ' static str ] = & [
1116- // item-level
1117- "address_insignificant" , // can be crate-level too
1118- "thread_local" , // for statics
1119- "allow" , "deny" , "forbid" , "warn" , // lint options
1120- "deprecated" , "experimental" , "unstable" , "stable" , "locked" , "frozen" , //item stability
1121- "cfg" , "doc" , "export_name" , "link_section" ,
1122- "no_mangle" , "static_assert" , "unsafe_no_drop_flag" , "packed" ,
1123- "simd" , "repr" , "deriving" , "unsafe_destructor" , "link" , "phase" ,
1124- "macro_export" , "must_use" , "automatically_derived" ,
1125-
1126- //mod-level
1127- "path" , "link_name" , "link_args" , "macro_escape" , "no_implicit_prelude" ,
1128-
1129- // fn-level
1130- "test" , "bench" , "should_fail" , "ignore" , "inline" , "lang" , "main" , "start" ,
1131- "no_split_stack" , "cold" , "macro_registrar" , "linkage" ,
1132-
1133- // internal attribute: bypass privacy inside items
1134- "!resolve_unexported" ,
1135- ] ;
1136-
1137- fn check_crate_attrs_usage ( cx : & Context , attrs : & [ ast:: Attribute ] ) {
1138-
1139- for attr in attrs. iter ( ) {
1140- let name = attr. node . value . name ( ) ;
1141- let mut iter = crate_attrs. iter ( ) . chain ( other_attrs. iter ( ) ) ;
1142- if !iter. any ( |other_attr| { name. equiv ( other_attr) } ) {
1143- cx. span_lint ( AttributeUsage , attr. span , "unknown crate attribute" ) ;
1144- }
1145- if name. equiv ( & ( "link" ) ) {
1146- cx. tcx . sess . span_err ( attr. span ,
1147- "obsolete crate `link` attribute" ) ;
1148- cx. tcx . sess . note ( "the link attribute has been superceded by the crate_id \
1149- attribute, which has the format `#[crate_id = \" name#version\" ]`") ;
1150- }
1151- }
1152- }
1153-
1154- fn check_attrs_usage ( cx : & Context , attrs : & [ ast:: Attribute ] ) {
1155- // check if element has crate-level, obsolete, or any unknown attributes.
1156-
1157- for attr in attrs. iter ( ) {
1158- let name = attr. node . value . name ( ) ;
1159- for crate_attr in crate_attrs. iter ( ) {
1160- if name. equiv ( crate_attr) {
1161- let msg = match attr. node . style {
1162- ast:: AttrOuter => "crate-level attribute should be an inner attribute: \
1163- add an exclamation mark: #![foo]",
1164- ast:: AttrInner => "crate-level attribute should be in the root module" ,
1165- } ;
1166- cx. span_lint ( AttributeUsage , attr. span , msg) ;
1167- return ;
1168- }
1169- }
1170-
1171- for & ( obs_attr, obs_alter) in obsolete_attrs. iter ( ) {
1172- if name. equiv ( & obs_attr) {
1173- cx. span_lint ( AttributeUsage , attr. span ,
1174- format ! ( "obsolete attribute: {:s}" ,
1175- obs_alter) . as_slice ( ) ) ;
1176- return ;
1177- }
1178- }
1179-
1180- if !other_attrs. iter ( ) . any ( |other_attr| { name. equiv ( other_attr) } ) {
1181- cx. span_lint ( AttributeUsage , attr. span , "unknown attribute" ) ;
1182- }
1183- }
1184- }
1185-
11861091fn check_unused_attribute ( cx : & Context , attr : & ast:: Attribute ) {
11871092 static ATTRIBUTE_WHITELIST : & ' static [ & ' static str ] = & ' static [
11881093 // FIXME: #14408 whitelist docs since rustdoc looks at them
@@ -1834,7 +1739,6 @@ impl<'a> Visitor<()> for Context<'a> {
18341739 check_item_non_uppercase_statics ( cx, it) ;
18351740 check_heap_item ( cx, it) ;
18361741 check_missing_doc_item ( cx, it) ;
1837- check_attrs_usage ( cx, it. attrs . as_slice ( ) ) ;
18381742 check_raw_ptr_deriving ( cx, it) ;
18391743
18401744 cx. visit_ids ( |v| v. visit_item ( it, ( ) ) ) ;
@@ -1845,15 +1749,12 @@ impl<'a> Visitor<()> for Context<'a> {
18451749
18461750 fn visit_foreign_item ( & mut self , it : & ast:: ForeignItem , _: ( ) ) {
18471751 self . with_lint_attrs ( it. attrs . as_slice ( ) , |cx| {
1848- check_attrs_usage ( cx, it. attrs . as_slice ( ) ) ;
18491752 visit:: walk_foreign_item ( cx, it, ( ) ) ;
18501753 } )
18511754 }
18521755
18531756 fn visit_view_item ( & mut self , i : & ast:: ViewItem , _: ( ) ) {
18541757 self . with_lint_attrs ( i. attrs . as_slice ( ) , |cx| {
1855- check_attrs_usage ( cx, i. attrs . as_slice ( ) ) ;
1856-
18571758 cx. visit_ids ( |v| v. visit_view_item ( i, ( ) ) ) ;
18581759
18591760 visit:: walk_view_item ( cx, i, ( ) ) ;
@@ -1935,7 +1836,6 @@ impl<'a> Visitor<()> for Context<'a> {
19351836 visit:: FkMethod ( ident, _, m) => {
19361837 self . with_lint_attrs ( m. attrs . as_slice ( ) , |cx| {
19371838 check_missing_doc_method ( cx, m) ;
1938- check_attrs_usage ( cx, m. attrs . as_slice ( ) ) ;
19391839
19401840 match method_context ( cx, m) {
19411841 PlainImpl => check_snake_case ( cx, "method" , ident, span) ,
@@ -1960,7 +1860,6 @@ impl<'a> Visitor<()> for Context<'a> {
19601860 fn visit_ty_method ( & mut self , t : & ast:: TypeMethod , _: ( ) ) {
19611861 self . with_lint_attrs ( t. attrs . as_slice ( ) , |cx| {
19621862 check_missing_doc_ty_method ( cx, t) ;
1963- check_attrs_usage ( cx, t. attrs . as_slice ( ) ) ;
19641863 check_snake_case ( cx, "trait method" , t. ident , t. span ) ;
19651864
19661865 visit:: walk_ty_method ( cx, t, ( ) ) ;
@@ -1984,7 +1883,6 @@ impl<'a> Visitor<()> for Context<'a> {
19841883 fn visit_struct_field ( & mut self , s : & ast:: StructField , _: ( ) ) {
19851884 self . with_lint_attrs ( s. node . attrs . as_slice ( ) , |cx| {
19861885 check_missing_doc_struct_field ( cx, s) ;
1987- check_attrs_usage ( cx, s. node . attrs . as_slice ( ) ) ;
19881886
19891887 visit:: walk_struct_field ( cx, s, ( ) ) ;
19901888 } )
@@ -1993,7 +1891,6 @@ impl<'a> Visitor<()> for Context<'a> {
19931891 fn visit_variant ( & mut self , v : & ast:: Variant , g : & ast:: Generics , _: ( ) ) {
19941892 self . with_lint_attrs ( v. node . attrs . as_slice ( ) , |cx| {
19951893 check_missing_doc_variant ( cx, v) ;
1996- check_attrs_usage ( cx, v. node . attrs . as_slice ( ) ) ;
19971894
19981895 visit:: walk_variant ( cx, v, g, ( ) ) ;
19991896 } )
@@ -2053,7 +1950,6 @@ pub fn check_crate(tcx: &ty::ctxt,
20531950 visit:: walk_crate ( v, krate, ( ) ) ;
20541951 } ) ;
20551952
2056- check_crate_attrs_usage ( cx, krate. attrs . as_slice ( ) ) ;
20571953 // since the root module isn't visited as an item (because it isn't an item), warn for it
20581954 // here.
20591955 check_missing_doc_attrs ( cx,
0 commit comments