@@ -1109,7 +1109,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
1109
1109
}
1110
1110
1111
1111
fn resolve_params ( & mut self , params : & [ Param ] ) {
1112
- let mut bindings = smallvec ! [ ( false , <_> :: default ( ) ) ] ;
1112
+ let mut bindings = smallvec ! [ ( false , Default :: default ( ) ) ] ;
1113
1113
for Param { pat, ty, .. } in params {
1114
1114
self . resolve_pattern ( pat, PatternSource :: FnParam , & mut bindings) ;
1115
1115
self . visit_ty ( ty) ;
@@ -1255,7 +1255,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
1255
1255
1256
1256
/// Arising from `source`, resolve a top level pattern.
1257
1257
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 ( ) ) ] ) ;
1259
1259
}
1260
1260
1261
1261
fn resolve_pattern (
@@ -1270,6 +1270,25 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
1270
1270
visit:: walk_pat ( self , pat) ;
1271
1271
}
1272
1272
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.
1273
1292
fn resolve_pattern_inner (
1274
1293
& mut self ,
1275
1294
pat : & Pat ,
@@ -1301,12 +1320,12 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
1301
1320
// Add a new set of bindings to the stack. `true` here records that when a
1302
1321
// binding already exists in this set, it should not result in an error because
1303
1322
// `V1(a) | V2(a)` must be allowed and are checked for consistency later.
1304
- bindings. push ( ( true , < _ > :: default ( ) ) ) ;
1323
+ bindings. push ( ( true , Default :: default ( ) ) ) ;
1305
1324
for p in ps {
1306
1325
// Now we need to switch back to a product context so that each
1307
1326
// part of the or-pattern internally rejects already bound names.
1308
1327
// 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 ( ) ) ) ;
1310
1329
self . resolve_pattern_inner ( p, pat_src, bindings) ;
1311
1330
// Move up the non-overlapping bindings to the or-pattern.
1312
1331
// Existing bindings just get "merged".
0 commit comments