@@ -81,6 +81,7 @@ pub enum lint {
81
81
type_limits,
82
82
default_methods,
83
83
deprecated_self,
84
+ deprecated_mutable_fields,
84
85
85
86
managed_heap_memory,
86
87
owned_heap_memory,
@@ -255,6 +256,13 @@ pub fn get_lint_dict() -> LintDict {
255
256
default : warn
256
257
} ) ,
257
258
259
+ ( @~"deprecated_mutable_fields",
260
+ @LintSpec {
261
+ lint : deprecated_mutable_fields,
262
+ desc : "deprecated mutable fields in structures" ,
263
+ default : deny
264
+ } ) ,
265
+
258
266
/* FIXME(#3266)--make liveness warnings lintable
259
267
(@~"unused_variable",
260
268
@LintSpec {
@@ -488,6 +496,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
488
496
check_item_type_limits ( cx, i) ;
489
497
check_item_default_methods ( cx, i) ;
490
498
check_item_deprecated_self ( cx, i) ;
499
+ check_item_deprecated_mutable_fields ( cx, i) ;
491
500
}
492
501
493
502
// Take a visitor, and modify it so that it will not proceed past subitems.
@@ -705,6 +714,26 @@ fn check_item_deprecated_self(cx: ty::ctxt, item: @ast::item) {
705
714
}
706
715
}
707
716
717
+ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
718
+ match item.node {
719
+ ast::item_struct(struct_def, _) => {
720
+ for struct_def.fields.each |field| {
721
+ match field.node.kind {
722
+ ast::named_field(_, ast::struct_mutable, _) => {
723
+ cx.sess.span_lint(deprecated_mutable_fields,
724
+ item.id,
725
+ item.id,
726
+ field.span,
727
+ ~" mutable fields are deprecated") ;
728
+ }
729
+ ast:: named_field( * ) | ast:: unnamed_field => { }
730
+ }
731
+ }
732
+ }
733
+ _ => { }
734
+ }
735
+ }
736
+
708
737
fn check_item_structural_records ( cx : ty:: ctxt , it : @ast:: item ) {
709
738
let visit = item_stopping_visitor (
710
739
visit:: mk_simple_visitor ( @visit:: SimpleVisitor {
0 commit comments