@@ -496,6 +496,9 @@ struct DiagnosticMetadata<'ast> {
496
496
497
497
/// The current impl items (used to suggest).
498
498
current_impl_items : Option < & ' ast [ P < AssocItem > ] > ,
499
+
500
+ /// When processing impl trait
501
+ currently_processing_impl_trait : Option < ( TraitRef , Ty ) > ,
499
502
}
500
503
501
504
struct LateResolutionVisitor < ' a , ' b , ' ast > {
@@ -2066,18 +2069,22 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2066
2069
fn with_optional_trait_ref < T > (
2067
2070
& mut self ,
2068
2071
opt_trait_ref : Option < & TraitRef > ,
2072
+ self_type : & ' ast Ty ,
2069
2073
f : impl FnOnce ( & mut Self , Option < DefId > ) -> T ,
2070
2074
) -> T {
2071
2075
let mut new_val = None ;
2072
2076
let mut new_id = None ;
2073
2077
if let Some ( trait_ref) = opt_trait_ref {
2074
2078
let path: Vec < _ > = Segment :: from_path ( & trait_ref. path ) ;
2079
+ self . diagnostic_metadata . currently_processing_impl_trait =
2080
+ Some ( ( trait_ref. clone ( ) , self_type. clone ( ) ) ) ;
2075
2081
let res = self . smart_resolve_path_fragment (
2076
2082
None ,
2077
2083
& path,
2078
2084
PathSource :: Trait ( AliasPossibility :: No ) ,
2079
2085
Finalize :: new ( trait_ref. ref_id , trait_ref. path . span ) ,
2080
2086
) ;
2087
+ self . diagnostic_metadata . currently_processing_impl_trait = None ;
2081
2088
if let Some ( def_id) = res. base_res ( ) . opt_def_id ( ) {
2082
2089
new_id = Some ( def_id) ;
2083
2090
new_val = Some ( ( self . r . expect_module ( def_id) , trait_ref. clone ( ) ) ) ;
@@ -2118,7 +2125,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2118
2125
this. with_self_rib ( Res :: SelfTy { trait_ : None , alias_to : None } , |this| {
2119
2126
this. with_lifetime_rib ( LifetimeRibKind :: AnonymousCreateParameter ( item_id) , |this| {
2120
2127
// Resolve the trait reference, if necessary.
2121
- this. with_optional_trait_ref ( opt_trait_reference. as_ref ( ) , |this, trait_id| {
2128
+ this. with_optional_trait_ref ( opt_trait_reference. as_ref ( ) , self_type , |this, trait_id| {
2122
2129
let item_def_id = this. r . local_def_id ( item_id) ;
2123
2130
2124
2131
// Register the trait definitions from here.
0 commit comments