@@ -155,11 +155,11 @@ enum ResolutionError<'a> {
155
155
CannotCaptureDynamicEnvironmentInFnItem ,
156
156
/// error E0435: attempt to use a non-constant value in a constant
157
157
AttemptToUseNonConstantValueInConstant ,
158
- /// error E0418 : X bindings cannot shadow Ys
158
+ /// error E0530 : X bindings cannot shadow Ys
159
159
BindingShadowsSomethingUnacceptable ( & ' a str , & ' a str , Name ) ,
160
- /// error E0419 : unresolved pattern path kind `name`
160
+ /// error E0531 : unresolved pattern path kind `name`
161
161
PatPathUnresolved ( & ' a str , & ' a Path ) ,
162
- /// error E0420 : expected pattern path kind, found another pattern path kind
162
+ /// error E0532 : expected pattern path kind, found another pattern path kind
163
163
PatPathUnexpected ( & ' a str , & ' a str , & ' a Path ) ,
164
164
}
165
165
@@ -426,11 +426,10 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
426
426
ResolutionError :: BindingShadowsSomethingUnacceptable ( what_binding, shadows_what, name) => {
427
427
let mut err = struct_span_err ! ( resolver. session,
428
428
span,
429
- E0418 ,
429
+ E0530 ,
430
430
"{}s cannot shadow {}s" , what_binding, shadows_what) ;
431
431
err. span_label ( span, & format ! ( "cannot be named the same as a {}" , shadows_what) ) ;
432
- if let Some ( binding) = resolver. current_module
433
- . resolve_name_in_lexical_scope ( name, ValueNS ) {
432
+ if let Success ( binding) = resolver. current_module . resolve_name ( name, ValueNS , true ) {
434
433
let participle = if binding. is_import ( ) { "imported" } else { "defined" } ;
435
434
err. span_label ( binding. span , & format ! ( "a {} `{}` is {} here" ,
436
435
shadows_what, name, participle) ) ;
@@ -440,15 +439,15 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
440
439
ResolutionError :: PatPathUnresolved ( expected_what, path) => {
441
440
struct_span_err ! ( resolver. session,
442
441
span,
443
- E0419 ,
442
+ E0531 ,
444
443
"unresolved {} `{}`" ,
445
444
expected_what,
446
445
path. segments. last( ) . unwrap( ) . identifier)
447
446
}
448
447
ResolutionError :: PatPathUnexpected ( expected_what, found_what, path) => {
449
448
struct_span_err ! ( resolver. session,
450
449
span,
451
- E0420 ,
450
+ E0532 ,
452
451
"expected {}, found {} `{}`" ,
453
452
expected_what,
454
453
found_what,
@@ -2201,15 +2200,15 @@ impl<'a> Resolver<'a> {
2201
2200
pat_id : NodeId ,
2202
2201
outer_pat_id : NodeId ,
2203
2202
pat_src : PatternSource ,
2204
- bindings_list : & mut HashMap < Name , NodeId > )
2203
+ bindings : & mut HashMap < Name , NodeId > )
2205
2204
-> PathResolution {
2206
2205
// Add the binding to the local ribs, if it
2207
- // doesn't already exist in the bindings list . (We
2208
- // must not add it if it's in the bindings list
2206
+ // doesn't already exist in the bindings map . (We
2207
+ // must not add it if it's in the bindings map
2209
2208
// because that breaks the assumptions later
2210
2209
// passes make about or-patterns.)
2211
2210
let renamed = mtwt:: resolve ( ident. node ) ;
2212
- let def = match bindings_list . get ( & renamed) . cloned ( ) {
2211
+ let def = match bindings . get ( & renamed) . cloned ( ) {
2213
2212
Some ( id) if id == outer_pat_id => {
2214
2213
// `Variant(a, a)`, error
2215
2214
resolve_error (
@@ -2231,8 +2230,9 @@ impl<'a> Resolver<'a> {
2231
2230
Def :: Err
2232
2231
}
2233
2232
Some ( ..) if pat_src == PatternSource :: Match => {
2234
- // `Varian1(a) | Varian2(a)`, ok
2235
- Def :: Local ( self . definitions . local_def_id ( pat_id) , pat_id)
2233
+ // `Variant1(a) | Variant2(a)`, ok
2234
+ // Reuse definition from the first `a`.
2235
+ self . value_ribs . last_mut ( ) . unwrap ( ) . bindings [ & renamed]
2236
2236
}
2237
2237
Some ( ..) => {
2238
2238
span_bug ! ( ident. span, "two bindings with the same name from \
@@ -2244,7 +2244,7 @@ impl<'a> Resolver<'a> {
2244
2244
// define `Invalid` bindings as `Def::Local`, just don't add them to the lists.
2245
2245
let def = Def :: Local ( self . definitions . local_def_id ( pat_id) , pat_id) ;
2246
2246
if ident. node . name != keywords:: Invalid . name ( ) {
2247
- bindings_list . insert ( renamed, outer_pat_id) ;
2247
+ bindings . insert ( renamed, outer_pat_id) ;
2248
2248
self . value_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( renamed, def) ;
2249
2249
}
2250
2250
def
@@ -2255,12 +2255,12 @@ impl<'a> Resolver<'a> {
2255
2255
}
2256
2256
2257
2257
fn resolve_pattern_path < ExpectedFn > ( & mut self ,
2258
- pat_id : NodeId ,
2259
- qself : Option < & QSelf > ,
2260
- path : & Path ,
2261
- namespace : Namespace ,
2262
- expected_fn : ExpectedFn ,
2263
- expected_what : & ' static str )
2258
+ pat_id : NodeId ,
2259
+ qself : Option < & QSelf > ,
2260
+ path : & Path ,
2261
+ namespace : Namespace ,
2262
+ expected_fn : ExpectedFn ,
2263
+ expected_what : & str )
2264
2264
where ExpectedFn : FnOnce ( Def ) -> bool
2265
2265
{
2266
2266
let resolution = if let Some ( resolution) = self . resolve_possibly_assoc_item ( pat_id,
@@ -2307,8 +2307,8 @@ impl<'a> Resolver<'a> {
2307
2307
pat_src : PatternSource ,
2308
2308
// Maps idents to the node ID for the
2309
2309
// outermost pattern that binds them.
2310
- bindings_list : & mut HashMap < Name , NodeId > ) {
2311
- // Visit all direct subpatterns of this pattern with the same PatternBindingMode .
2310
+ bindings : & mut HashMap < Name , NodeId > ) {
2311
+ // Visit all direct subpatterns of this pattern.
2312
2312
let outer_pat_id = pat. id ;
2313
2313
pat. walk ( & mut |pat| {
2314
2314
match pat. node {
@@ -2340,7 +2340,7 @@ impl<'a> Resolver<'a> {
2340
2340
// These entities are explicitly allowed
2341
2341
// to be shadowed by fresh bindings.
2342
2342
self . fresh_binding ( ident, pat. id , outer_pat_id,
2343
- pat_src, bindings_list )
2343
+ pat_src, bindings )
2344
2344
}
2345
2345
def => {
2346
2346
span_bug ! ( ident. span, "unexpected definition for an \
@@ -2349,7 +2349,7 @@ impl<'a> Resolver<'a> {
2349
2349
}
2350
2350
} else {
2351
2351
// Fall back to a fresh binding.
2352
- self . fresh_binding ( ident, pat. id , outer_pat_id, pat_src, bindings_list )
2352
+ self . fresh_binding ( ident, pat. id , outer_pat_id, pat_src, bindings )
2353
2353
} ;
2354
2354
2355
2355
self . record_def ( pat. id , resolution) ;
0 commit comments