Skip to content

Commit 29846d3

Browse files
committed
Fix cfg.
1 parent 9f6a019 commit 29846d3

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

build.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn main() {
2020
println!("cargo:rustc-check-cfg=cfg(no_literal_c_string)");
2121
println!("cargo:rustc-check-cfg=cfg(no_source_text)");
2222
println!("cargo:rustc-check-cfg=cfg(proc_macro_span)");
23+
println!("cargo:rustc-check-cfg=cfg(proc_macro_span_location)");
2324
println!("cargo:rustc-check-cfg=cfg(procmacro2_backtrace)");
2425
println!("cargo:rustc-check-cfg=cfg(procmacro2_nightly_testing)");
2526
println!("cargo:rustc-check-cfg=cfg(procmacro2_semver_exempt)");
@@ -71,37 +72,43 @@ fn main() {
7172
println!("cargo:rerun-if-changed=build/probe.rs");
7273

7374
let proc_macro_span;
75+
let proc_macro_span_location;
7476
let consider_rustc_bootstrap;
7577
if compile_probe(false) {
7678
// This is a nightly or dev compiler, so it supports unstable features
7779
// regardless of RUSTC_BOOTSTRAP. No need to rerun build script if
7880
// RUSTC_BOOTSTRAP is changed.
7981
proc_macro_span = true;
82+
proc_macro_span_location = true;
8083
consider_rustc_bootstrap = false;
8184
} else if let Some(rustc_bootstrap) = env::var_os("RUSTC_BOOTSTRAP") {
8285
if compile_probe(true) {
8386
// This is a stable or beta compiler for which the user has set
8487
// RUSTC_BOOTSTRAP to turn on unstable features. Rerun build script
8588
// if they change it.
8689
proc_macro_span = true;
90+
proc_macro_span_location = true;
8791
consider_rustc_bootstrap = true;
8892
} else if rustc_bootstrap == "1" {
8993
// This compiler does not support the proc macro Span API in the
9094
// form that proc-macro2 expects. No need to pay attention to
9195
// RUSTC_BOOTSTRAP.
9296
proc_macro_span = false;
97+
proc_macro_span_location = rustc >= 88;
9398
consider_rustc_bootstrap = false;
9499
} else {
95100
// This is a stable or beta compiler for which RUSTC_BOOTSTRAP is
96101
// set to restrict the use of unstable features by this crate.
97102
proc_macro_span = false;
103+
proc_macro_span_location = rustc >= 88;
98104
consider_rustc_bootstrap = true;
99105
}
100106
} else {
101107
// Without RUSTC_BOOTSTRAP, this compiler does not support the proc
102108
// macro Span API in the form that proc-macro2 expects, but try again if
103109
// the user turns on unstable features.
104110
proc_macro_span = false;
111+
proc_macro_span_location = rustc >= 88;
105112
consider_rustc_bootstrap = true;
106113
}
107114

@@ -116,13 +123,19 @@ fn main() {
116123
}
117124

118125
if proc_macro_span {
119-
// Enable non-dummy behavior of Span::start and Span::end methods which
120-
// requires an unstable compiler feature. Enabled when building with
121-
// nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable
122-
// features.
126+
// Enable non-dummy behavior of Span::byte_range and Span::join methods
127+
// which require an unstable compiler feature. Enabled when building
128+
// with nightly, unless `-Z allow-feature` in RUSTFLAGS disallows
129+
// unstable features.
123130
println!("cargo:rustc-cfg=proc_macro_span");
124131
}
125132

133+
if proc_macro_span_location {
134+
// Enable non-dummy behavior of Span::start and Span::end methods which
135+
// require Rust 1.88.
136+
println!("cargo:rustc-cfg=proc_macro_span_location");
137+
}
138+
126139
if semver_exempt && proc_macro_span {
127140
// Implement the semver exempt API in terms of the nightly-only
128141
// proc_macro API.

0 commit comments

Comments
 (0)