Skip to content

Commit 1f7bfac

Browse files
committed
rustc: Add lint for obsolete attributes
This also moves `#[auto_{en,de}code]` checker from syntax to lint.
1 parent 6ff697d commit 1f7bfac

File tree

6 files changed

+13
-59
lines changed

6 files changed

+13
-59
lines changed

src/librustc/middle/lint.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,11 @@ fn check_heap_item(cx: &Context, it: &ast::item) {
803803
// also make error on obsolete attributes for less confusion.
804804
fn check_item_attribute_usage(cx: &Context, it: &ast::item) {
805805
let crate_attrs = ["crate_type", "link", "feature", "no_uv", "no_main", "no_std"];
806+
let obsolete_attrs = [
807+
("abi", "extern \"abi\" fn"),
808+
("auto_encode", "#[deriving(Encodable)]"),
809+
("auto_decode", "#[deriving(Decodable)]"),
810+
];
806811

807812
for attr in it.attrs.iter() {
808813
let name = attr.node.value.name();
@@ -816,6 +821,13 @@ fn check_item_attribute_usage(cx: &Context, it: &ast::item) {
816821
cx.span_lint(attribute_usage, attr.span, msg);
817822
}
818823
}
824+
825+
for &(obs_attr, obs_alter) in obsolete_attrs.iter() {
826+
if name.equiv(&obs_attr) {
827+
cx.span_lint(attribute_usage, attr.span,
828+
format!("obsolete attribute: use `{:s}` instead", obs_alter));
829+
}
830+
}
819831
}
820832
}
821833

src/libstd/io/native/process.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ fn spawn_process_os(prog: &str, args: &[~str],
365365
use libc::funcs::bsd44::getdtablesize;
366366

367367
mod rustrt {
368-
#[abi = "cdecl"]
369368
extern {
370369
pub fn rust_unset_sigprocmask();
371370
}

src/libsyntax/ext/auto_encode.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub enum MacResult {
143143
}
144144

145145
pub enum SyntaxExtension {
146-
// #[auto_encode] and such
146+
// #[deriving] and such
147147
ItemDecorator(ItemDecorator),
148148

149149
// Token-tree expanders
@@ -229,12 +229,6 @@ pub fn syntax_expander_table() -> SyntaxEnv {
229229
syntax_expanders.insert(intern(&"format_args"),
230230
builtin_normal_tt_no_ctxt(
231231
ext::format::expand_args));
232-
syntax_expanders.insert(
233-
intern(&"auto_encode"),
234-
@SE(ItemDecorator(ext::auto_encode::expand_auto_encode)));
235-
syntax_expanders.insert(
236-
intern(&"auto_decode"),
237-
@SE(ItemDecorator(ext::auto_encode::expand_auto_decode)));
238232
syntax_expanders.insert(intern(&"env"),
239233
builtin_normal_tt_no_ctxt(
240234
ext::env::expand_env));

src/libsyntax/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ pub mod ext {
8383
pub mod concat;
8484
pub mod concat_idents;
8585
pub mod log_syntax;
86-
pub mod auto_encode;
8786
pub mod source_util;
8887

8988
pub mod trace_macros;

src/test/compile-fail/deprecated-auto-code.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)