@@ -699,16 +699,19 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
699699
700700 // Intrinsics are language primitives, not regular calls, so treat them separately.
701701 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.
702705 match tcx. lookup_const_stability ( callee) {
703706 None => {
704707 // Non-const intrinsic.
705708 self . check_op ( ops:: IntrinsicNonConst { name : intrinsic. name } ) ;
706709 }
707- Some ( ConstStability { feature : None , const_stable_indirect , .. } ) => {
710+ Some ( ConstStability { feature : None , .. } ) => {
708711 // Intrinsic does not need a separate feature gate (we rely on the
709712 // regular stability checker). However, we have to worry about recursive
710713 // const stability.
711- if !const_stable_indirect && self . enforce_recursive_const_stability ( ) {
714+ if !intrinsic . const_stable && self . enforce_recursive_const_stability ( ) {
712715 self . dcx ( ) . emit_err ( errors:: UnmarkedIntrinsicExposed {
713716 span : self . span ,
714717 def_path : self . tcx . def_path_str ( callee) ,
@@ -718,17 +721,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
718721 Some ( ConstStability {
719722 feature : Some ( feature) ,
720723 level : StabilityLevel :: Unstable { .. } ,
721- const_stable_indirect,
722724 ..
723725 } ) => {
724726 self . check_op ( ops:: IntrinsicUnstable {
725727 name : intrinsic. name ,
726728 feature,
727- const_stable_indirect ,
729+ const_stable : intrinsic . const_stable ,
728730 } ) ;
729731 }
730732 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) ;
732735 }
733736 }
734737 // This completes the checks for intrinsics.
0 commit comments