Do not apply #[macro_use]
to implicitly injected extern crate std;
, use standard library prelude instead
#53977
Labels
A-resolve
Area: Name/path resolution done by `rustc_resolve` specifically
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Macros like
vec
orprintln
are currently automatically available to user code through injected standard library#[macro_use]
puts all the macro names into macro prelude, so they are available in inner modules without additional imports.It would be good to avoid this, especially given that
#[macro_use]
is going to be gradually deprecated.We have analogous way to put things into prelude for non-macro namespaces - standard library prelude
std::prelude::v1
, all stable library macros can be reexported through it instead of#[macro_use]
in backward-compatible way.Undesirable unstable macros like
select
can be removed from prelude in the process.The only issue is that several imports for several macros (
env
,vec
,panic
) would also import corresponding modules from the standard library (std::env
,std::vec
,std::panic
) and put them into prelude. This is certainly not desirable.The solution is to come up with some way for a
use
item to import the name only in the single selected namespace, something likeAlternatively, this can be done with hacks for cross-crate scenarios (stdlib prelude is indeed a cross-crate scenario).
(All of this is applicable to libcore as well.)
The text was updated successfully, but these errors were encountered: