Skip to content

Commit a867e19

Browse files
committed
---
yaml --- r: 152375 b: refs/heads/try2 c: 42a18bd h: refs/heads/master i: 152373: 2ee862b 152371: 0990272 152367: f449d75 v: v3
1 parent 4a543a6 commit a867e19

File tree

7 files changed

+10
-124
lines changed

7 files changed

+10
-124
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3654ac68be4f1d8e9c3c4e45f3282dd78dc4bd73
8+
refs/heads/try2: 42a18bd985e103484abbe801082b0593f1a43019
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/lint.rs

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
11861091
fn 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,

branches/try2/src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool) -> String {
205205
if lints {
206206
prog.push_str(r"
207207
#![deny(warnings)]
208-
#![allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)]
208+
#![allow(unused_variable, dead_assignment, unused_mut, unused_attribute, dead_code)]
209209
");
210210
}
211211

branches/try2/src/test/compile-fail/lint-misplaced-attr.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
// When denying at the crate level, be sure to not get random warnings from the
1212
// injected intrinsics by the compiler.
1313

14-
#![deny(attribute_usage)]
1514
#![deny(unused_attribute)]
1615

1716
mod a {
18-
#![crate_type = "bin"] //~ ERROR: crate-level attribute
19-
//~^ ERROR: unused attribute
17+
#![crate_type = "bin"] //~ ERROR unused attribute
2018
}
2119

22-
#[crate_type = "bin"] fn main() {} //~ ERROR: crate-level attribute
23-
//~^ ERROR: unused attribute
20+
#[crate_type = "bin"] fn main() {} //~ ERROR unused attribute

branches/try2/src/test/compile-fail/lint-obsolete-attr.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111
// When denying at the crate level, be sure to not get random warnings from the
1212
// injected intrinsics by the compiler.
1313

14-
#![deny(attribute_usage)]
1514
#![deny(unused_attribute)]
1615
#![allow(dead_code)]
1716

18-
#[abi="stdcall"] extern {} //~ ERROR: obsolete attribute
19-
//~^ ERROR: unused attribute
17+
#[abi="stdcall"] extern {} //~ ERROR unused attribute
2018

21-
#[fixed_stack_segment] fn f() {} //~ ERROR: obsolete attribute
22-
//~^ ERROR: unused attribute
19+
#[fixed_stack_segment] fn f() {} //~ ERROR unused attribute
2320

2421
fn main() {}

branches/try2/src/test/compile-fail/lint-unknown-attr.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
// When denying at the crate level, be sure to not get random warnings from the
1212
// injected intrinsics by the compiler.
1313

14-
#![deny(attribute_usage)]
1514
#![deny(unused_attribute)]
1615

17-
#![mutable_doc] //~ ERROR: unknown crate attribute
18-
//~^ ERROR: unused attribute
16+
#![mutable_doc] //~ ERROR unused attribute
1917

20-
#[dance] mod a {} //~ ERROR: unknown attribute
21-
//~^ ERROR: unused attribute
18+
#[dance] mod a {} //~ ERROR unused attribute
2219

23-
#[dance] fn main() {} //~ ERROR: unknown attribute
24-
//~^ ERROR: unused attribute
20+
#[dance] fn main() {} //~ ERROR unused attribute

branches/try2/src/test/compile-fail/unused-attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010
#![deny(unused_attribute)]
11-
#![allow(attribute_usage, dead_code, unused_imports)]
11+
#![allow(dead_code, unused_imports)]
1212

1313
#![foo] //~ ERROR unused attribute
1414

0 commit comments

Comments
 (0)