@@ -129,8 +129,6 @@ enum ResolutionError<'a> {
129
129
IdentifierBoundMoreThanOnceInParameterList ( & ' a str ) ,
130
130
/// error E0416: identifier is bound more than once in the same pattern
131
131
IdentifierBoundMoreThanOnceInSamePattern ( & ' a str ) ,
132
- /// error E0422: does not name a struct
133
- DoesNotNameAStruct ( & ' a str ) ,
134
132
/// error E0423: is a struct variant name, but this expression uses it like a function name
135
133
StructVariantUsedAsFunction ( & ' a str ) ,
136
134
/// 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>,
336
334
err. span_label ( span, & format ! ( "used in a pattern more than once" ) ) ;
337
335
err
338
336
}
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
- }
348
337
ResolutionError :: StructVariantUsedAsFunction ( path_name) => {
349
338
let mut err = struct_span_err ! ( resolver. session,
350
339
span,
@@ -2383,6 +2372,18 @@ impl<'a> Resolver<'a> {
2383
2372
self . record_def ( pat_id, resolution) ;
2384
2373
}
2385
2374
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
+
2386
2387
fn resolve_pattern ( & mut self ,
2387
2388
pat : & Pat ,
2388
2389
pat_src : PatternSource ,
@@ -2460,13 +2461,7 @@ impl<'a> Resolver<'a> {
2460
2461
}
2461
2462
2462
2463
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) ;
2470
2465
}
2471
2466
2472
2467
_ => { }
@@ -3024,23 +3019,7 @@ impl<'a> Resolver<'a> {
3024
3019
}
3025
3020
3026
3021
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) ;
3044
3023
3045
3024
visit:: walk_expr ( self , expr) ;
3046
3025
}
0 commit comments