@@ -1109,7 +1109,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
11091109 }
11101110
11111111 fn resolve_params ( & mut self , params : & [ Param ] ) {
1112- let mut bindings = smallvec ! [ ( false , <_> :: default ( ) ) ] ;
1112+ let mut bindings = smallvec ! [ ( false , Default :: default ( ) ) ] ;
11131113 for Param { pat, ty, .. } in params {
11141114 self . resolve_pattern ( pat, PatternSource :: FnParam , & mut bindings) ;
11151115 self . visit_ty ( ty) ;
@@ -1255,7 +1255,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
12551255
12561256 /// Arising from `source`, resolve a top level pattern.
12571257 fn resolve_pattern_top ( & mut self , pat : & Pat , pat_src : PatternSource ) {
1258- self . resolve_pattern ( pat, pat_src, & mut smallvec ! [ ( false , <_> :: default ( ) ) ] ) ;
1258+ self . resolve_pattern ( pat, pat_src, & mut smallvec ! [ ( false , Default :: default ( ) ) ] ) ;
12591259 }
12601260
12611261 fn resolve_pattern (
@@ -1270,6 +1270,25 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
12701270 visit:: walk_pat ( self , pat) ;
12711271 }
12721272
1273+ /// Resolve bindings in a pattern. This is a helper to `resolve_pattern`.
1274+ ///
1275+ /// ### `bindings`
1276+ ///
1277+ /// A stack of sets of bindings accumulated.
1278+ ///
1279+ /// In each set, `false` denotes that a found binding in it should be interpreted as
1280+ /// re-binding an already bound binding. This results in an error. Meanwhile, `true`
1281+ /// denotes that a found binding in the set should result in reusing this binding
1282+ /// rather than creating a fresh one. In other words, `false` and `true` correspond
1283+ /// to product (e.g., `(a, b)`) and sum/or contexts (e.g., `p_0 | ... | p_i`) respectively.
1284+ ///
1285+ /// When called at the top level, the stack should have a single element with `false`.
1286+ /// Otherwise, pushing to the stack happens as or-patterns are encountered and the
1287+ /// context needs to be switched to `true` and then `false` for each `p_i.
1288+ /// When each `p_i` has been dealt with, the top set is merged with its parent.
1289+ /// When a whole or-pattern has been dealt with, the thing happens.
1290+ ///
1291+ /// See the implementation and `fresh_binding` for more details.
12731292 fn resolve_pattern_inner (
12741293 & mut self ,
12751294 pat : & Pat ,
@@ -1301,12 +1320,12 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
13011320 // Add a new set of bindings to the stack. `true` here records that when a
13021321 // binding already exists in this set, it should not result in an error because
13031322 // `V1(a) | V2(a)` must be allowed and are checked for consistency later.
1304- bindings. push ( ( true , < _ > :: default ( ) ) ) ;
1323+ bindings. push ( ( true , Default :: default ( ) ) ) ;
13051324 for p in ps {
13061325 // Now we need to switch back to a product context so that each
13071326 // part of the or-pattern internally rejects already bound names.
13081327 // For example, `V1(a) | V2(a, a)` and `V1(a, a) | V2(a)` are bad.
1309- bindings. push ( ( false , < _ > :: default ( ) ) ) ;
1328+ bindings. push ( ( false , Default :: default ( ) ) ) ;
13101329 self . resolve_pattern_inner ( p, pat_src, bindings) ;
13111330 // Move up the non-overlapping bindings to the or-pattern.
13121331 // Existing bindings just get "merged".
0 commit comments