@@ -560,6 +560,9 @@ declare_features! (
560
560
// Allows calling constructor functions in `const fn`.
561
561
( active, const_constructor, "1.37.0" , Some ( 61456 ) , None ) ,
562
562
563
+ // Allows `if/while p && let q = r && ...` chains.
564
+ ( active, let_chains, "1.37.0" , Some ( 53667 ) , None ) ,
565
+
563
566
// #[repr(transparent)] on enums.
564
567
( active, transparent_enums, "1.37.0" , Some ( 60405 ) , None ) ,
565
568
@@ -577,7 +580,8 @@ declare_features! (
577
580
const INCOMPLETE_FEATURES : & [ Symbol ] = & [
578
581
sym:: impl_trait_in_bindings,
579
582
sym:: generic_associated_types,
580
- sym:: const_generics
583
+ sym:: const_generics,
584
+ sym:: let_chains,
581
585
] ;
582
586
583
587
declare_features ! (
@@ -1936,6 +1940,27 @@ impl<'a> PostExpansionVisitor<'a> {
1936
1940
Err ( mut err) => err. emit ( ) ,
1937
1941
}
1938
1942
}
1943
+
1944
+ /// Recurse into all places where a `let` expression would be feature gated
1945
+ /// and emit gate post errors for those.
1946
+ fn find_and_gate_lets ( & mut self , e : & ' a ast:: Expr ) {
1947
+ match & e. node {
1948
+ ast:: ExprKind :: Paren ( e) => {
1949
+ self . find_and_gate_lets ( e) ;
1950
+ }
1951
+ ast:: ExprKind :: Binary ( op, lhs, rhs) if op. node == ast:: BinOpKind :: And => {
1952
+ self . find_and_gate_lets ( lhs) ;
1953
+ self . find_and_gate_lets ( rhs) ;
1954
+ }
1955
+ ast:: ExprKind :: Let ( ..) => {
1956
+ gate_feature_post ! (
1957
+ & self , let_chains, e. span,
1958
+ "`let` expressions in this position are experimental"
1959
+ ) ;
1960
+ }
1961
+ _ => { }
1962
+ }
1963
+ }
1939
1964
}
1940
1965
1941
1966
impl < ' a > Visitor < ' a > for PostExpansionVisitor < ' a > {
@@ -2133,6 +2158,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
2133
2158
2134
2159
fn visit_expr ( & mut self , e : & ' a ast:: Expr ) {
2135
2160
match e. node {
2161
+ ast:: ExprKind :: If ( ref e, ..) | ast:: ExprKind :: While ( ref e, ..) => match e. node {
2162
+ ast:: ExprKind :: Let ( ..) => { } // Stable!,
2163
+ _ => self . find_and_gate_lets ( e) ,
2164
+ }
2136
2165
ast:: ExprKind :: Box ( _) => {
2137
2166
gate_feature_post ! ( & self , box_syntax, e. span, EXPLAIN_BOX_SYNTAX ) ;
2138
2167
}
0 commit comments