@@ -28,6 +28,9 @@ pub enum Status {
2828Unstable {
2929/// The feature that must be enabled to use this operation.
3030gate : Symbol ,
31+ /// Whether the feature gate was already checked (because the logic is a bit more
32+ /// complicated than just checking a single gate).
33+ gate_already_checked : bool ,
3134/// Whether it is allowed to use this operation from stable `const fn`.
3235/// This will usually be `false`.
3336safe_to_expose_on_stable : bool ,
@@ -82,6 +85,7 @@ impl<'tcx> NonConstOp<'tcx> for ConditionallyConstCall<'tcx> {
8285// We use the `const_trait_impl` gate for all conditionally-const calls.
8386Status :: Unstable {
8487gate : sym:: const_trait_impl,
88+ gate_already_checked : false ,
8589safe_to_expose_on_stable : false ,
8690// We don't want the "mark the callee as `#[rustc_const_stable_indirect]`" hint
8791is_function_call : false ,
@@ -330,19 +334,24 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
330334pub ( crate ) struct FnCallUnstable {
331335pub def_id : DefId ,
332336pub feature : Symbol ,
337+ /// If this is true, then the feature is enabled, but we need to still check if it is safe to
338+ /// expose on stable.
339+ pub feature_enabled : bool ,
333340pub safe_to_expose_on_stable : bool ,
334341}
335342
336343impl < ' tcx > NonConstOp < ' tcx > for FnCallUnstable {
337344fn status_in_item ( & self , _ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
338345Status :: Unstable {
339346gate : self . feature ,
347+ gate_already_checked : self . feature_enabled ,
340348safe_to_expose_on_stable : self . safe_to_expose_on_stable ,
341349is_function_call : true ,
342350}
343351}
344352
345353fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
354+ assert ! ( !self . feature_enabled) ;
346355let mut err = ccx. dcx ( ) . create_err ( errors:: UnstableConstFn {
347356 span,
348357def_path : ccx. tcx . def_path_str ( self . def_id ) ,
@@ -376,14 +385,15 @@ impl<'tcx> NonConstOp<'tcx> for IntrinsicNonConst {
376385pub ( crate ) struct IntrinsicUnstable {
377386pub name : Symbol ,
378387pub feature : Symbol ,
379- pub const_stable : bool ,
388+ pub const_stable_indirect : bool ,
380389}
381390
382391impl < ' tcx > NonConstOp < ' tcx > for IntrinsicUnstable {
383392fn status_in_item ( & self , _ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
384393Status :: Unstable {
385394gate : self . feature ,
386- safe_to_expose_on_stable : self . const_stable ,
395+ gate_already_checked : false ,
396+ safe_to_expose_on_stable : self . const_stable_indirect ,
387397// We do *not* want to suggest to mark the intrinsic as `const_stable_indirect`,
388398// that's not a trivial change!
389399is_function_call : false ,
@@ -410,6 +420,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
410420{
411421Status :: Unstable {
412422gate : sym:: const_async_blocks,
423+ gate_already_checked : false ,
413424safe_to_expose_on_stable : false ,
414425is_function_call : false ,
415426}
0 commit comments