-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
compiler: Forward attributes to eii-expanded macros #150913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+6
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Otherwise you get errors like these if you have an Externally
Implementable Item defined in std:
error: attribute macro has missing stability attribute
--> library/std/src/io/mod.rs:2269:1
|
2269 | #[eii(on_broken_pipe)]
| ^^^^^^^^^^^^^^^^^^^^--
| |
| in this attribute macro expansion
|
::: library/core/src/macros/mod.rs:1899:5
|
1899 | pub macro eii($item:item) {
| ------------- in this expansion of `#[eii]`
Or (fatal) warnings like these:
warning: missing documentation for an attribute macro
--> library/std/src/io/mod.rs:2269:1
48 tasks
Contributor
|
@bors r+ rollup |
Contributor
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jan 10, 2026
compiler: Forward attributes to eii-expanded macros Since rust-lang#150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation. ## The Problem With this eii in **library/std/src/io/mod.rs**: ```rs /// Foo #[eii(on_broken_pipe)] #[unstable(feature = "on_broken_pipe", issue = "150588")] pub fn on_broken_pipe() -> OnBrokenPipe { OnBrokenPipe::BackwardsCompatible } ``` you currently get this compilation error: ``` error: attribute macro has missing stability attribute --> library/std/src/io/mod.rs:2269:1 | 2269 | #[eii(on_broken_pipe)] | ^^^^^^^^^^^^^^^^^^^^-- | | | in this attribute macro expansion | ::: library/core/src/macros/mod.rs:1899:5 | 1899 | pub macro eii($item:item) { | ------------- in this expansion of `#[eii]` ``` because with ` MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/std` we can see that a pub item in the expanded code is indeed missing that attribute: ```rs const _: () = { #[on_broken_pipe] fn on_broken_pipe() -> OnBrokenPipe { OnBrokenPipe::BackwardsCompatible } }; unsafe extern "Rust" { /// Foo #[unstable(feature = "on_broken_pipe", issue = "150588")] #[rustc_eii_extern_item] pub safe fn on_broken_pipe() -> OnBrokenPipe; } #[rustc_builtin_macro(eii_shared_macro)] #[eii_extern_target(on_broken_pipe)] pub macro on_broken_pipe { () => {} } ``` ## The Solution With the fix, that error goes away because we get this expanded code instead: ```rs const _: () = { #[on_broken_pipe] fn on_broken_pipe() -> OnBrokenPipe { OnBrokenPipe::BackwardsCompatible } }; unsafe extern "Rust" { /// Foo #[unstable(feature = "on_broken_pipe", issue = "150588")] #[rustc_eii_extern_item] pub safe fn on_broken_pipe() -> OnBrokenPipe; } /// Foo #[unstable(feature = "on_broken_pipe", issue = "150588")] #[rustc_builtin_macro(eii_shared_macro)] #[eii_extern_target(on_broken_pipe)] pub macro on_broken_pipe { () => {} } ``` Note that we also need to forward the docs, otherwise get get (fatal) warnings like these: ``` warning: missing documentation for an attribute macro --> library/std/src/io/mod.rs:2269:1 ``` r? @jdonszelmann Tracking issues: - rust-lang#125418 - rust-lang#150588 ### What about a test? rust-lang#150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.
rust-bors bot
added a commit
that referenced
this pull request
Jan 11, 2026
Rollup of 11 pull requests Successful merges: - #148196 (Implement create_dir_all() to operate iteratively instead of recursively) - #150494 ( Fix dso_local for external statics with linkage) - #150788 (THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data) - #150799 (Fix ICE: can't type-check body of DefId for issue #148729) - #150804 (Remove std_detect_file_io and std_detect_dlsym_getauxval features) - #150852 (std: sys: fs: uefi: Implement File::write) - #150871 (Use f64 NaN in documentation instead of sqrt(-1.0)) - #150878 (Emit an error for linking staticlibs on BPF) - #150911 (Add missing documentation for globs feature) - #150913 (compiler: Forward attributes to eii-expanded macros) - #150916 (Once again, reorganize the EII tests a bit) r? @ghost
rust-bors bot
added a commit
that referenced
this pull request
Jan 11, 2026
Rollup of 12 pull requests Successful merges: - #150947 (alloctests: Don't run the longer partial-sort tests under Miri) - #148196 (Implement create_dir_all() to operate iteratively instead of recursively) - #150494 ( Fix dso_local for external statics with linkage) - #150788 (THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data) - #150799 (Fix ICE: can't type-check body of DefId for issue #148729) - #150804 (Remove std_detect_file_io and std_detect_dlsym_getauxval features) - #150852 (std: sys: fs: uefi: Implement File::write) - #150871 (Use f64 NaN in documentation instead of sqrt(-1.0)) - #150878 (Emit an error for linking staticlibs on BPF) - #150911 (Add missing documentation for globs feature) - #150913 (compiler: Forward attributes to eii-expanded macros) - #150916 (Once again, reorganize the EII tests a bit) r? @ghost
rust-timer
added a commit
that referenced
this pull request
Jan 11, 2026
Rollup merge of #150913 - eii-macro-attrs, r=jdonszelmann compiler: Forward attributes to eii-expanded macros Since #150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation. ## The Problem With this eii in **library/std/src/io/mod.rs**: ```rs /// Foo #[eii(on_broken_pipe)] #[unstable(feature = "on_broken_pipe", issue = "150588")] pub fn on_broken_pipe() -> OnBrokenPipe { OnBrokenPipe::BackwardsCompatible } ``` you currently get this compilation error: ``` error: attribute macro has missing stability attribute --> library/std/src/io/mod.rs:2269:1 | 2269 | #[eii(on_broken_pipe)] | ^^^^^^^^^^^^^^^^^^^^-- | | | in this attribute macro expansion | ::: library/core/src/macros/mod.rs:1899:5 | 1899 | pub macro eii($item:item) { | ------------- in this expansion of `#[eii]` ``` because with ` MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/std` we can see that a pub item in the expanded code is indeed missing that attribute: ```rs const _: () = { #[on_broken_pipe] fn on_broken_pipe() -> OnBrokenPipe { OnBrokenPipe::BackwardsCompatible } }; unsafe extern "Rust" { /// Foo #[unstable(feature = "on_broken_pipe", issue = "150588")] #[rustc_eii_extern_item] pub safe fn on_broken_pipe() -> OnBrokenPipe; } #[rustc_builtin_macro(eii_shared_macro)] #[eii_extern_target(on_broken_pipe)] pub macro on_broken_pipe { () => {} } ``` ## The Solution With the fix, that error goes away because we get this expanded code instead: ```rs const _: () = { #[on_broken_pipe] fn on_broken_pipe() -> OnBrokenPipe { OnBrokenPipe::BackwardsCompatible } }; unsafe extern "Rust" { /// Foo #[unstable(feature = "on_broken_pipe", issue = "150588")] #[rustc_eii_extern_item] pub safe fn on_broken_pipe() -> OnBrokenPipe; } /// Foo #[unstable(feature = "on_broken_pipe", issue = "150588")] #[rustc_builtin_macro(eii_shared_macro)] #[eii_extern_target(on_broken_pipe)] pub macro on_broken_pipe { () => {} } ``` Note that we also need to forward the docs, otherwise get get (fatal) warnings like these: ``` warning: missing documentation for an attribute macro --> library/std/src/io/mod.rs:2269:1 ``` r? @jdonszelmann Tracking issues: - #125418 - #150588 ### What about a test? #150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since #150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation.
The Problem
With this eii in library/std/src/io/mod.rs:
you currently get this compilation error:
because with
MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/stdwe can see that a pub item in the expanded code is indeed missing that attribute:The Solution
With the fix, that error goes away because we get this expanded code instead:
Note that we also need to forward the docs, otherwise get get (fatal) warnings like these:
r? @jdonszelmann
Tracking issues:
#[std::io::on_broken_pipe]#150588What about a test?
#150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.