`#![no_implicit_prelude]` does not disable macros
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
// edition 2018, 2021, or 2024
#![no_implicit_prelude]
fn main() {
assert!(true);
}
I expected to see this happen: Compilation error, according to the language reference:
The
no_implicit_preludeattribute may be applied at the crate level or on a module to indicate that it should not automatically bring the standard library prelude, extern prelude, or tool prelude into scope for that module or any of its descendants.This attribute does not affect the language prelude.
Edition differences: In the 2015 edition, the
no_implicit_preludeattribute does not affect themacro_useprelude, and all macros exported from the standard library are still included in themacro_useprelude. Starting in the 2018 edition, it will remove themacro_useprelude.
In particular, both the macro_use prelude and the standard library prelude should not be in scope, and assert! is not a member of the language prelude, so assert! should not be in scope.
Instead, this happened: The code compiles. The macro is still in scope.
Meta
Tested with stable 1.85.1 and nightly 1.87.0-nightly (2025-03-19 1aeb99d248e1b0069110).
I do not know whether this ever worked.
Prompted by a discussion in the Rust Community Discord server.
@rustbot label +A-macros
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the minimal Rust example in the issue and compare its behavior with the quoted no_implicit_prelude language-reference rules across the 2018, 2021, and 2024 editions. Done means the assert! macro is not in scope under the documented editions, with regression coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100