You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> When one of [std::panic!] or [core::panic!] is brought into scope due to the [standard library prelude], `rustc` currently accepts the other being resolved through a user-written [glob import]; that glob import takes precedence.
235
+
>
236
+
> In later editions, [core::panic!] and [std::panic!] operate identically, but we can tell the difference between them in Rust 2018 and earlier where only in [std::panic!] is a [String] accepted as the format argument.
237
+
>
238
+
> E.g., due to that, this is an error:
239
+
>
240
+
> ```rust,edition2018,compile_fail,E0308
241
+
> extern crate core;
242
+
> use ::core::prelude::v1::*;
243
+
> fn main() {
244
+
> panic!(std::string::String::new()); // ERROR
245
+
> }
246
+
> ```
247
+
>
248
+
> And this is accepted:
249
+
>
250
+
> <!-- ignore: Can't test with `no_std`. -->
251
+
> ```rust,edition2018,ignore
252
+
> #![no_std]
253
+
> extern crate std;
254
+
> use ::std::prelude::v1::*;
255
+
> fn main() {
256
+
> panic!(std::string::String::new()); // ERROR
257
+
> }
258
+
> ```
259
+
>
260
+
> Don't rely on this behavior; the plan is to remove it.
261
+
>
262
+
> For details, see [Rust issue #147319](https://github.com/rust-lang/rust/issues/147319).
> [`core::prelude::rust_2015`] and [`core::prelude::rust_2018`] have the same contents as [`core::prelude::v1`].
42
42
43
+
> [!NOTE]
44
+
> When one of [std::panic!] or [core::panic!] is brought into scope due to the [standard library prelude], `rustc` currently accepts the other being resolved through a user-written [glob import]; that glob import takes precedence.
45
+
>
46
+
> For details, see [names.resolution.expansion.imports.ambiguity.panic-hack].
0 commit comments