Skip to content

Commit 9eaeba8

Browse files
committed
Exclude panic and env namespaces from prelude
1 parent 25f46fb commit 9eaeba8

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

library/core/src/prelude/v1.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,22 @@ pub use crate::hash::macros::Hash;
6161
#[allow(deprecated)]
6262
#[doc(no_inline)]
6363
pub use crate::{
64-
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, module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write, writeln,
64+
assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write, writeln,
6565
};
6666

67+
// These macros needs special handling, so that we don't export it *and* the modules of the same
68+
// name. We only want the macro in the prelude.
69+
mod ambiguous_macro_only {
70+
#[allow(hidden_glob_reexports)]
71+
mod env {}
72+
#[allow(hidden_glob_reexports)]
73+
mod panic {}
74+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
75+
pub use crate::*;
76+
}
77+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
78+
pub use self::ambiguous_macro_only::{env, panic};
79+
6780
#[unstable(feature = "cfg_match", issue = "115585")]
6881
#[doc(no_inline)]
6982
pub use crate::cfg_match;

library/std/src/prelude/v1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ pub use crate::{
5959
dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local,
6060
};
6161

62-
// The `vec` macro needs special handling, so that we don't export it *and* the `std::vec` module at
63-
// the same time. We only want the macro in the prelude.
64-
mod vec_macro_only {
62+
// These macros needs special handling, so that we don't export it *and* the modules of the same
63+
// name. We only want the macro in the prelude.
64+
mod ambiguous_macro_only_std {
6565
#[allow(hidden_glob_reexports)]
6666
mod vec {}
6767
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6868
pub use crate::*;
6969
}
7070
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
71-
pub use self::vec_macro_only::vec;
71+
pub use self::ambiguous_macro_only_std::vec;
7272

7373
#[unstable(feature = "cfg_match", issue = "115585")]
7474
#[doc(no_inline)]

0 commit comments

Comments
 (0)