Skip to content
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

Remove normalization of Span debug output in proc-macro tests #75345

Merged
merged 1 commit into from
Aug 10, 2020

Conversation

Aaron1011
Copy link
Member

Fixes #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.

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.
@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 9, 2020
@petrochenkov
Copy link
Contributor

r? @petrochenkov @bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Aug 9, 2020

📌 Commit db6b3c1 has been approved by petrochenkov

@bors bors 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 Aug 9, 2020
@bors
Copy link
Contributor

bors commented Aug 9, 2020

⌛ Testing commit db6b3c1 with merge f5fef3c...

@bors
Copy link
Contributor

bors commented Aug 10, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: petrochenkov
Pushing f5fef3c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 10, 2020
@bors bors merged commit f5fef3c into rust-lang:master Aug 10, 2020
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: 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.

Avoid normalizing SyntaxContext ids in test output
6 participants