@@ -824,7 +824,7 @@ pub(crate) struct DiagMetadata<'ast> {
824824 current_impl_item : Option < & ' ast AssocItem > ,
825825
826826 /// When processing impl trait
827- currently_processing_impl_trait : Option < ( TraitRef , Ty ) > ,
827+ currently_processing_impl_trait : Option < ( & ' ast TraitRef , & ' ast Ty ) > ,
828828
829829 /// Accumulate the errors due to missed lifetime elision,
830830 /// and report them all at once for each function.
@@ -857,7 +857,7 @@ struct LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
857857 lifetime_elision_candidates : Option < Vec < ( LifetimeRes , LifetimeElisionCandidate ) > > ,
858858
859859 /// The trait that the current context can refer to.
860- current_trait_ref : Option < ( Module < ' ra > , TraitRef ) > ,
860+ current_trait_ref : Option < ( Module < ' ra > , & ' ast TraitRef ) > ,
861861
862862 /// Fields used to add information to diagnostic errors.
863863 diag_metadata : Box < DiagMetadata < ' ast > > ,
@@ -2004,8 +2004,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
20042004 // are we trying to use an anonymous lifetime
20052005 // on a non GAT associated trait type?
20062006 if !self . in_func_body
2007- && let Some ( ( module, _) ) = & self . current_trait_ref
2008- && let Some ( ty) = & self . diag_metadata . current_self_type
2007+ && let Some ( ( module, _) ) = self . current_trait_ref
2008+ && let Some ( ty) = self . diag_metadata . current_self_type
20092009 && Some ( true ) == self . diag_metadata . in_non_gat_assoc_type
20102010 && let crate :: ModuleKind :: Def ( DefKind :: Trait , trait_id, _, _) =
20112011 module. kind
@@ -3509,16 +3509,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35093509 /// This is called to resolve a trait reference from an `impl` (i.e., `impl Trait for Foo`).
35103510 fn with_optional_trait_ref < T > (
35113511 & mut self ,
3512- opt_trait_ref : Option < & TraitRef > ,
3512+ opt_trait_ref : Option < & ' ast TraitRef > ,
35133513 self_type : & ' ast Ty ,
35143514 f : impl FnOnce ( & mut Self , Option < DefId > ) -> T ,
35153515 ) -> T {
35163516 let mut new_val = None ;
35173517 let mut new_id = None ;
35183518 if let Some ( trait_ref) = opt_trait_ref {
35193519 let path: Vec < _ > = Segment :: from_path ( & trait_ref. path ) ;
3520- self . diag_metadata . currently_processing_impl_trait =
3521- Some ( ( trait_ref. clone ( ) , self_type. clone ( ) ) ) ;
3520+ self . diag_metadata . currently_processing_impl_trait = Some ( ( trait_ref, self_type) ) ;
35223521 let res = self . smart_resolve_path_fragment (
35233522 & None ,
35243523 & path,
@@ -3530,7 +3529,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35303529 self . diag_metadata . currently_processing_impl_trait = None ;
35313530 if let Some ( def_id) = res. expect_full_res ( ) . opt_def_id ( ) {
35323531 new_id = Some ( def_id) ;
3533- new_val = Some ( ( self . r . expect_module ( def_id) , trait_ref. clone ( ) ) ) ;
3532+ new_val = Some ( ( self . r . expect_module ( def_id) , trait_ref) ) ;
35343533 }
35353534 }
35363535 let original_trait_ref = replace ( & mut self . current_trait_ref , new_val) ;
@@ -3917,7 +3916,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
39173916 let Some ( decl) = decl else {
39183917 // We could not find the method: report an error.
39193918 let candidate = self . find_similarly_named_assoc_item ( reported_ident. name , kind) ;
3920- let path = & self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path ;
3919+ let path = & self . current_trait_ref . unwrap ( ) . 1 . path ;
39213920 let path_names = path_names_to_string ( path) ;
39223921 self . report_error ( span, err ( reported_ident, path_names, candidate) ) ;
39233922 feed_visibility ( self , module. def_id ( ) ) ;
@@ -3931,7 +3930,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
39313930 match seen_trait_items. entry ( id_in_trait) {
39323931 Entry :: Occupied ( entry) => {
39333932 let trait_span = decl. parent_module . unwrap ( ) . span . shrink_to_lo ( ) ;
3934- let impl_span = self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path . span ;
3933+ let impl_span = self . current_trait_ref . unwrap ( ) . 1 . path . span ;
39353934 self . report_error (
39363935 span,
39373936 ResolutionError :: TraitImplDuplicate {
@@ -3961,7 +3960,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
39613960 }
39623961
39633962 // The method kind does not correspond to what appeared in the trait, report.
3964- let path = & self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path ;
3963+ let path = & self . current_trait_ref . unwrap ( ) . 1 . path ;
39653964 let ( code, kind) = match kind {
39663965 AssocItemKind :: Const ( ..) => ( E0323 , "const" ) ,
39673966 AssocItemKind :: Fn ( ..) => ( E0324 , "method" ) ,
@@ -3973,7 +3972,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
39733972 } ;
39743973 let trait_path = path_names_to_string ( path) ;
39753974 let trait_span = decl. parent_module . unwrap ( ) . span . shrink_to_lo ( ) ;
3976- let impl_span = self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path . span ;
3975+ let impl_span = self . current_trait_ref . unwrap ( ) . 1 . path . span ;
39773976 self . report_error (
39783977 span,
39793978 ResolutionError :: TraitImplMismatch {
@@ -5542,7 +5541,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
55425541
55435542 fn record_traits_in_scope ( & mut self , node_id : NodeId , ident : Ident ) {
55445543 let traits = self . r . traits_in_scope (
5545- self . current_trait_ref . as_ref ( ) . map ( |( module, _) | * module) ,
5544+ self . current_trait_ref . map ( |( module, _) | module) ,
55465545 & self . parent_scope ,
55475546 ident. span ,
55485547 Some ( ( ident. name , ValueNS ) ) ,
0 commit comments