@@ -699,16 +699,19 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
699
699
700
700
// Intrinsics are language primitives, not regular calls, so treat them separately.
701
701
if let Some ( intrinsic) = tcx. intrinsic ( callee) {
702
+ // We use `intrinsic.const_stable` to determine if this can be safely exposed to
703
+ // stable code, rather than `const_stable_indirect`. This is to make
704
+ // `#[rustc_const_stable_indirect]` an attribute that is always safe to add.
702
705
match tcx. lookup_const_stability ( callee) {
703
706
None => {
704
707
// Non-const intrinsic.
705
708
self . check_op ( ops:: IntrinsicNonConst { name : intrinsic. name } ) ;
706
709
}
707
- Some ( ConstStability { feature : None , const_stable_indirect , .. } ) => {
710
+ Some ( ConstStability { feature : None , .. } ) => {
708
711
// Intrinsic does not need a separate feature gate (we rely on the
709
712
// regular stability checker). However, we have to worry about recursive
710
713
// const stability.
711
- if !const_stable_indirect && self . enforce_recursive_const_stability ( ) {
714
+ if !intrinsic . const_stable && self . enforce_recursive_const_stability ( ) {
712
715
self . dcx ( ) . emit_err ( errors:: UnmarkedIntrinsicExposed {
713
716
span : self . span ,
714
717
def_path : self . tcx . def_path_str ( callee) ,
@@ -718,17 +721,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
718
721
Some ( ConstStability {
719
722
feature : Some ( feature) ,
720
723
level : StabilityLevel :: Unstable { .. } ,
721
- const_stable_indirect,
722
724
..
723
725
} ) => {
724
726
self . check_op ( ops:: IntrinsicUnstable {
725
727
name : intrinsic. name ,
726
728
feature,
727
- const_stable_indirect ,
729
+ const_stable : intrinsic . const_stable ,
728
730
} ) ;
729
731
}
730
732
Some ( ConstStability { level : StabilityLevel :: Stable { .. } , .. } ) => {
731
- // All good.
733
+ // All good. But ensure this is indeed a const-stable intrinsic.
734
+ assert ! ( intrinsic. const_stable) ;
732
735
}
733
736
}
734
737
// This completes the checks for intrinsics.
0 commit comments