@@ -32,7 +32,7 @@ pub(super) fn check_trait<'tcx>(
32
32
impl_header : ty:: ImplTraitHeader < ' tcx > ,
33
33
) -> Result < ( ) , ErrorGuaranteed > {
34
34
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 } ;
36
36
let mut res = checker. check ( lang_items. drop_trait ( ) , visit_implementation_of_drop) ;
37
37
res = res. and ( checker. check ( lang_items. copy_trait ( ) , visit_implementation_of_copy) ) ;
38
38
res = res. and (
@@ -52,19 +52,9 @@ struct Checker<'tcx> {
52
52
trait_def_id : DefId ,
53
53
impl_def_id : LocalDefId ,
54
54
impl_header : ty:: ImplTraitHeader < ' tcx > ,
55
- trait_ref : ty:: TraitRef < ' tcx > ,
56
55
}
57
56
58
57
impl < ' 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
- }
68
58
fn check (
69
59
& self ,
70
60
trait_def_id : Option < DefId > ,
@@ -78,7 +68,7 @@ fn visit_implementation_of_drop(checker: &Checker<'_>) -> Result<(), ErrorGuaran
78
68
let tcx = checker. tcx ;
79
69
let impl_did = checker. impl_def_id ;
80
70
// 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 ( ) {
82
72
ty:: Adt ( def, _) if def. did ( ) . is_local ( ) => return Ok ( ( ) ) ,
83
73
ty:: Error ( _) => return Ok ( ( ) ) ,
84
74
_ => { }
@@ -95,7 +85,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
95
85
let impl_did = checker. impl_def_id ;
96
86
debug ! ( "visit_implementation_of_copy: impl_did={:?}" , impl_did) ;
97
87
98
- let self_type = checker . trait_ref . self_ty ( ) ;
88
+ let self_type = impl_header . trait_ref . instantiate_identity ( ) . self_ty ( ) ;
99
89
debug ! ( "visit_implementation_of_copy: self_type={:?} (bound)" , self_type) ;
100
90
101
91
let param_env = tcx. param_env ( impl_did) ;
@@ -129,7 +119,7 @@ fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), E
129
119
let tcx = checker. tcx ;
130
120
let header = checker. impl_header ;
131
121
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 ( ) ;
133
123
assert ! ( !self_type. has_escaping_bound_vars( ) ) ;
134
124
135
125
let param_env = tcx. param_env ( impl_did) ;
@@ -167,7 +157,7 @@ fn visit_implementation_of_coerce_unsized(checker: &Checker<'_>) -> Result<(), E
167
157
fn visit_implementation_of_dispatch_from_dyn ( checker : & Checker < ' _ > ) -> Result < ( ) , ErrorGuaranteed > {
168
158
let tcx = checker. tcx ;
169
159
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 ( ) ;
171
161
debug ! ( "visit_implementation_of_dispatch_from_dyn: impl_did={:?}" , impl_did) ;
172
162
173
163
let span = tcx. def_span ( impl_did) ;
0 commit comments