Skip to content

Commit 33fc161

Browse files
committed
Exclude panic and env namespaces from prelude
1 parent 71bc72f commit 33fc161

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
@@ -60,9 +60,22 @@ pub use crate::hash::macros::Hash;
6060
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6161
#[doc(no_inline)]
6262
pub use crate::{
63-
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,
63+
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,
6464
};
6565

66+
// These macros needs special handling, so that we don't export it *and* the modules of the same
67+
// name. We only want the macro in the prelude.
68+
mod ambiguous_macro_only {
69+
#[allow(hidden_glob_reexports)]
70+
mod env {}
71+
#[allow(hidden_glob_reexports)]
72+
mod panic {}
73+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
74+
pub use crate::*;
75+
}
76+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
77+
pub use self::ambiguous_macro_only::{env, panic};
78+
6679
#[unstable(feature = "cfg_match", issue = "115585")]
6780
#[doc(no_inline)]
6881
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
@@ -58,16 +58,16 @@ pub use crate::{
5858
dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local,
5959
};
6060

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

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

0 commit comments

Comments
 (0)