@@ -191,6 +191,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status
191191
192192 // allow `#[unwind]`
193193 ( "unwind_attributes" , "1.4.0" , None , Active ) ,
194+
195+ // allow empty structs/enum variants with braces
196+ ( "braced_empty_structs" , "1.5.0" , None , Active ) ,
194197] ;
195198// (changing above list without updating src/doc/reference.md makes @cmr sad)
196199
@@ -775,7 +778,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
775778 }
776779 }
777780
778- ast:: ItemStruct ( .. ) => {
781+ ast:: ItemStruct ( ref def , _ ) => {
779782 if attr:: contains_name ( & i. attrs [ ..] , "simd" ) {
780783 self . gate_feature ( "simd" , i. span ,
781784 "SIMD types are experimental and possibly buggy" ) ;
@@ -794,6 +797,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
794797 }
795798 }
796799 }
800+ if def. fields . is_empty ( ) && def. ctor_id . is_none ( ) {
801+ self . gate_feature ( "braced_empty_structs" , i. span ,
802+ "empty structs with braces are unstable" ) ;
803+ }
797804 }
798805
799806 ast:: ItemDefaultImpl ( ..) => {
@@ -843,6 +850,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
843850 "box expression syntax is experimental; \
844851 you can call `Box::new` instead.") ;
845852 }
853+ ast:: ExprStruct ( _, ref fields, ref expr) => {
854+ if fields. is_empty ( ) && expr. is_none ( ) {
855+ self . gate_feature ( "braced_empty_structs" , e. span ,
856+ "empty structs with braces are unstable" ) ;
857+ }
858+ }
846859 _ => { }
847860 }
848861 visit:: walk_expr ( self , e) ;
@@ -867,6 +880,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
867880 pattern. span ,
868881 "box pattern syntax is experimental" ) ;
869882 }
883+ ast:: PatStruct ( _, ref fields, dotdot) => {
884+ if fields. is_empty ( ) && !dotdot {
885+ self . gate_feature ( "braced_empty_structs" , pattern. span ,
886+ "empty structs with braces are unstable" ) ;
887+ }
888+ }
870889 _ => { }
871890 }
872891 visit:: walk_pat ( self , pattern)
0 commit comments