@@ -32,7 +32,7 @@ pub(super) fn check_trait<'tcx>(
3232 impl_header : ty:: ImplTraitHeader < ' tcx > ,
3333) -> Result < ( ) , ErrorGuaranteed > {
3434 let lang_items = tcx. lang_items ( ) ;
35- let checker = Checker :: new ( tcx, trait_def_id, impl_def_id, impl_header) ;
35+ let checker = Checker { tcx, trait_def_id, impl_def_id, impl_header } ;
3636 let mut res = checker. check ( lang_items. drop_trait ( ) , visit_implementation_of_drop) ;
3737 res = res. and ( checker. check ( lang_items. copy_trait ( ) , visit_implementation_of_copy) ) ;
3838 res = res. and (
@@ -52,19 +52,9 @@ struct Checker<'tcx> {
5252 trait_def_id : DefId ,
5353 impl_def_id : LocalDefId ,
5454 impl_header : ty:: ImplTraitHeader < ' tcx > ,
55- trait_ref : ty:: TraitRef < ' tcx > ,
5655}
5756
5857impl < ' tcx > Checker < ' tcx > {
59- fn new (
60- tcx : TyCtxt < ' tcx > ,
61- trait_def_id : DefId ,
62- impl_def_id : LocalDefId ,
63- impl_header : ty:: ImplTraitHeader < ' tcx > ,
64- ) -> Self {
65- let trait_ref = impl_header. trait_ref . instantiate_identity ( ) ;
66- Self { tcx, trait_def_id, impl_def_id, impl_header, trait_ref }
67- }
6858 fn check (
6959 & self ,
7060 trait_def_id : Option < DefId > ,
@@ -78,7 +68,7 @@ fn visit_implementation_of_drop(checker: &Checker<'_>) -> Result<(), ErrorGuaran
7868 let tcx = checker. tcx ;
7969 let impl_did = checker. impl_def_id ;
8070 // Destructors only work on local ADT types.
81- match checker. trait_ref . self_ty ( ) . kind ( ) {
71+ match checker. impl_header . trait_ref . instantiate_identity ( ) . self_ty ( ) . kind ( ) {
8272 ty:: Adt ( def, _) if def. did ( ) . is_local ( ) => return Ok ( ( ) ) ,
8373 ty:: Error ( _) => return Ok ( ( ) ) ,
8474 _ => { }
@@ -95,7 +85,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
9585 let impl_did = checker. impl_def_id ;
9686 debug ! ( "visit_implementation_of_copy: impl_did={:?}" , impl_did) ;
9787
98- let self_type = checker . trait_ref . self_ty ( ) ;
88+ let self_type = impl_header . trait_ref . instantiate_identity ( ) . self_ty ( ) ;
9989 debug ! ( "visit_implementation_of_copy: self_type={:?} (bound)" , self_type) ;
10090
10191 let param_env = tcx. param_env ( impl_did) ;
@@ -129,7 +119,7 @@ fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), E
129119 let tcx = checker. tcx ;
130120 let header = checker. impl_header ;
131121 let impl_did = checker. impl_def_id ;
132- let self_type = checker . trait_ref . self_ty ( ) ;
122+ let self_type = header . trait_ref . instantiate_identity ( ) . self_ty ( ) ;
133123 assert ! ( !self_type. has_escaping_bound_vars( ) ) ;
134124
135125 let param_env = tcx. param_env ( impl_did) ;
@@ -167,7 +157,7 @@ fn visit_implementation_of_coerce_unsized(checker: &Checker<'_>) -> Result<(), E
167157fn visit_implementation_of_dispatch_from_dyn ( checker : & Checker < ' _ > ) -> Result < ( ) , ErrorGuaranteed > {
168158 let tcx = checker. tcx ;
169159 let impl_did = checker. impl_def_id ;
170- let trait_ref = checker. trait_ref ;
160+ let trait_ref = checker. impl_header . trait_ref . instantiate_identity ( ) ;
171161 debug ! ( "visit_implementation_of_dispatch_from_dyn: impl_did={:?}" , impl_did) ;
172162
173163 let span = tcx. def_span ( impl_did) ;
0 commit comments