@@ -155,11 +155,11 @@ enum ResolutionError<'a> {
155155 CannotCaptureDynamicEnvironmentInFnItem ,
156156 /// error E0435: attempt to use a non-constant value in a constant
157157 AttemptToUseNonConstantValueInConstant ,
158- /// error E0418 : X bindings cannot shadow Ys
158+ /// error E0530 : X bindings cannot shadow Ys
159159 BindingShadowsSomethingUnacceptable ( & ' a str , & ' a str , Name ) ,
160- /// error E0419 : unresolved pattern path kind `name`
160+ /// error E0531 : unresolved pattern path kind `name`
161161 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
163163 PatPathUnexpected ( & ' a str , & ' a str , & ' a Path ) ,
164164}
165165
@@ -426,11 +426,10 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
426426 ResolutionError :: BindingShadowsSomethingUnacceptable ( what_binding, shadows_what, name) => {
427427 let mut err = struct_span_err ! ( resolver. session,
428428 span,
429- E0418 ,
429+ E0530 ,
430430 "{}s cannot shadow {}s" , what_binding, shadows_what) ;
431431 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 ) {
434433 let participle = if binding. is_import ( ) { "imported" } else { "defined" } ;
435434 err. span_label ( binding. span , & format ! ( "a {} `{}` is {} here" ,
436435 shadows_what, name, participle) ) ;
@@ -440,15 +439,15 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
440439 ResolutionError :: PatPathUnresolved ( expected_what, path) => {
441440 struct_span_err ! ( resolver. session,
442441 span,
443- E0419 ,
442+ E0531 ,
444443 "unresolved {} `{}`" ,
445444 expected_what,
446445 path. segments. last( ) . unwrap( ) . identifier)
447446 }
448447 ResolutionError :: PatPathUnexpected ( expected_what, found_what, path) => {
449448 struct_span_err ! ( resolver. session,
450449 span,
451- E0420 ,
450+ E0532 ,
452451 "expected {}, found {} `{}`" ,
453452 expected_what,
454453 found_what,
@@ -2201,15 +2200,15 @@ impl<'a> Resolver<'a> {
22012200 pat_id : NodeId ,
22022201 outer_pat_id : NodeId ,
22032202 pat_src : PatternSource ,
2204- bindings_list : & mut HashMap < Name , NodeId > )
2203+ bindings : & mut HashMap < Name , NodeId > )
22052204 -> PathResolution {
22062205 // 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
22092208 // because that breaks the assumptions later
22102209 // passes make about or-patterns.)
22112210 let renamed = mtwt:: resolve ( ident. node ) ;
2212- let def = match bindings_list . get ( & renamed) . cloned ( ) {
2211+ let def = match bindings . get ( & renamed) . cloned ( ) {
22132212 Some ( id) if id == outer_pat_id => {
22142213 // `Variant(a, a)`, error
22152214 resolve_error (
@@ -2231,8 +2230,9 @@ impl<'a> Resolver<'a> {
22312230 Def :: Err
22322231 }
22332232 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]
22362236 }
22372237 Some ( ..) => {
22382238 span_bug ! ( ident. span, "two bindings with the same name from \
@@ -2244,7 +2244,7 @@ impl<'a> Resolver<'a> {
22442244 // define `Invalid` bindings as `Def::Local`, just don't add them to the lists.
22452245 let def = Def :: Local ( self . definitions . local_def_id ( pat_id) , pat_id) ;
22462246 if ident. node . name != keywords:: Invalid . name ( ) {
2247- bindings_list . insert ( renamed, outer_pat_id) ;
2247+ bindings . insert ( renamed, outer_pat_id) ;
22482248 self . value_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( renamed, def) ;
22492249 }
22502250 def
@@ -2255,12 +2255,12 @@ impl<'a> Resolver<'a> {
22552255 }
22562256
22572257 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 )
22642264 where ExpectedFn : FnOnce ( Def ) -> bool
22652265 {
22662266 let resolution = if let Some ( resolution) = self . resolve_possibly_assoc_item ( pat_id,
@@ -2307,8 +2307,8 @@ impl<'a> Resolver<'a> {
23072307 pat_src : PatternSource ,
23082308 // Maps idents to the node ID for the
23092309 // 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.
23122312 let outer_pat_id = pat. id ;
23132313 pat. walk ( & mut |pat| {
23142314 match pat. node {
@@ -2340,7 +2340,7 @@ impl<'a> Resolver<'a> {
23402340 // These entities are explicitly allowed
23412341 // to be shadowed by fresh bindings.
23422342 self . fresh_binding ( ident, pat. id , outer_pat_id,
2343- pat_src, bindings_list )
2343+ pat_src, bindings )
23442344 }
23452345 def => {
23462346 span_bug ! ( ident. span, "unexpected definition for an \
@@ -2349,7 +2349,7 @@ impl<'a> Resolver<'a> {
23492349 }
23502350 } else {
23512351 // 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 )
23532353 } ;
23542354
23552355 self . record_def ( pat. id , resolution) ;
0 commit comments