@@ -38,7 +38,6 @@ fn do_orphan_check_impl<'tcx>(
38
38
def_id : LocalDefId ,
39
39
) -> Result < ( ) , ErrorGuaranteed > {
40
40
let trait_def_id = trait_ref. def_id ;
41
- let sp = tcx. def_span ( def_id) ;
42
41
43
42
match traits:: orphan_check ( tcx, def_id. to_def_id ( ) ) {
44
43
Ok ( ( ) ) => { }
@@ -48,6 +47,7 @@ fn do_orphan_check_impl<'tcx>(
48
47
bug ! ( "{:?} is not an impl: {:?}" , def_id, item) ;
49
48
} ;
50
49
let tr = impl_. of_trait . as_ref ( ) . unwrap ( ) ;
50
+ let sp = tcx. def_span ( def_id) ;
51
51
52
52
emit_orphan_check_error (
53
53
tcx,
@@ -237,7 +237,10 @@ fn do_orphan_check_impl<'tcx>(
237
237
| ty:: GeneratorWitnessMIR ( ..)
238
238
| ty:: Bound ( ..)
239
239
| ty:: Placeholder ( ..)
240
- | ty:: Infer ( ..) => span_bug ! ( sp, "weird self type for autotrait impl" ) ,
240
+ | ty:: Infer ( ..) => {
241
+ let sp = tcx. def_span ( def_id) ;
242
+ span_bug ! ( sp, "weird self type for autotrait impl" )
243
+ }
241
244
242
245
ty:: Error ( ..) => ( LocalImpl :: Allow , NonlocalImpl :: Allow ) ,
243
246
} ;
@@ -256,6 +259,7 @@ fn do_orphan_check_impl<'tcx>(
256
259
is one of the trait object's trait bounds",
257
260
trait = tcx. def_path_str( trait_def_id) ,
258
261
) ;
262
+ let sp = tcx. def_span ( def_id) ;
259
263
let reported =
260
264
struct_span_err ! ( tcx. sess, sp, E0321 , "{}" , msg) . note ( label) . emit ( ) ;
261
265
return Err ( reported) ;
@@ -284,6 +288,7 @@ fn do_orphan_check_impl<'tcx>(
284
288
non-struct/enum type",
285
289
) ) ,
286
290
} {
291
+ let sp = tcx. def_span ( def_id) ;
287
292
let reported =
288
293
struct_span_err ! ( tcx. sess, sp, E0321 , "{}" , msg) . span_label ( sp, label) . emit ( ) ;
289
294
return Err ( reported) ;
0 commit comments