@@ -129,8 +129,6 @@ enum ResolutionError<'a> {
129129 IdentifierBoundMoreThanOnceInParameterList ( & ' a str ) ,
130130 /// error E0416: identifier is bound more than once in the same pattern
131131 IdentifierBoundMoreThanOnceInSamePattern ( & ' a str ) ,
132- /// error E0422: does not name a struct
133- DoesNotNameAStruct ( & ' a str ) ,
134132 /// error E0423: is a struct variant name, but this expression uses it like a function name
135133 StructVariantUsedAsFunction ( & ' a str ) ,
136134 /// error E0424: `self` is not available in a static method
@@ -336,15 +334,6 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
336334 err. span_label ( span, & format ! ( "used in a pattern more than once" ) ) ;
337335 err
338336 }
339- ResolutionError :: DoesNotNameAStruct ( name) => {
340- let mut err = struct_span_err ! ( resolver. session,
341- span,
342- E0422 ,
343- "`{}` does not name a structure" ,
344- name) ;
345- err. span_label ( span, & format ! ( "not a structure" ) ) ;
346- err
347- }
348337 ResolutionError :: StructVariantUsedAsFunction ( path_name) => {
349338 let mut err = struct_span_err ! ( resolver. session,
350339 span,
@@ -2383,6 +2372,18 @@ impl<'a> Resolver<'a> {
23832372 self . record_def ( pat_id, resolution) ;
23842373 }
23852374
2375+ fn resolve_struct_path ( & mut self , node_id : NodeId , path : & Path ) {
2376+ // Resolution logic is equivalent for expressions and patterns,
2377+ // reuse `resolve_pattern_path` for both.
2378+ self . resolve_pattern_path ( node_id, None , path, TypeNS , |def| {
2379+ match def {
2380+ Def :: Struct ( ..) | Def :: Union ( ..) | Def :: Variant ( ..) |
2381+ Def :: TyAlias ( ..) | Def :: AssociatedTy ( ..) | Def :: SelfTy ( ..) => true ,
2382+ _ => false ,
2383+ }
2384+ } , "struct, variant or union type" ) ;
2385+ }
2386+
23862387 fn resolve_pattern ( & mut self ,
23872388 pat : & Pat ,
23882389 pat_src : PatternSource ,
@@ -2460,13 +2461,7 @@ impl<'a> Resolver<'a> {
24602461 }
24612462
24622463 PatKind :: Struct ( ref path, ..) => {
2463- self . resolve_pattern_path ( pat. id , None , path, TypeNS , |def| {
2464- match def {
2465- Def :: Struct ( ..) | Def :: Union ( ..) | Def :: Variant ( ..) |
2466- Def :: TyAlias ( ..) | Def :: AssociatedTy ( ..) => true ,
2467- _ => false ,
2468- }
2469- } , "variant, struct or type alias" ) ;
2464+ self . resolve_struct_path ( pat. id , path) ;
24702465 }
24712466
24722467 _ => { }
@@ -3024,23 +3019,7 @@ impl<'a> Resolver<'a> {
30243019 }
30253020
30263021 ExprKind :: Struct ( ref path, ..) => {
3027- // Resolve the path to the structure it goes to. We don't
3028- // check to ensure that the path is actually a structure; that
3029- // is checked later during typeck.
3030- match self . resolve_path ( expr. id , path, 0 , TypeNS ) {
3031- Ok ( definition) => self . record_def ( expr. id , definition) ,
3032- Err ( true ) => self . record_def ( expr. id , err_path_resolution ( ) ) ,
3033- Err ( false ) => {
3034- debug ! ( "(resolving expression) didn't find struct def" , ) ;
3035-
3036- resolve_error ( self ,
3037- path. span ,
3038- ResolutionError :: DoesNotNameAStruct (
3039- & path_names_to_string ( path, 0 ) )
3040- ) ;
3041- self . record_def ( expr. id , err_path_resolution ( ) ) ;
3042- }
3043- }
3022+ self . resolve_struct_path ( expr. id , path) ;
30443023
30453024 visit:: walk_expr ( self , expr) ;
30463025 }
0 commit comments