2020-05-30 21:04:57 +00:00
|
|
|
//@ check-pass
|
2018-12-09 14:46:12 +00:00
|
|
|
//@ edition:2018
|
Remove normalization of `Span` debug output in proc-macro tests
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.
2020-08-09 17:36:31 +00:00
|
|
|
//@ compile-flags: -Z span-debug
|
2019-05-21 22:09:58 +00:00
|
|
|
//@ aux-build:test-macros.rs
|
2018-12-09 14:46:12 +00:00
|
|
|
//@ aux-build:dollar-crate-external.rs
|
2018-12-09 14:31:12 +00:00
|
|
|
|
Remove normalization of `Span` debug output in proc-macro tests
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.
2020-08-09 17:36:31 +00:00
|
|
|
#![no_std] // Don't load unnecessary hygiene information from std
|
|
|
|
extern crate std;
|
2018-12-09 14:31:12 +00:00
|
|
|
|
2019-05-21 22:09:58 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate test_macros;
|
2018-12-18 00:21:28 +00:00
|
|
|
extern crate dollar_crate_external;
|
|
|
|
|
2018-12-09 14:31:12 +00:00
|
|
|
type S = u8;
|
|
|
|
|
2018-12-09 14:46:12 +00:00
|
|
|
mod local {
|
|
|
|
macro_rules! local {
|
|
|
|
() => {
|
2019-05-21 22:09:58 +00:00
|
|
|
print_bang! {
|
2018-12-09 14:46:12 +00:00
|
|
|
struct M($crate::S);
|
|
|
|
}
|
|
|
|
|
2019-05-21 22:09:58 +00:00
|
|
|
#[print_attr]
|
2018-12-09 14:46:12 +00:00
|
|
|
struct A($crate::S);
|
|
|
|
|
2019-05-21 22:09:58 +00:00
|
|
|
#[derive(Print)]
|
2020-05-30 21:04:57 +00:00
|
|
|
struct D($crate::S);
|
2018-12-09 14:46:12 +00:00
|
|
|
};
|
2018-12-09 14:31:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-09 14:46:12 +00:00
|
|
|
local!();
|
|
|
|
}
|
|
|
|
|
|
|
|
mod external {
|
2018-12-18 00:21:28 +00:00
|
|
|
use crate::dollar_crate_external;
|
|
|
|
|
2020-05-30 21:04:57 +00:00
|
|
|
dollar_crate_external::external!();
|
2018-12-09 14:46:12 +00:00
|
|
|
}
|
2018-12-09 14:31:12 +00:00
|
|
|
|
|
|
|
fn main() {}
|