@@ -464,6 +464,12 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
464
464
err_span,
465
465
) ;
466
466
}
467
+
468
+ fn crate_inject_span ( & self ) -> Option < Span > {
469
+ self . tcx . hir_crate_items ( ( ) ) . definitions ( ) . next ( ) . and_then ( |id| {
470
+ self . tcx . crate_level_attribute_injection_span ( self . tcx . local_def_id_to_hir_id ( id) )
471
+ } )
472
+ }
467
473
}
468
474
469
475
impl < ' tcx > Visitor < ' tcx > for Checker < ' _ , ' tcx > {
@@ -819,17 +825,11 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
819
825
feature,
820
826
..
821
827
} ) => {
822
- let suggestion =
823
- tcx. hir_crate_items ( ( ) ) . definitions ( ) . next ( ) . and_then ( |id| {
824
- tcx. crate_level_attribute_injection_span (
825
- tcx. local_def_id_to_hir_id ( id) ,
826
- )
827
- } ) ;
828
828
self . check_op ( ops:: IntrinsicUnstable {
829
829
name : intrinsic. name ,
830
830
feature,
831
831
const_stable_indirect : is_const_stable,
832
- suggestion,
832
+ suggestion : self . crate_inject_span ( ) ,
833
833
} ) ;
834
834
}
835
835
Some ( ConstStability { level : StabilityLevel :: Stable { .. } , .. } ) => {
@@ -923,18 +923,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
923
923
// Even if the feature is enabled, we still need check_op to double-check
924
924
// this if the callee is not safe to expose on stable.
925
925
if !feature_enabled || !callee_safe_to_expose_on_stable {
926
- let suggestion_span =
927
- tcx. hir_crate_items ( ( ) ) . definitions ( ) . next ( ) . and_then ( |id| {
928
- tcx. crate_level_attribute_injection_span (
929
- tcx. local_def_id_to_hir_id ( id) ,
930
- )
931
- } ) ;
932
926
self . check_op ( ops:: FnCallUnstable {
933
927
def_id : callee,
934
928
feature,
935
929
feature_enabled,
936
930
safe_to_expose_on_stable : callee_safe_to_expose_on_stable,
937
- suggestion_span,
931
+ suggestion_span : self . crate_inject_span ( ) ,
938
932
} ) ;
939
933
}
940
934
}
0 commit comments