Skip to content

Make #[cfg(bootstrap)] not error in proc macros on later stages - #98147

Merged
bors merged 1 commit into
rust-lang:masterfrom
est31:bootstrap_cfg_flag
Jun 16, 2022
Merged

Make #[cfg(bootstrap)] not error in proc macros on later stages #98147
bors merged 1 commit into
rust-lang:masterfrom
est31:bootstrap_cfg_flag

Conversation

@est31

@est31est31 commented Jun 15, 2022

Copy link
Copy Markdown
Member

As was discovered in #93628 (comment),
adding #[cfg(bootstrap)] to a rust-internal proc macro crate
would yield an unexpected cfg name error, at least on later
stages wher the bootstrap cfg arg wasn't set.

rustc already passes arguments to mark bootstrap as expected,
however the means of delivery through the RUSTFLAGS env var
is unable to reach proc macro crates, as described
in the issue linked in the code this commit touches.

This wouldn't be an issue for cfg args that get passed through
RUSTFLAGS, as they would never become active either, so
any usage of one of these flags in a proc macro's code would
legitimately yield a lint warning. But since dc30258,
rust takes extra measures to pass --cfg=bootstrap even in
proc macros, by passing it via the wrapper. Thus, we need
to send the flags to mark bootstrap as expected also from the
wrapper, so that #[cfg(bootstrap)] also works from proc macros.

I want to thank Urgau and jplatte for helping me find the cause of this. ❤️

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 15, 2022
@est31est31 mentioned this pull request Jun 15, 2022
@jplatte

Copy link
Copy Markdown
Contributor

Can you please remove the @ before my username in the commit description? I already got two pings from it 😅

@UrgauUrgau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM as this follows the pre-existing hack, even-trough this is very ugly hack.

Comment threadsrc/bootstrap/bin/rustc.rs Outdated
As was discovered in rust-lang#93628 (comment) ,
adding #[cfg(bootstrap)] to a rust-internal proc macro crate
would yield an unexpected cfg name error, at least on later
stages wher the bootstrap cfg arg wasn't set.
rustc already passes arguments to mark bootstrap as expected,
however the means of delivery through the RUSTFLAGS env var
is unable to reach proc macro crates, as described
in the issue linked in the code this commit touches.
This wouldn't be an issue for cfg args that get passed through
RUSTFLAGS, as they would never become *active* either, so
any usage of one of these flags in a proc macro's code would
legitimately yield a lint warning. But since dc30258,
rust takes extra measures to pass --cfg=bootstrap even in
proc macros, by passing it via the wrapper. Thus, we need
to send the flags to mark bootstrap as expected also from the
wrapper, so that #[cfg(bootstrap)] also works from proc macros.
I want to thank Urgau and jplatte for helping me find the cause of this. ❤️
@est31
est31force-pushed the bootstrap_cfg_flag branch from 642f3ef to 471fa05CompareJune 15, 2022 22:04
// Set `--cfg=bootstrap` explicitly instead.
cmd.arg("--cfg=bootstrap");
}
cmd.arg("-Zunstable-options");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still sad about the blanket enable of unstable-options being required, but ultimately it's probably OK.

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented Jun 15, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 471fa05 has been approved by Mark-Simulacrum

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 16, 2022
…askrgr
Rollup of 4 pull requests
Successful merges:
- rust-lang#97757 (Support lint expectations for `--force-warn` lints (RFC 2383))
- rust-lang#98125 (Entry and_modify doc)
- rust-lang#98137 (debuginfo: Fix NatVis for Rc and Arc with unsized pointees.)
- rust-lang#98147 (Make #[cfg(bootstrap)] not error in proc macros on later stages )
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 97a7a3c into rust-lang:masterJun 16, 2022
@rustbotrustbot added this to the 1.63.0 milestone Jun 16, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@est31@rust-highfive@jplatte@Mark-Simulacrum@bors@Urgau@rustbot