Skip to content

Commit f29c3c4

Browse files
committed
entirely get rid of NeedsRfc CTFE errors
1 parent a9f9145 commit f29c3c4

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::interpret::{
1515
/// The CTFE machine has some custom error kinds.
1616
#[derive(Clone, Debug)]
1717
pub enum ConstEvalErrKind {
18-
NeedsRfc(String),
1918
ConstAccessesStatic,
2019
ModifiedGlobal,
2120
AssertFailure(AssertKind<ConstInt>),
@@ -42,9 +41,6 @@ impl fmt::Display for ConstEvalErrKind {
4241
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4342
use self::ConstEvalErrKind::*;
4443
match *self {
45-
NeedsRfc(ref msg) => {
46-
write!(f, "\"{}\" needs an rfc before being allowed inside constants", msg)
47-
}
4844
ConstAccessesStatic => write!(f, "constant accesses static"),
4945
ModifiedGlobal => {
5046
write!(f, "modifying a static's initial value from another static's initializer")

compiler/rustc_const_eval/src/const_eval/machine.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
340340

341341
// CTFE-specific intrinsics.
342342
let Some(ret) = target else {
343-
return Err(ConstEvalErrKind::NeedsRfc(format!(
344-
"calling intrinsic `{}`",
345-
intrinsic_name
346-
))
347-
.into());
343+
throw_unsup_format!("intrinsic `{intrinsic_name}` is not supported at compile-time");
348344
};
349345
match intrinsic_name {
350346
sym::ptr_guaranteed_eq | sym::ptr_guaranteed_ne => {
@@ -401,11 +397,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
401397
}
402398
}
403399
_ => {
404-
return Err(ConstEvalErrKind::NeedsRfc(format!(
405-
"calling intrinsic `{}`",
406-
intrinsic_name
407-
))
408-
.into());
400+
throw_unsup_format!(
401+
"intrinsic `{intrinsic_name}` is not supported at compile-time"
402+
);
409403
}
410404
}
411405

@@ -448,7 +442,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
448442
_left: &ImmTy<'tcx>,
449443
_right: &ImmTy<'tcx>,
450444
) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)> {
451-
Err(ConstEvalErrKind::NeedsRfc("pointer arithmetic or comparison".to_string()).into())
445+
throw_unsup_format!("pointer arithmetic or comparison is not supported at compile-time");
452446
}
453447

454448
fn before_terminator(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {

src/test/ui/consts/miri_unleashed/ptr_arith.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ static PTR_INT_TRANSMUTE: () = unsafe {
1919
//~| unable to turn pointer into raw bytes
2020
};
2121

22+
// I'd love to test pointer comparison, but that is not possible since
23+
// their `PartialEq` impl is non-`const`.
24+
2225
fn main() {}

0 commit comments

Comments
 (0)