@@ -736,16 +736,19 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
736
736
737
737
// Intrinsics are language primitives, not regular calls, so treat them separately.
738
738
if let Some ( intrinsic) = tcx. intrinsic ( callee) {
739
+ // We use `intrinsic.const_stable` to determine if this can be safely exposed to
740
+ // stable code, rather than `const_stable_indirect`. This is to make
741
+ // `#[rustc_const_stable_indirect]` an attribute that is always safe to add.
739
742
match tcx. lookup_const_stability ( callee) {
740
743
None => {
741
744
// Non-const intrinsic.
742
745
self . check_op ( ops:: IntrinsicNonConst { name : intrinsic. name } ) ;
743
746
}
744
- Some ( ConstStability { feature : None , const_stable_indirect , .. } ) => {
747
+ Some ( ConstStability { feature : None , .. } ) => {
745
748
// Intrinsic does not need a separate feature gate (we rely on the
746
749
// regular stability checker). However, we have to worry about recursive
747
750
// const stability.
748
- if !const_stable_indirect && self . enforce_recursive_const_stability ( ) {
751
+ if !intrinsic . const_stable && self . enforce_recursive_const_stability ( ) {
749
752
self . dcx ( ) . emit_err ( errors:: UnmarkedIntrinsicExposed {
750
753
span : self . span ,
751
754
def_path : self . tcx . def_path_str ( callee) ,
@@ -755,17 +758,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
755
758
Some ( ConstStability {
756
759
feature : Some ( feature) ,
757
760
level : StabilityLevel :: Unstable { .. } ,
758
- const_stable_indirect,
759
761
..
760
762
} ) => {
761
763
self . check_op ( ops:: IntrinsicUnstable {
762
764
name : intrinsic. name ,
763
765
feature,
764
- const_stable_indirect ,
766
+ const_stable : intrinsic . const_stable ,
765
767
} ) ;
766
768
}
767
769
Some ( ConstStability { level : StabilityLevel :: Stable { .. } , .. } ) => {
768
- // All good.
770
+ // All good. But ensure this is indeed a const-stable intrinsic.
771
+ assert ! ( intrinsic. const_stable) ;
769
772
}
770
773
}
771
774
// This completes the checks for intrinsics.
0 commit comments