Remove normalization of Span debug output in proc-macro tests#75345
Merged
bors merged 1 commit intorust-lang:masterfrom Aug 10, 2020
Merged
Remove normalization of Span debug output in proc-macro tests#75345bors merged 1 commit intorust-lang:masterfrom
Span debug output in proc-macro tests#75345bors merged 1 commit intorust-lang:masterfrom
Conversation
Fixes rust-lang#74800 The definition of `is_x86_feature_detected!` (and similar macros) depends on the platform - it is produced by a `cfg_if!` invocation on x86, and a plain `#[cfg]` on other platforms. Since it is part of the prelude, we will end up importing different hygiene information depending on the platform. This previously required us to avoid printing raw `SyntaxContext` ids in any tests that uses the standard library, since the captured output will be platform-dependent. Previously, we replaced all `SyntaxContext` ids with "#CTXT", and the raw `Span` lo/hi bytes with "LO..HI". This commit adds `#![no_std]` and `extern crate std` to all proc-macro tests that print spans. This suppresses the prelude import, while still using lang items from `std` (which gives us a buildable binary). With this apporach, we will only load hygiene information for things which we explicitly import. This lets us re-add `-Z unpretty=expanded,hygiene`, since its output can now be made stable across all platforms. Additionally, we use `-Z span-debug` in more places, which lets us avoid the "LO..HI" normalization hack.
Contributor
|
(rust_highfive has picked a reviewer for you, use r? to override) |
Contributor
|
r? @petrochenkov @bors r+ rollup=iffy |
Collaborator
|
📌 Commit db6b3c1 has been approved by |
Collaborator
Collaborator
|
☀️ Test successful - checks-actions, checks-azure |
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.
Fixes #74800
The definition of
is_x86_feature_detected!(and similar macros)depends on the platform - it is produced by a
cfg_if!invocation onx86, and a plain
#[cfg]on other platforms. Since it is part of theprelude, we will end up importing different hygiene information
depending on the platform. This previously required us to avoid printing raw
SyntaxContextids in any tests that uses the standard library, sincethe captured output will be platform-dependent.
Previously, we replaced all
SyntaxContextids with "#CTXT", and theraw
Spanlo/hi bytes with "LO..HI".This commit adds
#![no_std]andextern crate stdto all proc-macrotests that print spans. This suppresses the prelude import, while
still using lang items from
std(which gives us a buildable binary).With this apporach, we will only load hygiene information for things
which we explicitly import. This lets us re-add
-Z unpretty=expanded,hygiene, since its output can now be made stableacross all platforms.
Additionally, we use
-Z span-debugin more places, which lets us avoidthe "LO..HI" normalization hack.