@@ -18,25 +18,17 @@ pub(crate) fn orphan_check_impl(
18
18
let trait_ref = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) . instantiate_identity ( ) ;
19
19
trait_ref. error_reported ( ) ?;
20
20
21
- do_orphan_check_impl ( tcx, trait_ref, impl_def_id)
22
- }
23
-
24
- fn do_orphan_check_impl < ' tcx > (
25
- tcx : TyCtxt < ' tcx > ,
26
- trait_ref : ty:: TraitRef < ' tcx > ,
27
- def_id : LocalDefId ,
28
- ) -> Result < ( ) , ErrorGuaranteed > {
29
21
let trait_def_id = trait_ref. def_id ;
30
22
31
- match traits:: orphan_check ( tcx, def_id . to_def_id ( ) ) {
23
+ match traits:: orphan_check ( tcx, impl_def_id . to_def_id ( ) ) {
32
24
Ok ( ( ) ) => { }
33
25
Err ( err) => {
34
- let item = tcx. hir ( ) . expect_item ( def_id ) ;
26
+ let item = tcx. hir ( ) . expect_item ( impl_def_id ) ;
35
27
let hir:: ItemKind :: Impl ( impl_) = item. kind else {
36
- bug ! ( "{:?} is not an impl: {:?}" , def_id , item) ;
28
+ bug ! ( "{:?} is not an impl: {:?}" , impl_def_id , item) ;
37
29
} ;
38
30
let tr = impl_. of_trait . as_ref ( ) . unwrap ( ) ;
39
- let sp = tcx. def_span ( def_id ) ;
31
+ let sp = tcx. def_span ( impl_def_id ) ;
40
32
41
33
emit_orphan_check_error (
42
34
tcx,
@@ -180,7 +172,7 @@ fn do_orphan_check_impl<'tcx>(
180
172
// impl<T> AutoTrait for T {}
181
173
// impl<T: ?Sized> AutoTrait for T {}
182
174
ty:: Param ( ..) => (
183
- if self_ty. is_sized ( tcx, tcx. param_env ( def_id ) ) {
175
+ if self_ty. is_sized ( tcx, tcx. param_env ( impl_def_id ) ) {
184
176
LocalImpl :: Allow
185
177
} else {
186
178
LocalImpl :: Disallow { problematic_kind : "generic type" }
@@ -237,7 +229,7 @@ fn do_orphan_check_impl<'tcx>(
237
229
| ty:: Bound ( ..)
238
230
| ty:: Placeholder ( ..)
239
231
| ty:: Infer ( ..) => {
240
- let sp = tcx. def_span ( def_id ) ;
232
+ let sp = tcx. def_span ( impl_def_id ) ;
241
233
span_bug ! ( sp, "weird self type for autotrait impl" )
242
234
}
243
235
@@ -249,7 +241,7 @@ fn do_orphan_check_impl<'tcx>(
249
241
LocalImpl :: Allow => { }
250
242
LocalImpl :: Disallow { problematic_kind } => {
251
243
return Err ( tcx. dcx ( ) . emit_err ( errors:: TraitsWithDefaultImpl {
252
- span : tcx. def_span ( def_id ) ,
244
+ span : tcx. def_span ( impl_def_id ) ,
253
245
traits : tcx. def_path_str ( trait_def_id) ,
254
246
problematic_kind,
255
247
self_ty,
@@ -261,13 +253,13 @@ fn do_orphan_check_impl<'tcx>(
261
253
NonlocalImpl :: Allow => { }
262
254
NonlocalImpl :: DisallowBecauseNonlocal => {
263
255
return Err ( tcx. dcx ( ) . emit_err ( errors:: CrossCrateTraitsDefined {
264
- span : tcx. def_span ( def_id ) ,
256
+ span : tcx. def_span ( impl_def_id ) ,
265
257
traits : tcx. def_path_str ( trait_def_id) ,
266
258
} ) ) ;
267
259
}
268
260
NonlocalImpl :: DisallowOther => {
269
261
return Err ( tcx. dcx ( ) . emit_err ( errors:: CrossCrateTraits {
270
- span : tcx. def_span ( def_id ) ,
262
+ span : tcx. def_span ( impl_def_id ) ,
271
263
traits : tcx. def_path_str ( trait_def_id) ,
272
264
self_ty,
273
265
} ) ) ;
0 commit comments