mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 21:42:44 +00:00
Use panic() instead of panic!() in some places in core.
This commit is contained in:
parent
87e8639d8d
commit
ad6ef48dd9
@ -141,6 +141,7 @@
|
|||||||
#![feature(const_type_id)]
|
#![feature(const_type_id)]
|
||||||
#![feature(const_type_name)]
|
#![feature(const_type_name)]
|
||||||
#![feature(const_default_impls)]
|
#![feature(const_default_impls)]
|
||||||
|
#![feature(core_panic)]
|
||||||
#![feature(duration_consts_float)]
|
#![feature(duration_consts_float)]
|
||||||
#![feature(maybe_uninit_uninit_array)]
|
#![feature(maybe_uninit_uninit_array)]
|
||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
|
@ -589,9 +589,10 @@ macro_rules! writeln {
|
|||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow_internal_unstable(core_panic)]
|
||||||
macro_rules! unreachable {
|
macro_rules! unreachable {
|
||||||
() => ({
|
() => ({
|
||||||
$crate::panic!("internal error: entered unreachable code")
|
$crate::panicking::panic("internal error: entered unreachable code")
|
||||||
});
|
});
|
||||||
($msg:expr $(,)?) => ({
|
($msg:expr $(,)?) => ({
|
||||||
$crate::unreachable!("{}", $msg)
|
$crate::unreachable!("{}", $msg)
|
||||||
@ -674,8 +675,9 @@ macro_rules! unreachable {
|
|||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow_internal_unstable(core_panic)]
|
||||||
macro_rules! unimplemented {
|
macro_rules! unimplemented {
|
||||||
() => ($crate::panic!("not implemented"));
|
() => ($crate::panicking::panic("not implemented"));
|
||||||
($($arg:tt)+) => ($crate::panic!("not implemented: {}", $crate::format_args!($($arg)+)));
|
($($arg:tt)+) => ($crate::panic!("not implemented: {}", $crate::format_args!($($arg)+)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,8 +737,9 @@ macro_rules! unimplemented {
|
|||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "todo_macro", since = "1.40.0")]
|
#[stable(feature = "todo_macro", since = "1.40.0")]
|
||||||
|
#[allow_internal_unstable(core_panic)]
|
||||||
macro_rules! todo {
|
macro_rules! todo {
|
||||||
() => ($crate::panic!("not yet implemented"));
|
() => ($crate::panicking::panic("not yet implemented"));
|
||||||
($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+)));
|
($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,6 +501,7 @@
|
|||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use crate::iter::{FromIterator, FusedIterator, TrustedLen};
|
use crate::iter::{FromIterator, FusedIterator, TrustedLen};
|
||||||
|
use crate::panicking::{panic, panic_str};
|
||||||
use crate::pin::Pin;
|
use crate::pin::Pin;
|
||||||
use crate::{
|
use crate::{
|
||||||
convert, hint, mem,
|
convert, hint, mem,
|
||||||
@ -755,7 +756,7 @@ impl<T> Option<T> {
|
|||||||
pub const fn unwrap(self) -> T {
|
pub const fn unwrap(self) -> T {
|
||||||
match self {
|
match self {
|
||||||
Some(val) => val,
|
Some(val) => val,
|
||||||
None => panic!("called `Option::unwrap()` on a `None` value"),
|
None => panic("called `Option::unwrap()` on a `None` value"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1815,8 +1816,9 @@ impl<T, E> Option<Result<T, E>> {
|
|||||||
#[cfg_attr(feature = "panic_immediate_abort", inline)]
|
#[cfg_attr(feature = "panic_immediate_abort", inline)]
|
||||||
#[cold]
|
#[cold]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
|
||||||
const fn expect_failed(msg: &str) -> ! {
|
const fn expect_failed(msg: &str) -> ! {
|
||||||
panic!("{}", msg)
|
panic_str(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
let mut _19: *const T; // in scope 0 at $DIR/issue_76432.rs:9:54: 9:68
|
let mut _19: *const T; // in scope 0 at $DIR/issue_76432.rs:9:54: 9:68
|
||||||
let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
|
let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
|
||||||
let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
|
let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
|
||||||
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
|
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
||||||
let mut _23: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
|
let mut _23: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
|
||||||
scope 1 {
|
scope 1 {
|
||||||
debug v => _2; // in scope 1 at $DIR/issue_76432.rs:7:9: 7:10
|
debug v => _2; // in scope 1 at $DIR/issue_76432.rs:7:9: 7:10
|
||||||
@ -66,10 +66,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
bb1: {
|
bb1: {
|
||||||
StorageLive(_22); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
|
StorageLive(_22); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
||||||
core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
|
core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
||||||
// mir::Constant
|
// mir::Constant
|
||||||
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
|
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
||||||
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
|
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
|
||||||
// ty::Const
|
// ty::Const
|
||||||
// + ty: &str
|
// + ty: &str
|
||||||
|
@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const Y: () = std::unreachable!();
|
LL | const Y: () = std::unreachable!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
|
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
|
||||||
|
|
|
|
||||||
= 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 `std::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic.rs:15:15
|
--> $DIR/const_panic.rs:15:15
|
||||||
@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const X: () = std::unimplemented!();
|
LL | const X: () = std::unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15
|
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15
|
||||||
|
|
|
|
||||||
= 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 `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic.rs:18:15
|
--> $DIR/const_panic.rs:18:15
|
||||||
@ -68,7 +68,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
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:30:20
|
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:30:20
|
||||||
|
|
|
|
||||||
= 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 `core::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic.rs:33:20
|
--> $DIR/const_panic.rs:33:20
|
||||||
@ -76,7 +76,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const X_CORE: () = core::unimplemented!();
|
LL | const X_CORE: () = core::unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:33:20
|
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:33:20
|
||||||
|
|
|
|
||||||
= 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 `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic.rs:36:20
|
--> $DIR/const_panic.rs:36:20
|
||||||
|
@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const C: () = std::unreachable!();
|
LL | const C: () = std::unreachable!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:12:15
|
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:12:15
|
||||||
|
|
|
|
||||||
= 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 `std::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic_2021.rs:15:15
|
--> $DIR/const_panic_2021.rs:15:15
|
||||||
@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const D: () = std::unimplemented!();
|
LL | const D: () = std::unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:15:15
|
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:15:15
|
||||||
|
|
|
|
||||||
= 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 `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic_2021.rs:18:15
|
--> $DIR/const_panic_2021.rs:18:15
|
||||||
@ -60,7 +60,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const C_CORE: () = core::unreachable!();
|
LL | const C_CORE: () = core::unreachable!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:27:20
|
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:27:20
|
||||||
|
|
|
|
||||||
= 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 `core::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic_2021.rs:30:20
|
--> $DIR/const_panic_2021.rs:30:20
|
||||||
@ -68,7 +68,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const D_CORE: () = core::unimplemented!();
|
LL | const D_CORE: () = core::unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:30:20
|
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:30:20
|
||||||
|
|
|
|
||||||
= 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 `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic_2021.rs:33:20
|
--> $DIR/const_panic_2021.rs:33:20
|
||||||
|
@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const Y: () = unreachable!();
|
LL | const Y: () = unreachable!();
|
||||||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:11:15
|
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:11:15
|
||||||
|
|
|
|
||||||
= 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 `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_panic_libcore_bin.rs:14:15
|
--> $DIR/const_panic_libcore_bin.rs:14:15
|
||||||
@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | const X: () = unimplemented!();
|
LL | const X: () = unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:14:15
|
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:14:15
|
||||||
|
|
|
|
||||||
= 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 `unimplemented` (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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user