@@ -60,6 +60,7 @@ enum lint {
60
60
unrecognized_lint,
61
61
non_implicitly_copyable_typarams,
62
62
vecs_implicitly_copyable,
63
+ deprecated_item,
63
64
deprecated_mode,
64
65
deprecated_pattern,
65
66
non_camel_case_types,
@@ -157,6 +158,11 @@ fn get_lint_dict() -> lint_dict {
157
158
desc: ~"implicit copies of non implicitly copyable data",
158
159
default : warn} ) ,
159
160
161
+ ( ~"deprecated_item",
162
+ @{ lint: deprecated_item,
163
+ desc: ~"warn about items marked deprecated",
164
+ default : warn} ) ,
165
+
160
166
( ~"deprecated_mode",
161
167
@{ lint: deprecated_mode,
162
168
desc: ~"warn about deprecated uses of modes",
@@ -412,6 +418,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
412
418
check_item_non_camel_case_types( cx, i) ;
413
419
check_item_heap( cx, i) ;
414
420
check_item_structural_records( cx, i) ;
421
+ check_item_deprecated( cx, i) ;
415
422
check_item_deprecated_modes( cx, i) ;
416
423
check_item_type_limits( cx, i) ;
417
424
}
@@ -767,6 +774,26 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
767
774
}
768
775
}
769
776
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
+
770
797
fn check_fn( tcx: ty:: ctxt, fk: visit:: fn_kind, decl: ast:: fn_decl,
771
798
_body: ast:: blk, span: span, id: ast:: node_id) {
772
799
debug!( "lint check_fn fk=%? id=%?", fk, id) ;
0 commit comments