std predule macros should be available in std::prelude
#91
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
The
core
prelude containsuse
reexports for mostcore
#[macro_use]
d macros (e.g.include!
,env!
,file!
,line!
). Thestd prelude
reexports thecore
prelude macros but does not provideuse
reexports for the std prelude macros (e.g.prinln!
,vec!
).Motivation, use-cases
The primary motivation is consistency.
#[macro_use] extern crate
is discouraged in favor of using named imports for macros; std should name all of the prelude names in the prelude import, rather than relying on#[macro_use]
.A primary use-case is conditionally-std crates. There's currently two main ways to spell conditional-std-ness:
It would be ideal if case 2b can be folded into 2a, where an explicit
use std::prelude::edition::*
can be added to#[cfg(feature = "std")]
modules to get access to the full std prelude.Solution sketches
Add reexports for the macros not currently available through the prelude into the prelude. This includes macros in core, alloc, and std that are imported by
#[macro_use]
but not yet available in the respective preludes.In the future (a lang change, not a libs change), consider removing the use of
#[macro_use]
for the injectedextern crate std;
and rely on the prelude import instead. This should not change any observable behavior, as the prelude import is injected into every module already. However, this is NOT part of this ACP.Links and related work
(none)
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: