Skip to content

Commit 1961358

Browse files
authored
Merge pull request #466 from dtolnay/buildrs
Bring build script comments up to date
2 parents 5b27127 + e1bd2cc commit 1961358

File tree

1 file changed

+22
-36
lines changed

1 file changed

+22
-36
lines changed

build.rs

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
// rustc-cfg emitted by the build script:
2-
//
3-
// "wrap_proc_macro"
4-
// Wrap types from libproc_macro rather than polyfilling the whole API.
5-
// Enabled on rustc 1.29+ as long as procmacro2_semver_exempt is not set,
6-
// because we can't emulate the unstable API without emulating everything
7-
// else. Also enabled unconditionally on nightly, in which case the
8-
// procmacro2_semver_exempt surface area is implemented by using the
9-
// nightly-only proc_macro API.
10-
//
11-
// "hygiene"
12-
// Enable Span::mixed_site() and non-dummy behavior of Span::resolved_at
13-
// and Span::located_at. Enabled on Rust 1.45+.
14-
//
15-
// "proc_macro_span"
16-
// Enable non-dummy behavior of Span::start and Span::end methods which
17-
// requires an unstable compiler feature. Enabled when building with
18-
// nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable
19-
// features.
20-
//
21-
// "super_unstable"
22-
// Implement the semver exempt API in terms of the nightly-only proc_macro
23-
// API. Enabled when using procmacro2_semver_exempt on a nightly compiler.
24-
//
25-
// "span_locations"
26-
// Provide methods Span::start and Span::end which give the line/column
27-
// location of a token. Enabled by procmacro2_semver_exempt or the
28-
// "span-locations" Cargo cfg. This is behind a cfg because tracking
29-
// location inside spans is a performance hit.
30-
//
31-
// "is_available"
32-
// Use proc_macro::is_available() to detect if the proc macro API is
33-
// available or needs to be polyfilled instead of trying to use the proc
34-
// macro API and catching a panic if it isn't available. Enabled on Rust
35-
// 1.57+.
36-
371
#![allow(unknown_lints)]
382
#![allow(unexpected_cfgs)]
393

@@ -71,18 +35,28 @@ fn main() {
7135
}
7236

7337
if semver_exempt || cfg!(feature = "span-locations") {
38+
// Provide methods Span::start and Span::end which give the line/column
39+
// location of a token. This is behind a cfg because tracking location
40+
// inside spans is a performance hit.
7441
println!("cargo:rustc-cfg=span_locations");
7542
}
7643

7744
if rustc < 57 {
45+
// Do not use proc_macro::is_available() to detect whether the proc
46+
// macro API is available vs needs to be polyfilled. Instead, use the
47+
// proc macro API unconditionally and catch the panic that occurs if it
48+
// isn't available.
7849
println!("cargo:rustc-cfg=no_is_available");
7950
}
8051

8152
if rustc < 66 {
53+
// Do not call libproc_macro's Span::source_text. Always return None.
8254
println!("cargo:rustc-cfg=no_source_text");
8355
}
8456

8557
if rustc < 79 {
58+
// Do not call Literal::byte_character nor Literal::c_string. They can
59+
// be emulated by way of Literal::from_str.
8660
println!("cargo:rustc-cfg=no_literal_byte_character");
8761
println!("cargo:rustc-cfg=no_literal_c_string");
8862
}
@@ -130,14 +104,26 @@ fn main() {
130104
}
131105

132106
if proc_macro_span || !semver_exempt {
107+
// Wrap types from libproc_macro rather than polyfilling the whole API.
108+
// Enabled as long as procmacro2_semver_exempt is not set, because we
109+
// can't emulate the unstable API without emulating everything else.
110+
// Also enabled unconditionally on nightly, in which case the
111+
// procmacro2_semver_exempt surface area is implemented by using the
112+
// nightly-only proc_macro API.
133113
println!("cargo:rustc-cfg=wrap_proc_macro");
134114
}
135115

136116
if proc_macro_span {
117+
// Enable non-dummy behavior of Span::start and Span::end methods which
118+
// requires an unstable compiler feature. Enabled when building with
119+
// nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable
120+
// features.
137121
println!("cargo:rustc-cfg=proc_macro_span");
138122
}
139123

140124
if semver_exempt && proc_macro_span {
125+
// Implement the semver exempt API in terms of the nightly-only
126+
// proc_macro API.
141127
println!("cargo:rustc-cfg=super_unstable");
142128
}
143129

0 commit comments

Comments
 (0)