Skip to content

Commit 114947e

Browse files
committed
Explicitly use std panic over core panic
1 parent 9eaeba8 commit 114947e

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

library/std/src/prelude/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ pub mod rust_2021 {
145145
#[stable(feature = "prelude_2021", since = "1.55.0")]
146146
#[doc(no_inline)]
147147
pub use core::prelude::rust_2021::*;
148+
149+
// There are two different panic macros, one in `core` and one in `std`. They are slightly
150+
// different. For `std` we explicitly want the one defined in `std`.
151+
#[stable(feature = "prelude_2021", since = "1.55.0")]
152+
pub use super::v1::panic;
148153
}
149154

150155
/// The 2024 version of the prelude of The Rust Standard Library.
@@ -159,6 +164,11 @@ pub mod rust_2024 {
159164
#[stable(feature = "prelude_2024", since = "1.85.0")]
160165
#[doc(no_inline)]
161166
pub use core::prelude::rust_2024::*;
167+
168+
// There are two different panic macros, one in `core` and one in `std`. They are slightly
169+
// different. For `std` we explicitly want the one defined in `std`.
170+
#[stable(feature = "prelude_2024", since = "1.85.0")]
171+
pub use super::v1::panic;
162172
}
163173

164174
/// The Future version of the prelude of The Rust Standard Library.
@@ -174,4 +184,9 @@ pub mod rust_future {
174184
#[unstable(feature = "prelude_next", issue = "none")]
175185
#[doc(no_inline)]
176186
pub use core::prelude::rust_future::*;
187+
188+
// There are two different panic macros, one in `core` and one in `std`. They are slightly
189+
// different. For `std` we explicitly want the one defined in `std`.
190+
#[unstable(feature = "prelude_next", issue = "none")]
191+
pub use super::v1::panic;
177192
}

library/std/src/prelude/v1.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,28 @@ pub use crate::result::Result::{self, Err, Ok};
4949
#[doc(no_inline)]
5050
pub use core::prelude::v1::{
5151
assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches,
52-
module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write,
52+
module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write,
5353
writeln, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd,
5454
};
5555

5656
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
5757
#[doc(no_inline)]
5858
pub use crate::{
59-
dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local,
59+
dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local
6060
};
6161

6262
// These macros needs special handling, so that we don't export it *and* the modules of the same
6363
// name. We only want the macro in the prelude.
6464
mod ambiguous_macro_only_std {
6565
#[allow(hidden_glob_reexports)]
6666
mod vec {}
67+
#[allow(hidden_glob_reexports)]
68+
mod panic {}
6769
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6870
pub use crate::*;
6971
}
7072
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
71-
pub use self::ambiguous_macro_only_std::vec;
73+
pub use self::ambiguous_macro_only_std::{vec, panic};
7274

7375
#[unstable(feature = "cfg_match", issue = "115585")]
7476
#[doc(no_inline)]

0 commit comments

Comments
 (0)