@@ -28,6 +28,9 @@ pub enum Status {
28
28
Unstable {
29
29
/// The feature that must be enabled to use this operation.
30
30
gate : 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 ,
31
34
/// Whether it is allowed to use this operation from stable `const fn`.
32
35
/// This will usually be `false`.
33
36
safe_to_expose_on_stable : bool ,
@@ -82,6 +85,7 @@ impl<'tcx> NonConstOp<'tcx> for ConditionallyConstCall<'tcx> {
82
85
// We use the `const_trait_impl` gate for all conditionally-const calls.
83
86
Status :: Unstable {
84
87
gate : sym:: const_trait_impl,
88
+ gate_already_checked : false ,
85
89
safe_to_expose_on_stable : false ,
86
90
// We don't want the "mark the callee as `#[rustc_const_stable_indirect]`" hint
87
91
is_function_call : false ,
@@ -330,19 +334,24 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
330
334
pub ( crate ) struct FnCallUnstable {
331
335
pub def_id : DefId ,
332
336
pub 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 ,
333
340
pub safe_to_expose_on_stable : bool ,
334
341
}
335
342
336
343
impl < ' tcx > NonConstOp < ' tcx > for FnCallUnstable {
337
344
fn status_in_item ( & self , _ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
338
345
Status :: Unstable {
339
346
gate : self . feature ,
347
+ gate_already_checked : self . feature_enabled ,
340
348
safe_to_expose_on_stable : self . safe_to_expose_on_stable ,
341
349
is_function_call : true ,
342
350
}
343
351
}
344
352
345
353
fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
354
+ assert ! ( !self . feature_enabled) ;
346
355
let mut err = ccx. dcx ( ) . create_err ( errors:: UnstableConstFn {
347
356
span,
348
357
def_path : ccx. tcx . def_path_str ( self . def_id ) ,
@@ -376,14 +385,15 @@ impl<'tcx> NonConstOp<'tcx> for IntrinsicNonConst {
376
385
pub ( crate ) struct IntrinsicUnstable {
377
386
pub name : Symbol ,
378
387
pub feature : Symbol ,
379
- pub const_stable : bool ,
388
+ pub const_stable_indirect : bool ,
380
389
}
381
390
382
391
impl < ' tcx > NonConstOp < ' tcx > for IntrinsicUnstable {
383
392
fn status_in_item ( & self , _ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
384
393
Status :: Unstable {
385
394
gate : 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 ,
387
397
// We do *not* want to suggest to mark the intrinsic as `const_stable_indirect`,
388
398
// that's not a trivial change!
389
399
is_function_call : false ,
@@ -410,6 +420,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
410
420
{
411
421
Status :: Unstable {
412
422
gate : sym:: const_async_blocks,
423
+ gate_already_checked : false ,
413
424
safe_to_expose_on_stable : false ,
414
425
is_function_call : false ,
415
426
}
0 commit comments