2020-06-24 17:16:36 +00:00
|
|
|
//@ aux-build:make-macro.rs
|
2024-11-25 01:37:25 +00:00
|
|
|
//@ proc-macro: meta-macro.rs
|
2020-06-24 17:16:36 +00:00
|
|
|
//@ edition:2018
|
2020-09-02 07:40:56 +00:00
|
|
|
//@ compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene -Z trim-diagnostic-paths=no
|
2020-06-24 17:16:36 +00:00
|
|
|
//@ check-pass
|
2023-07-29 21:44:17 +00:00
|
|
|
// ignore-tidy-linelength
|
2024-12-25 11:12:17 +00:00
|
|
|
//@ normalize-stdout: "\d+#" -> "0#"
|
|
|
|
//@ normalize-stdout: "expn\d{3,}" -> "expnNNN"
|
|
|
|
//@ normalize-stdout: "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */"
|
2020-07-21 23:51:07 +00:00
|
|
|
//
|
|
|
|
// We don't care about symbol ids, so we set them all to 0
|
2020-06-30 02:02:57 +00:00
|
|
|
// in the stdout
|
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;
|
|
|
|
|
2020-06-24 17:16:36 +00:00
|
|
|
extern crate meta_macro;
|
2020-07-21 23:51:07 +00:00
|
|
|
|
|
|
|
macro_rules! produce_it {
|
|
|
|
() => {
|
|
|
|
// `print_def_site!` will respan the `$crate` identifier
|
|
|
|
// with `Span::def_site()`. This should cause it to resolve
|
|
|
|
// relative to `meta_macro`, *not* `make_macro` (despite
|
2022-10-12 16:12:19 +00:00
|
|
|
// the fact that `print_def_site` is produced by a
|
|
|
|
// `macro_rules!` macro in `make_macro`).
|
2020-07-21 23:51:07 +00:00
|
|
|
meta_macro::print_def_site!($crate::dummy!());
|
2023-07-29 21:44:17 +00:00
|
|
|
};
|
2020-07-21 23:51:07 +00:00
|
|
|
}
|
2020-06-24 17:16:36 +00:00
|
|
|
|
|
|
|
fn main() {
|
2020-07-21 23:51:07 +00:00
|
|
|
produce_it!();
|
2020-06-24 17:16:36 +00:00
|
|
|
}
|