1
Fork 0

Emit a hard error when a panic occurs during const-eval

Previous, a panic during const evaluation would go through the
`const_err` lint. This PR ensures that such a panic always causes
compilation to fail.
This commit is contained in:
Aaron Hill 2021-05-25 20:54:59 -05:00
parent 2023cc3aa1
commit 2779fc1c47
No known key found for this signature in database
GPG key ID: B4087E510E98B164
15 changed files with 118 additions and 182 deletions

View file

@ -435,8 +435,12 @@ impl<T: Any> AsAny for T {
} }
/// A trait for machine-specific errors (or other "machine stop" conditions). /// A trait for machine-specific errors (or other "machine stop" conditions).
pub trait MachineStopType: AsAny + fmt::Display + Send {} pub trait MachineStopType: AsAny + fmt::Display + Send {
impl MachineStopType for String {} /// If `true`, emit a hard error instead of going through the `CONST_ERR` lint
fn is_hard_err(&self) -> bool {
false
}
}
impl dyn MachineStopType { impl dyn MachineStopType {
#[inline(always)] #[inline(always)]

View file

@ -9,7 +9,7 @@ use rustc_span::{Span, Symbol};
use super::InterpCx; use super::InterpCx;
use crate::interpret::{ use crate::interpret::{
struct_error, ErrorHandled, FrameInfo, InterpError, InterpErrorInfo, Machine, struct_error, ErrorHandled, FrameInfo, InterpError, InterpErrorInfo, Machine, MachineStopType,
}; };
/// The CTFE machine has some custom error kinds. /// The CTFE machine has some custom error kinds.
@ -24,12 +24,21 @@ pub enum ConstEvalErrKind {
Abort(String), Abort(String),
} }
impl MachineStopType for ConstEvalErrKind {
fn is_hard_err(&self) -> bool {
match self {
Self::Panic { .. } => true,
_ => false,
}
}
}
// The errors become `MachineStop` with plain strings when being raised. // The errors become `MachineStop` with plain strings when being raised.
// `ConstEvalErr` (in `librustc_middle/mir/interpret/error.rs`) knows to // `ConstEvalErr` (in `librustc_middle/mir/interpret/error.rs`) knows to
// handle these. // handle these.
impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind { impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
fn into(self) -> InterpErrorInfo<'tcx> { fn into(self) -> InterpErrorInfo<'tcx> {
err_machine_stop!(self.to_string()).into() err_machine_stop!(self).into()
} }
} }
@ -148,31 +157,10 @@ impl<'tcx> ConstEvalErr<'tcx> {
tcx: TyCtxtAt<'tcx>, tcx: TyCtxtAt<'tcx>,
message: &str, message: &str,
emit: impl FnOnce(DiagnosticBuilder<'_>), emit: impl FnOnce(DiagnosticBuilder<'_>),
lint_root: Option<hir::HirId>, mut lint_root: Option<hir::HirId>,
) -> ErrorHandled { ) -> ErrorHandled {
let must_error = match self.error {
err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
return ErrorHandled::TooGeneric;
}
err_inval!(AlreadyReported(error_reported)) => {
return ErrorHandled::Reported(error_reported);
}
// We must *always* hard error on these, even if the caller wants just a lint.
err_inval!(Layout(LayoutError::SizeOverflow(_))) => true,
_ => false,
};
trace!("reporting const eval failure at {:?}", self.span);
let err_msg = match &self.error {
InterpError::MachineStop(msg) => {
// A custom error (`ConstEvalErrKind` in `librustc_mir/interp/const_eval/error.rs`).
// Should be turned into a string by now.
msg.downcast_ref::<String>().expect("invalid MachineStop payload").clone()
}
err => err.to_string(),
};
let finish = |mut err: DiagnosticBuilder<'_>, span_msg: Option<String>| { let finish = |mut err: DiagnosticBuilder<'_>, span_msg: Option<String>| {
trace!("reporting const eval failure at {:?}", self.span);
if let Some(span_msg) = span_msg { if let Some(span_msg) = span_msg {
err.span_label(self.span, span_msg); err.span_label(self.span, span_msg);
} }
@ -186,34 +174,50 @@ impl<'tcx> ConstEvalErr<'tcx> {
emit(err) emit(err)
}; };
if must_error { // Special handling for certain errors
// The `message` makes little sense here, this is a more serious error than the match &self.error {
// caller thinks anyway. // Don't emit a new diagnostic for these errors
// See <https://github.com/rust-lang/rust/pull/63152>. err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
finish(struct_error(tcx, &err_msg), None); return ErrorHandled::TooGeneric;
ErrorHandled::Reported(ErrorReported)
} else {
// Regular case.
if let Some(lint_root) = lint_root {
// Report as lint.
let hir_id = self
.stacktrace
.iter()
.rev()
.find_map(|frame| frame.lint_root)
.unwrap_or(lint_root);
tcx.struct_span_lint_hir(
rustc_session::lint::builtin::CONST_ERR,
hir_id,
tcx.span,
|lint| finish(lint.build(message), Some(err_msg)),
);
ErrorHandled::Linted
} else {
// Report as hard error.
finish(struct_error(tcx, message), Some(err_msg));
ErrorHandled::Reported(ErrorReported)
} }
err_inval!(AlreadyReported(error_reported)) => {
return ErrorHandled::Reported(*error_reported);
}
err_inval!(Layout(LayoutError::SizeOverflow(_))) => {
// We must *always* hard error on these, even if the caller wants just a lint.
// The `message` makes little sense here, this is a more serious error than the
// caller thinks anyway.
// See <https://github.com/rust-lang/rust/pull/63152>.
finish(struct_error(tcx, &self.error.to_string()), None);
return ErrorHandled::Reported(ErrorReported);
}
_ => {}
};
// If we have a 'hard error', then set `lint_root` to `None` so that we don't
// emit a lint.
if matches!(&self.error, InterpError::MachineStop(err) if err.is_hard_err()) {
lint_root = None;
}
let err_msg = self.error.to_string();
// Regular case - emit a lint.
if let Some(lint_root) = lint_root {
// Report as lint.
let hir_id =
self.stacktrace.iter().rev().find_map(|frame| frame.lint_root).unwrap_or(lint_root);
tcx.struct_span_lint_hir(
rustc_session::lint::builtin::CONST_ERR,
hir_id,
tcx.span,
|lint| finish(lint.build(message), Some(err_msg)),
);
ErrorHandled::Linted
} else {
// Report as hard error.
finish(struct_error(tcx, message), Some(err_msg));
ErrorHandled::Reported(ErrorReported)
} }
} }
} }

View file

@ -6,40 +6,30 @@ const MSG: &str = "hello";
const Z: () = std::panic!("cheese"); const Z: () = std::panic!("cheese");
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const Z2: () = std::panic!(); const Z2: () = std::panic!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const Y: () = std::unreachable!(); const Y: () = std::unreachable!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const X: () = std::unimplemented!(); const X: () = std::unimplemented!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
// //
const W: () = std::panic!(MSG); const W: () = std::panic!(MSG);
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const Z_CORE: () = core::panic!("cheese"); const Z_CORE: () = core::panic!("cheese");
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const Z2_CORE: () = core::panic!(); const Z2_CORE: () = core::panic!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const Y_CORE: () = core::unreachable!(); const Y_CORE: () = core::unreachable!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const X_CORE: () = core::unimplemented!(); const X_CORE: () = core::unimplemented!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const W_CORE: () = core::panic!(MSG); const W_CORE: () = core::panic!(MSG);
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:7:15 --> $DIR/const_panic.rs:7:15
| |
LL | const Z: () = std::panic!("cheese"); LL | const Z: () = std::panic!("cheese");
@ -6,118 +6,98 @@ LL | const Z: () = std::panic!("cheese");
| | | |
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15 | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:11:16 --> $DIR/const_panic.rs:10:16
| |
LL | const Z2: () = std::panic!(); LL | const Z2: () = std::panic!();
| ---------------^^^^^^^^^^^^^- | ---------------^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:11:16 | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:15:15 --> $DIR/const_panic.rs:13:15
| |
LL | const Y: () = std::unreachable!(); LL | const Y: () = std::unreachable!();
| --------------^^^^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:15:15 | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:19:15 --> $DIR/const_panic.rs:16:15
| |
LL | const X: () = std::unimplemented!(); LL | const X: () = std::unimplemented!();
| --------------^^^^^^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:19:15 | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:23:15 --> $DIR/const_panic.rs:19:15
| |
LL | const W: () = std::panic!(MSG); LL | const W: () = std::panic!(MSG);
| --------------^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:23:15 | the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:27:20 --> $DIR/const_panic.rs:22:20
| |
LL | const Z_CORE: () = core::panic!("cheese"); LL | const Z_CORE: () = core::panic!("cheese");
| -------------------^^^^^^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:27:20 | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:31:21 --> $DIR/const_panic.rs:25:21
| |
LL | const Z2_CORE: () = core::panic!(); LL | const Z2_CORE: () = core::panic!();
| --------------------^^^^^^^^^^^^^^- | --------------------^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:31:21 | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:35:20 --> $DIR/const_panic.rs:28:20
| |
LL | const Y_CORE: () = core::unreachable!(); LL | const Y_CORE: () = core::unreachable!();
| -------------------^^^^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:35:20 | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:39:20 --> $DIR/const_panic.rs:31:20
| |
LL | const X_CORE: () = core::unimplemented!(); LL | const X_CORE: () = core::unimplemented!();
| -------------------^^^^^^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:39:20 | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic.rs:43:20 --> $DIR/const_panic.rs:34:20
| |
LL | const W_CORE: () = core::panic!(MSG); LL | const W_CORE: () = core::panic!(MSG);
| -------------------^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:43:20 | the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 10 previous errors error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -8,15 +8,12 @@ use core::panic::PanicInfo;
const Z: () = panic!("cheese"); const Z: () = panic!("cheese");
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const Y: () = unreachable!(); const Y: () = unreachable!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
const X: () = unimplemented!(); const X: () = unimplemented!();
//~^ ERROR any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
#[lang = "eh_personality"] #[lang = "eh_personality"]
fn eh() {} fn eh() {}

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic_libcore_bin.rs:9:15 --> $DIR/const_panic_libcore_bin.rs:9:15
| |
LL | const Z: () = panic!("cheese"); LL | const Z: () = panic!("cheese");
@ -6,34 +6,28 @@ LL | const Z: () = panic!("cheese");
| | | |
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15 | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic_libcore_bin.rs:13:15 --> $DIR/const_panic_libcore_bin.rs:12:15
| |
LL | const Y: () = unreachable!(); LL | const Y: () = unreachable!();
| --------------^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:13:15 | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/const_panic_libcore_bin.rs:17:15 --> $DIR/const_panic_libcore_bin.rs:15:15
| |
LL | const X: () = unimplemented!(); LL | const X: () = unimplemented!();
| --------------^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:17:15 | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -9,8 +9,7 @@ struct PrintName;
impl PrintName { impl PrintName {
const VOID: ! = panic!(); const VOID: ! = panic!();
//~^ WARN any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
} }
fn main() { fn main() {

View file

@ -1,4 +1,4 @@
warning: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/panic-assoc-never-type.rs:11:21 --> $DIR/panic-assoc-never-type.rs:11:21
| |
LL | const VOID: ! = panic!(); LL | const VOID: ! = panic!();
@ -6,21 +6,14 @@ LL | const VOID: ! = panic!();
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:11:21 | the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:11:21
| |
note: the lint level is defined here = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
--> $DIR/panic-assoc-never-type.rs:4:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: erroneous constant used error[E0080]: erroneous constant used
--> $DIR/panic-assoc-never-type.rs:17:13 --> $DIR/panic-assoc-never-type.rs:16:13
| |
LL | let _ = PrintName::VOID; LL | let _ = PrintName::VOID;
| ^^^^^^^^^^^^^^^ referenced constant has errors | ^^^^^^^^^^^^^^^ referenced constant has errors
error: aborting due to previous error; 1 warning emitted error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0080`.

View file

@ -1,15 +1,11 @@
// build-fail
// Regression test for #66975 // Regression test for #66975
#![warn(const_err)] #![warn(const_err)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(never_type)] #![feature(never_type)]
const VOID: ! = panic!(); const VOID: ! = panic!();
//~^ WARN any use of this value will cause an error //~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
fn main() { fn main() {
let _ = VOID; let _ = VOID;
//~^ ERROR erroneous constant used
} }

View file

@ -1,26 +1,13 @@
warning: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/panic-never-type.rs:8:17 --> $DIR/panic-never-type.rs:6:17
| |
LL | const VOID: ! = panic!(); LL | const VOID: ! = panic!();
| ----------------^^^^^^^^- | ----------------^^^^^^^^-
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:8:17 | the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:6:17
| |
note: the lint level is defined here = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
--> $DIR/panic-never-type.rs:4:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: erroneous constant used error: aborting due to previous error
--> $DIR/panic-never-type.rs:13:13
|
LL | let _ = VOID;
| ^^^^ referenced constant has errors
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0080`.

View file

@ -2,8 +2,7 @@
#[unwind(aborts)] #[unwind(aborts)]
const fn foo() { const fn foo() {
panic!() //~ ERROR any use of this value will cause an error [const_err] panic!() //~ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
} }
const _: () = foo(); const _: () = foo();

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/unwind-abort.rs:5:5 --> $DIR/unwind-abort.rs:5:5
| |
LL | panic!() LL | panic!()
@ -6,15 +6,13 @@ LL | panic!()
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5 | the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5
| inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL | inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL
| inside `_` at $DIR/unwind-abort.rs:9:15 | inside `_` at $DIR/unwind-abort.rs:8:15
... ...
LL | const _: () = foo(); LL | const _: () = foo();
| -------------------- | --------------------
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $SRC_DIR/core/src/option.rs:LL:COL --> $SRC_DIR/core/src/option.rs:LL:COL
| |
LL | None => panic!("called `Option::unwrap()` on a `None` value"), LL | None => panic!("called `Option::unwrap()` on a `None` value"),
@ -13,10 +13,8 @@ LL | None => panic!("called `Option::unwrap()` on a `None` value"),
LL | const BAR: i32 = Option::<i32>::None.unwrap(); LL | const BAR: i32 = Option::<i32>::None.unwrap();
| ---------------------------------------------- | ----------------------------------------------
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -1,4 +1,4 @@
error: any use of this value will cause an error error[E0080]: any use of this value will cause an error
--> $DIR/assert.rs:10:15 --> $DIR/assert.rs:10:15
| |
LL | const _: () = assert!(false); LL | const _: () = assert!(false);
@ -6,10 +6,8 @@ LL | const _: () = assert!(false);
| | | |
| the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15 | the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15
| |
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.

View file

@ -10,6 +10,5 @@ const _: () = assert!(true);
const _: () = assert!(false); const _: () = assert!(false);
//[stock]~^ ERROR panicking in constants is unstable //[stock]~^ ERROR panicking in constants is unstable
//[const_panic]~^^ ERROR any use of this value will cause an error //[const_panic]~^^ ERROR any use of this value will cause an error
//[const_panic]~| WARN this was previously accepted by the compiler but is being phased out
fn main() {} fn main() {}