@@ -38,7 +38,6 @@ fn do_orphan_check_impl<'tcx>(
3838 def_id : LocalDefId ,
3939) -> Result < ( ) , ErrorGuaranteed > {
4040 let trait_def_id = trait_ref. def_id ;
41- let sp = tcx. def_span ( def_id) ;
4241
4342 match traits:: orphan_check ( tcx, def_id. to_def_id ( ) ) {
4443 Ok ( ( ) ) => { }
@@ -48,6 +47,7 @@ fn do_orphan_check_impl<'tcx>(
4847 bug ! ( "{:?} is not an impl: {:?}" , def_id, item) ;
4948 } ;
5049 let tr = impl_. of_trait . as_ref ( ) . unwrap ( ) ;
50+ let sp = tcx. def_span ( def_id) ;
5151
5252 emit_orphan_check_error (
5353 tcx,
@@ -237,7 +237,10 @@ fn do_orphan_check_impl<'tcx>(
237237 | ty:: GeneratorWitnessMIR ( ..)
238238 | ty:: Bound ( ..)
239239 | 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+ }
241244
242245 ty:: Error ( ..) => ( LocalImpl :: Allow , NonlocalImpl :: Allow ) ,
243246 } ;
@@ -256,6 +259,7 @@ fn do_orphan_check_impl<'tcx>(
256259 is one of the trait object's trait bounds",
257260 trait = tcx. def_path_str( trait_def_id) ,
258261 ) ;
262+ let sp = tcx. def_span ( def_id) ;
259263 let reported =
260264 struct_span_err ! ( tcx. sess, sp, E0321 , "{}" , msg) . note ( label) . emit ( ) ;
261265 return Err ( reported) ;
@@ -284,6 +288,7 @@ fn do_orphan_check_impl<'tcx>(
284288 non-struct/enum type",
285289 ) ) ,
286290 } {
291+ let sp = tcx. def_span ( def_id) ;
287292 let reported =
288293 struct_span_err ! ( tcx. sess, sp, E0321 , "{}" , msg) . span_label ( sp, label) . emit ( ) ;
289294 return Err ( reported) ;
0 commit comments