You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 rstest-issue
cd rstest-issue
mkdir .cargo
echo'[build]'>> .cargo/config.toml
echo'rustflags = ["-Zallow-features="]'>> .cargo/config.toml
echo'rstest = "0.6"'>> Cargo.toml
rustup override set nightly
cargo check
produces
Compiling rstest v0.6.4
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:
You can see that by changing the instructions above to -Zallow-features=proc_macro_span:
$ cargo check Compiling rstest v0.6.4error[E0725]: the feature `proc_macro_diagnostic` is not in the list of allowed features --> /Users/jongje/.cargo/registry/src/github.com-1ecc6299db9ec823/rstest-0.6.4/src/lib.rs:213:48 |213 | #![cfg_attr(use_proc_macro_diagnostic, feature(proc_macro_diagnostic))] | ^^^^^^^^^^^^^^^^^^^^^
Honestly, I'd recommend instead using something like @cuviper's autocfg, which will implement the logic for you, and will be upgraded to use the logic once it lands with no further changes needed on your part :) There's also version_check which doesn't currently implement the logic for "is this specific feature available", but will do so soon.
I choose to implement CARGO_ENCODED_RUSTFLAGS parsing because autocfg don't implement the feature probing that I need and the pull request stuck from a while. Also version_check haven't any plan to implement it soon.
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:
produces
The
proc-macro2
crate specifically tries to handle this by parsingRUSTFLAGS
if set, though that currently also runs into issues (dtolnay/proc-macro2#290). Theanyhow
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 onceproc-macro2
is fixed, cookie will start breaking with the same reproduction steps due to thisbuild.rs
:rstest/build.rs
Lines 7 to 9 in 3e6648a
You can see that by changing the instructions above to
-Zallow-features=proc_macro_span
:See also rwf2/cookie-rs#177.
The text was updated successfully, but these errors were encountered: