@@ -2192,14 +2192,22 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2192
2192
self . check_proc_macro_attrs ( & item. attrs ) ;
2193
2193
2194
2194
match item. node {
2195
- ItemKind :: Enum ( _, ref generics) |
2196
2195
ItemKind :: Ty ( _, ref generics) |
2197
- ItemKind :: Existential ( _, ref generics) |
2198
- ItemKind :: Struct ( _, ref generics) |
2199
- ItemKind :: Union ( _, ref generics) |
2200
- ItemKind :: Fn ( _, _, ref generics, _) => {
2196
+ ItemKind :: Fn ( _, _, ref generics, _) |
2197
+ ItemKind :: Existential ( _, ref generics) => {
2201
2198
self . with_type_parameter_rib ( HasTypeParameters ( generics, ItemRibKind ) ,
2202
- |this| visit:: walk_item ( this, item) ) ;
2199
+ |this| visit:: walk_item ( this, item) ) ;
2200
+ }
2201
+
2202
+ ItemKind :: Enum ( _, ref generics) |
2203
+ ItemKind :: Struct ( _, ref generics) |
2204
+ ItemKind :: Union ( _, ref generics) => {
2205
+ self . with_type_parameter_rib ( HasTypeParameters ( generics, ItemRibKind ) , |this| {
2206
+ let item_def_id = this. definitions . local_def_id ( item. id ) ;
2207
+ this. with_self_rib ( Def :: SelfTy ( None , Some ( item_def_id) ) , |this| {
2208
+ visit:: walk_item ( this, item) ;
2209
+ } ) ;
2210
+ } ) ;
2203
2211
}
2204
2212
2205
2213
ItemKind :: Impl ( .., ref generics, ref opt_trait_ref, ref self_type, ref impl_items) =>
@@ -2489,13 +2497,14 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2489
2497
let item_def_id = this. definitions . local_def_id ( item_id) ;
2490
2498
this. with_self_rib ( Def :: SelfTy ( trait_id, Some ( item_def_id) ) , |this| {
2491
2499
if let Some ( trait_ref) = opt_trait_reference. as_ref ( ) {
2492
- // Resolve type arguments in trait path
2500
+ // Resolve type arguments in the trait path.
2493
2501
visit:: walk_trait_ref ( this, trait_ref) ;
2494
2502
}
2495
2503
// Resolve the self type.
2496
2504
this. visit_ty ( self_type) ;
2497
2505
// Resolve the type parameters.
2498
2506
this. visit_generics ( generics) ;
2507
+ // Resolve the items within the impl.
2499
2508
this. with_current_self_type ( self_type, |this| {
2500
2509
for impl_item in impl_items {
2501
2510
this. check_proc_macro_attrs ( & impl_item. attrs ) ;
@@ -2511,8 +2520,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2511
2520
// If this is a trait impl, ensure the const
2512
2521
// exists in trait
2513
2522
this. check_trait_item ( impl_item. ident ,
2514
- ValueNS ,
2515
- impl_item. span ,
2523
+ ValueNS ,
2524
+ impl_item. span ,
2516
2525
|n, s| ConstNotMemberOfTrait ( n, s) ) ;
2517
2526
this. with_constant_rib ( |this|
2518
2527
visit:: walk_impl_item ( this, impl_item)
@@ -2522,8 +2531,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2522
2531
// If this is a trait impl, ensure the method
2523
2532
// exists in trait
2524
2533
this. check_trait_item ( impl_item. ident ,
2525
- ValueNS ,
2526
- impl_item. span ,
2534
+ ValueNS ,
2535
+ impl_item. span ,
2527
2536
|n, s| MethodNotMemberOfTrait ( n, s) ) ;
2528
2537
2529
2538
visit:: walk_impl_item ( this, impl_item) ;
@@ -2532,8 +2541,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2532
2541
// If this is a trait impl, ensure the type
2533
2542
// exists in trait
2534
2543
this. check_trait_item ( impl_item. ident ,
2535
- TypeNS ,
2536
- impl_item. span ,
2544
+ TypeNS ,
2545
+ impl_item. span ,
2537
2546
|n, s| TypeNotMemberOfTrait ( n, s) ) ;
2538
2547
2539
2548
this. visit_ty ( ty) ;
@@ -2542,8 +2551,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2542
2551
// If this is a trait impl, ensure the type
2543
2552
// exists in trait
2544
2553
this. check_trait_item ( impl_item. ident ,
2545
- TypeNS ,
2546
- impl_item. span ,
2554
+ TypeNS ,
2555
+ impl_item. span ,
2547
2556
|n, s| TypeNotMemberOfTrait ( n, s) ) ;
2548
2557
2549
2558
for bound in bounds {
0 commit comments