@@ -191,6 +191,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status
191
191
192
192
// allow `#[unwind]`
193
193
( "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 ) ,
194
197
] ;
195
198
// (changing above list without updating src/doc/reference.md makes @cmr sad)
196
199
@@ -775,7 +778,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
775
778
}
776
779
}
777
780
778
- ast:: ItemStruct ( .. ) => {
781
+ ast:: ItemStruct ( ref def , _ ) => {
779
782
if attr:: contains_name ( & i. attrs [ ..] , "simd" ) {
780
783
self . gate_feature ( "simd" , i. span ,
781
784
"SIMD types are experimental and possibly buggy" ) ;
@@ -794,6 +797,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
794
797
}
795
798
}
796
799
}
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
+ }
797
804
}
798
805
799
806
ast:: ItemDefaultImpl ( ..) => {
@@ -843,6 +850,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
843
850
"box expression syntax is experimental; \
844
851
you can call `Box::new` instead.") ;
845
852
}
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
+ }
846
859
_ => { }
847
860
}
848
861
visit:: walk_expr ( self , e) ;
@@ -867,6 +880,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
867
880
pattern. span ,
868
881
"box pattern syntax is experimental" ) ;
869
882
}
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
+ }
870
889
_ => { }
871
890
}
872
891
visit:: walk_pat ( self , pattern)
0 commit comments