Fix const stability
This commit is contained in:
parent
6770dbd4b5
commit
26b78ccd31
4 changed files with 37 additions and 2 deletions
|
@ -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() {
|
||||
|
|
|
@ -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,
|
||||
|
|
20
src/test/ui/intrinsics/const-eval-select-stability.rs
Normal file
20
src/test/ui/intrinsics/const-eval-select-stability.rs
Normal 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() {}
|
10
src/test/ui/intrinsics/const-eval-select-stability.stderr
Normal file
10
src/test/ui/intrinsics/const-eval-select-stability.stderr
Normal 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
|
||||
|
Loading…
Add table
Reference in a new issue