Skip to content

Document tool attributes being unaffected by the no_implicit_prelude attribute - #2404

Open
mejrs wants to merge 1 commit into
rust-lang:masterfrom
mejrs:tool_prelude
Open

mejrs wants to merge 1 commit into
rust-lang:masterfrom
mejrs:tool_prelude

Conversation

@mejrs

@mejrs mejrs commented Nov 2, 2026

Copy link
Copy Markdown
Member

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Nov 2, 2026
Comment thread src/names/preludes.md

r[names.preludes.no_implicit_prelude.intro]
The *`no_implicit_prelude` [attribute]* is used to prevent implicit preludes from being brought into scope.
The `no_implicit_prelude` attribute prevents the [standard library prelude], [extern prelude], and the [`macro_use` prelude] from being brought into scope for a crate or a module and its descendants.

@DanielEScherzer DanielEScherzer Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest leaving the .intro rule unchanged, and just moving the tool prelude mention from .excluded-preludes to the (now renamed) .unaffected

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it quite jarring to have basically the same information in two places with one being a watered down version of the other. It's still "intro length" so I thought it best to just say it once.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
…r, r=petrochenkov

Make `no_implicit_prelude` not suppress tool attributes

Implements part of the `register_tool` rfc, [RFC 3808](https://rust-lang.github.io/rfcs/3808-register-tool.html):
> Today, #![no_implicit_prelude] suppresses the tool attribute prelude but does not suppress the lint prelude (e.g., #[allow(clippy::foo)] continues to work). Under this RFC, neither prelude is suppressed by #![no_implicit_prelude]. This is technically a breaking change since it can produce new ambiguity errors in stable code.

(The breaking change is already taken care of in rust-lang#162597, the ambiguity error is raised regardless of whether the `no_implicit_prelude` attribute is used)

Currently, the following code errors. After this PR, it will start compiling.
```rust
#![no_implicit_prelude]
#![feature(register_tool)]
#![register_tool(my_tool)]

#[my_tool::attr] // ERROR cannot find module or crate `my_tool` in this scope
#[rustfmt::skip] // ERROR cannot find module or crate `rustfmt` in this scope
struct X;
```

Reference PR: rust-lang/reference#2404

r? petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
…r, r=petrochenkov

Make `no_implicit_prelude` not suppress tool attributes

Implements part of the `register_tool` rfc, [RFC 3808](https://rust-lang.github.io/rfcs/3808-register-tool.html):
> Today, #![no_implicit_prelude] suppresses the tool attribute prelude but does not suppress the lint prelude (e.g., #[allow(clippy::foo)] continues to work). Under this RFC, neither prelude is suppressed by #![no_implicit_prelude]. This is technically a breaking change since it can produce new ambiguity errors in stable code.

(The breaking change is already taken care of in rust-lang#162597, the ambiguity error is raised regardless of whether the `no_implicit_prelude` attribute is used)

Currently, the following code errors. After this PR, it will start compiling.
```rust
#![no_implicit_prelude]
#![feature(register_tool)]
#![register_tool(my_tool)]

#[my_tool::attr] // ERROR cannot find module or crate `my_tool` in this scope
#[rustfmt::skip] // ERROR cannot find module or crate `rustfmt` in this scope
struct X;
```

Reference PR: rust-lang/reference#2404

r? petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
…r, r=petrochenkov

Make `no_implicit_prelude` not suppress tool attributes

Implements part of the `register_tool` rfc, [RFC 3808](https://rust-lang.github.io/rfcs/3808-register-tool.html):
> Today, #![no_implicit_prelude] suppresses the tool attribute prelude but does not suppress the lint prelude (e.g., #[allow(clippy::foo)] continues to work). Under this RFC, neither prelude is suppressed by #![no_implicit_prelude]. This is technically a breaking change since it can produce new ambiguity errors in stable code.

(The breaking change is already taken care of in rust-lang#162597, the ambiguity error is raised regardless of whether the `no_implicit_prelude` attribute is used)

Currently, the following code errors. After this PR, it will start compiling.
```rust
#![no_implicit_prelude]
#![feature(register_tool)]
#![register_tool(my_tool)]

#[my_tool::attr] // ERROR cannot find module or crate `my_tool` in this scope
#[rustfmt::skip] // ERROR cannot find module or crate `rustfmt` in this scope
struct X;
```

Reference PR: rust-lang/reference#2404

r? petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 3, 2026
…r, r=petrochenkov

Make `no_implicit_prelude` not suppress tool attributes

Implements part of the `register_tool` rfc, [RFC 3808](https://rust-lang.github.io/rfcs/3808-register-tool.html):
> Today, #![no_implicit_prelude] suppresses the tool attribute prelude but does not suppress the lint prelude (e.g., #[allow(clippy::foo)] continues to work). Under this RFC, neither prelude is suppressed by #![no_implicit_prelude]. This is technically a breaking change since it can produce new ambiguity errors in stable code.

(The breaking change is already taken care of in rust-lang#162597, the ambiguity error is raised regardless of whether the `no_implicit_prelude` attribute is used)

Currently, the following code errors. After this PR, it will start compiling.
```rust
#![no_implicit_prelude]
#![feature(register_tool)]
#![register_tool(my_tool)]

#[my_tool::attr] // ERROR cannot find module or crate `my_tool` in this scope
#[rustfmt::skip] // ERROR cannot find module or crate `rustfmt` in this scope
struct X;
```

Reference PR: rust-lang/reference#2404

r? petrochenkov
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Nov 4, 2026
Rollup merge of #165377 - mejrs:no_implicit_prelude_tool_attr, r=petrochenkov

Make `no_implicit_prelude` not suppress tool attributes

Implements part of the `register_tool` rfc, [RFC 3808](https://rust-lang.github.io/rfcs/3808-register-tool.html):
> Today, #![no_implicit_prelude] suppresses the tool attribute prelude but does not suppress the lint prelude (e.g., #[allow(clippy::foo)] continues to work). Under this RFC, neither prelude is suppressed by #![no_implicit_prelude]. This is technically a breaking change since it can produce new ambiguity errors in stable code.

(The breaking change is already taken care of in #162597, the ambiguity error is raised regardless of whether the `no_implicit_prelude` attribute is used)

Currently, the following code errors. After this PR, it will start compiling.
```rust
#![no_implicit_prelude]
#![feature(register_tool)]
#![register_tool(my_tool)]

#[my_tool::attr] // ERROR cannot find module or crate `my_tool` in this scope
#[rustfmt::skip] // ERROR cannot find module or crate `rustfmt` in this scope
struct X;
```

Reference PR: rust-lang/reference#2404

r? petrochenkov

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants