@@ -3812,9 +3812,10 @@ impl<'a> Resolver<'a> {
3812
3812
}
3813
3813
Some ( declaration) => {
3814
3814
for argument in declaration. inputs . iter ( ) {
3815
+ let mut bindings_list = HashMap :: new ( ) ;
3815
3816
this. resolve_pattern ( & * argument. pat ,
3816
3817
ArgumentIrrefutableMode ,
3817
- None ) ;
3818
+ & mut bindings_list ) ;
3818
3819
3819
3820
this. resolve_type ( & * argument. ty ) ;
3820
3821
@@ -4045,7 +4046,10 @@ impl<'a> Resolver<'a> {
4045
4046
}
4046
4047
4047
4048
// Resolve the pattern.
4048
- self . resolve_pattern ( & * local. pat , LocalIrrefutableMode , None ) ;
4049
+ let mut bindings_list = HashMap :: new ( ) ;
4050
+ self . resolve_pattern ( & * local. pat ,
4051
+ LocalIrrefutableMode ,
4052
+ & mut bindings_list) ;
4049
4053
}
4050
4054
4051
4055
// build a map from pattern identifiers to binding-info's.
@@ -4114,9 +4118,7 @@ impl<'a> Resolver<'a> {
4114
4118
4115
4119
let mut bindings_list = HashMap :: new ( ) ;
4116
4120
for pattern in arm. pats . iter ( ) {
4117
- self . resolve_pattern ( & * * pattern,
4118
- RefutableMode ,
4119
- Some ( & mut bindings_list) ) ;
4121
+ self . resolve_pattern ( & * * pattern, RefutableMode , & mut bindings_list) ;
4120
4122
}
4121
4123
4122
4124
// This has to happen *after* we determine which
@@ -4262,7 +4264,7 @@ impl<'a> Resolver<'a> {
4262
4264
mode : PatternBindingMode ,
4263
4265
// Maps idents to the node ID for the (outermost)
4264
4266
// pattern that binds them
4265
- mut bindings_list : Option < & mut HashMap < Name , NodeId > > ) {
4267
+ bindings_list : & mut HashMap < Name , NodeId > ) {
4266
4268
let pat_id = pattern. id ;
4267
4269
walk_pat ( pattern, |pattern| {
4268
4270
match pattern. node {
@@ -4351,43 +4353,27 @@ impl<'a> Resolver<'a> {
4351
4353
// because that breaks the assumptions later
4352
4354
// passes make about or-patterns.)
4353
4355
4354
- match bindings_list {
4355
- Some ( ref mut bindings_list)
4356
- if !bindings_list. contains_key ( & renamed) => {
4357
- let this = & mut * self ;
4358
- let value_ribs = this. value_ribs . borrow ( ) ;
4359
- let length = value_ribs. len ( ) ;
4360
- let last_rib = value_ribs. get (
4361
- length - 1 ) ;
4362
- last_rib. bindings . borrow_mut ( )
4363
- . insert ( renamed, DlDef ( def) ) ;
4364
- bindings_list. insert ( renamed, pat_id) ;
4365
- }
4366
- Some ( ref mut b) => {
4367
- if b. find ( & renamed) == Some ( & pat_id) {
4368
- // Then this is a duplicate variable
4369
- // in the same disjunct, which is an
4370
- // error
4371
- self . resolve_error ( pattern. span ,
4372
- format ! ( "identifier `{}` is bound \
4373
- more than once in the same \
4374
- pattern",
4375
- path_to_str( path) ) . as_slice ( ) ) ;
4376
- }
4377
- // Not bound in the same pattern: do nothing
4378
- }
4379
- None => {
4380
- let this = & mut * self ;
4381
- {
4382
- let value_ribs = this. value_ribs . borrow ( ) ;
4383
- let length = value_ribs. len ( ) ;
4384
- let last_rib = value_ribs. get (
4385
- length - 1 ) ;
4386
- last_rib. bindings . borrow_mut ( )
4387
- . insert ( renamed, DlDef ( def) ) ;
4388
- }
4389
- }
4356
+ if !bindings_list. contains_key ( & renamed) {
4357
+ let this = & mut * self ;
4358
+ let value_ribs = this. value_ribs . borrow ( ) ;
4359
+ let length = value_ribs. len ( ) ;
4360
+ let last_rib = value_ribs. get (
4361
+ length - 1 ) ;
4362
+ last_rib. bindings . borrow_mut ( )
4363
+ . insert ( renamed, DlDef ( def) ) ;
4364
+ bindings_list. insert ( renamed, pat_id) ;
4365
+ } else if bindings_list. find ( & renamed) ==
4366
+ Some ( & pat_id) {
4367
+ // Then this is a duplicate variable in the
4368
+ // same disjunction, which is an error.
4369
+ self . resolve_error ( pattern. span ,
4370
+ format ! ( "identifier `{}` is bound \
4371
+ more than once in the same \
4372
+ pattern",
4373
+ path_to_str( path) ) . as_slice ( ) ) ;
4390
4374
}
4375
+ // Else, not bound in the same pattern: do
4376
+ // nothing.
4391
4377
}
4392
4378
}
4393
4379
0 commit comments