-
-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Currently, the build script just checks whether the user is using nightly, but that doesn't work when the user's configuration, other flags, or the rustc wrapper, prevent the use of the relevant features:
cargo new cookie-issue
cd cookie-issue
mkdir .cargo
echo '[build]' >> .cargo/config.toml
echo 'rustflags = ["-Zallow-features="]' >> .cargo/config.toml
echo 'cookie = "0.15"' >> Cargo.toml
rustup override set nightly
cargo check
produces
Compiling cookie v0.15.0
error[E0725]: the feature `proc_macro_span` is not in the list of allowed features
--> /Users/jongje/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.27/src/lib.rs:82:59
|
82 | #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
| ^^^^^^^^^^^^^^^
error[E0658]: use of unstable library feature 'proc_macro_span'
--> /Users/jongje/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.27/src/wrapper.rs:517:72
|
517 | (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.join(b)?),
| ^^^^
|
= note: see issue #54725 <https://github.com/rust-lang/rust/issues/54725> for more information
= help: add `#![feature(proc_macro_span)]` to the crate attributes to enable
...
The proc-macro2
crate specifically tries to handle this by parsing RUSTFLAGS
if set, though that currently also runs into issues (dtolnay/proc-macro2#290). The anyhow
crate uses a "compile probe", which is very robust, but currently suffers from lack of information from Cargo (dtolnay/anyhow#156). But once rust-lang/cargo#9601 lands, we'll have access to the necessary configuration information to check for feature support using either of those two approaches.
I filed this here (in addition to proc-macro2
) because once proc-macro2
is fixed, cookie will start breaking with the same reproduction steps due to this build.rs
:
https://github.com/SergioBenitez/cookie-rs/blob/434721e1f9fdf9bdb6ec6d760918e1c7390c9a93/build.rs#L2-L3