Skip to content

Commit 692342d

Browse files
committed
---
yaml --- r: 40749 b: refs/heads/dist-snap c: f675b97 h: refs/heads/master i: 40747: 4949765 v: v3
1 parent b271ce3 commit 692342d

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: e7dd3af970b44c09a429d02d60fd44b9f8ec45bd
10+
refs/heads/dist-snap: f675b97ddc3d85498473bb4da7f95b8942ebbd81
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/lint.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum lint {
6060
unrecognized_lint,
6161
non_implicitly_copyable_typarams,
6262
vecs_implicitly_copyable,
63+
deprecated_item,
6364
deprecated_mode,
6465
deprecated_pattern,
6566
non_camel_case_types,
@@ -157,6 +158,11 @@ fn get_lint_dict() -> lint_dict {
157158
desc: ~"implicit copies of non implicitly copyable data",
158159
default: warn}),
159160

161+
(~"deprecated_item",
162+
@{lint: deprecated_item,
163+
desc: ~"warn about items marked deprecated",
164+
default: warn}),
165+
160166
(~"deprecated_mode",
161167
@{lint: deprecated_mode,
162168
desc: ~"warn about deprecated uses of modes",
@@ -412,6 +418,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
412418
check_item_non_camel_case_types(cx, i);
413419
check_item_heap(cx, i);
414420
check_item_structural_records(cx, i);
421+
check_item_deprecated(cx, i);
415422
check_item_deprecated_modes(cx, i);
416423
check_item_type_limits(cx, i);
417424
}
@@ -767,6 +774,26 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
767774
}
768775
}
769776

777+
fn check_item_deprecated(tcx: ty::ctxt, it: @ast::item) {
778+
let at = attr::find_attrs_by_name(it.attrs, ~"deprecated");
779+
780+
if at.is_not_empty() {
781+
for at.each |attr| {
782+
let fmt = match attr.node.value.node {
783+
ast::meta_name_value(_, ref l) =>
784+
match l.node {
785+
ast::lit_str(ref reason) =>
786+
fmt!("deprecated: %s", **reason),
787+
_ => ~"item is deprecated"
788+
},
789+
_ => ~"item is deprecated"
790+
};
791+
tcx.sess.span_lint(deprecated_item, it.id, it.id, it.span,
792+
fmt);
793+
}
794+
}
795+
}
796+
770797
fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
771798
_body: ast::blk, span: span, id: ast::node_id) {
772799
debug!("lint check_fn fk=%? id=%?", fk, id);

branches/dist-snap/src/libsyntax/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) ->
182182
return vec::filter_map(attrs, filter);
183183
}
184184

185-
/// Searcha list of meta items and return only those with a specific name
185+
/// Search a list of meta items and return only those with a specific name
186186
fn find_meta_items_by_name(metas: ~[@ast::meta_item], name: ~str) ->
187187
~[@ast::meta_item] {
188188
let filter = fn@(m: &@ast::meta_item) -> Option<@ast::meta_item> {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[forbid(deprecated_item)];
2+
3+
type Bar = uint;
4+
5+
#[deprecated = "use Bar instead"]
6+
type Foo = int;
7+
8+
fn main() {
9+
let _x: Foo = 21;
10+
}

0 commit comments

Comments
 (0)