@@ -457,6 +457,12 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
457
457
err_span,
458
458
) ;
459
459
}
460
+
461
+ fn crate_inject_span ( & self ) -> Option < Span > {
462
+ self . tcx . hir_crate_items ( ( ) ) . definitions ( ) . next ( ) . and_then ( |id| {
463
+ self . tcx . crate_level_attribute_injection_span ( self . tcx . local_def_id_to_hir_id ( id) )
464
+ } )
465
+ }
460
466
}
461
467
462
468
impl < ' tcx > Visitor < ' tcx > for Checker < ' _ , ' tcx > {
@@ -799,17 +805,11 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
799
805
feature,
800
806
..
801
807
} ) => {
802
- let suggestion =
803
- tcx. hir_crate_items ( ( ) ) . definitions ( ) . next ( ) . and_then ( |id| {
804
- tcx. crate_level_attribute_injection_span (
805
- tcx. local_def_id_to_hir_id ( id) ,
806
- )
807
- } ) ;
808
808
self . check_op ( ops:: IntrinsicUnstable {
809
809
name : intrinsic. name ,
810
810
feature,
811
811
const_stable_indirect : is_const_stable,
812
- suggestion,
812
+ suggestion : self . crate_inject_span ( ) ,
813
813
} ) ;
814
814
}
815
815
Some ( ConstStability { level : StabilityLevel :: Stable { .. } , .. } ) => {
@@ -903,18 +903,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
903
903
// Even if the feature is enabled, we still need check_op to double-check
904
904
// this if the callee is not safe to expose on stable.
905
905
if !feature_enabled || !callee_safe_to_expose_on_stable {
906
- let suggestion_span =
907
- tcx. hir_crate_items ( ( ) ) . definitions ( ) . next ( ) . and_then ( |id| {
908
- tcx. crate_level_attribute_injection_span (
909
- tcx. local_def_id_to_hir_id ( id) ,
910
- )
911
- } ) ;
912
906
self . check_op ( ops:: FnCallUnstable {
913
907
def_id : callee,
914
908
feature,
915
909
feature_enabled,
916
910
safe_to_expose_on_stable : callee_safe_to_expose_on_stable,
917
- suggestion_span,
911
+ suggestion_span : self . crate_inject_span ( ) ,
918
912
} ) ;
919
913
}
920
914
}
0 commit comments