Fix const stability

This commit is contained in:
Deadbeef 2021-10-14 06:53:20 +00:00
parent 6770dbd4b5
commit 26b78ccd31
No known key found for this signature in database
GPG key ID: 027DF9338862ADDD
4 changed files with 37 additions and 2 deletions

View file

@ -24,7 +24,7 @@ use std::ops::Deref;
use super::ops::{self, NonConstOp, Status};
use super::qualifs::{self, CustomEq, HasMutInterior, NeedsNonConstDrop};
use super::resolver::FlowSensitiveAnalysis;
use super::{is_lang_special_const_fn, ConstCx, Qualif};
use super::{is_lang_panic_fn, is_lang_special_const_fn, ConstCx, Qualif};
use crate::const_eval::is_unstable_const_fn;
// We are using `MaybeMutBorrowedLocals` as a proxy for whether an item may have been mutated
@ -910,7 +910,10 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
}
}
return;
if is_lang_panic_fn(tcx, callee) {
// run stability check on non-panic special const fns.
return;
}
}
if Some(callee) == tcx.lang_items().exchange_malloc_fn() {

View file

@ -2258,6 +2258,7 @@ pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
issue = "none",
reason = "const_eval_select will never be stable"
)]
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
#[lang = "const_eval_select"]
#[rustc_do_not_const_check]
pub const unsafe fn const_eval_select<ARG, F, G, RET>(
@ -2278,6 +2279,7 @@ where
issue = "none",
reason = "const_eval_select will never be stable"
)]
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
#[lang = "const_eval_select_ct"]
pub const unsafe fn const_eval_select_ct<ARG, F, G, RET>(
arg: ARG,

View file

@ -0,0 +1,20 @@
#![feature(staged_api)]
#![feature(const_eval_select)]
#![stable(since = "1.0", feature = "ui_test")]
use std::intrinsics::const_eval_select;
fn log() {
println!("HEY HEY HEY")
}
const fn nothing(){}
#[stable(since = "1.0", feature = "hey")]
#[rustc_const_stable(since = "1.0", feature = "const_hey")]
pub const unsafe fn hey() {
const_eval_select((), nothing, log);
//~^ ERROR `const_eval_select` is not yet stable as a const fn
}
fn main() {}

View file

@ -0,0 +1,10 @@
error: `const_eval_select` is not yet stable as a const fn
--> $DIR/const-eval-select-stability.rs:16:5
|
LL | const_eval_select((), nothing, log);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: const-stable functions can only call other const-stable functions
error: aborting due to previous error