Make #[cfg(bootstrap)] not error in proc macros on later stages #98147
Merged
bors merged 1 commit intorust-lang:masterfrom Jun 16, 2022
Merged
Make #[cfg(bootstrap)] not error in proc macros on later stages #98147bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Contributor
|
(rust-highfive has picked a reviewer for you, use r? to override) |
Merged
Contributor
|
Can you please remove the |
Urgau
approved these changes
Jun 15, 2022
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. ❤️
642f3ef to
471fa05
Compare
| // Set `--cfg=bootstrap` explicitly instead. | ||
| cmd.arg("--cfg=bootstrap"); | ||
| } | ||
| cmd.arg("-Zunstable-options"); |
Member
There was a problem hiding this comment.
Still sad about the blanket enable of unstable-options being required, but ultimately it's probably OK.
Member
|
@bors r+ rollup |
Collaborator
|
📌 Commit 471fa05 has been approved by |
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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
Urgauandjplattefor helping me find the cause of this. ❤️