@@ -155,6 +155,10 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
155155
156156 // Allows use of unary negate on unsigned integers, e.g. -e for e: u8
157157 ( "negate_unsigned" , "1.0.0" , Active ) ,
158+
159+ // Allows the definition of associated constants in `trait` or `impl`
160+ // blocks.
161+ ( "associated_consts" , "1.0.0" , Active ) ,
158162] ;
159163// (changing above list without updating src/doc/reference.md makes @cmr sad)
160164
@@ -659,6 +663,30 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
659663 }
660664 visit:: walk_fn ( self , fn_kind, fn_decl, block, span) ;
661665 }
666+
667+ fn visit_trait_item ( & mut self , ti : & ' v ast:: TraitItem ) {
668+ match ti. node {
669+ ast:: ConstTraitItem ( ..) => {
670+ self . gate_feature ( "associated_consts" ,
671+ ti. span ,
672+ "associated constants are experimental" )
673+ }
674+ _ => { }
675+ }
676+ visit:: walk_trait_item ( self , ti) ;
677+ }
678+
679+ fn visit_impl_item ( & mut self , ii : & ' v ast:: ImplItem ) {
680+ match ii. node {
681+ ast:: ConstImplItem ( ..) => {
682+ self . gate_feature ( "associated_consts" ,
683+ ii. span ,
684+ "associated constants are experimental" )
685+ }
686+ _ => { }
687+ }
688+ visit:: walk_impl_item ( self , ii) ;
689+ }
662690}
663691
664692fn check_crate_inner < F > ( cm : & CodeMap , span_handler : & SpanHandler ,
0 commit comments