dtolnay / dtolnay/proc-macro2

Make `proc_macro_span` optional with nightly

Open
#415 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
934
Forks
135
PR merge metrics
No merged PRs in 30d

Description

From the documentation of [`proc_macro_span`](https://github.com/dtolnay/proc-macro2/blob/fecb02df0e2966c7eb39e020dbf650fa8bafd0c5/build.rs#L15C1-L20C3) I was understanding that if you don't allow unstable features in your nightly build, then the build of the crate should still work:
"Enabled when building with nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable features."

I am using the following configuration in my `.cargo/config.toml`:
```toml
[unstable]
allow-features = []
```

And the following rust nightly: `nightly-2023-09-25`.

When building a dummy crate that just has proc-macro2 as a dependency, the following happens:
```
cargo build --verbose
Dirty proc-macro2 v1.0.67: the config settings changed
Compiling proc-macro2 v1.0.67
Dirty unicode-ident v1.0.12: the config settings changed
Compiling unicode-ident v1.0.12
Running `/Users/fandree/.rustup/toolchains/nightly-2023-09-25-aarch64-apple-darwin/bin/rustc --crate-name build_script_build --edition=2021 /Users/fandree/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.67/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=312 -Zallow-features= --crate-type bin --emit=dep-info,link -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=643d0f678a6ab910 -C extra-filename=-643d0f678a6ab910 --out-dir /Users/fandree/sources/rust-crates/test-crate/target/debug/build/proc-macro2-643d0f678a6ab910 -L dependency=/Users/fandree/sources/rust-crates/test-crate/target/debug/deps --cap-lints allow`
Running `/Users/fandree/.rustup/toolchains/nightly-2023-09-25-aarch64-apple-darwin/bin/rustc --crate-name unicode_ident --edition=2018 /Users/fandree/.cargo/registry/src/index.crates.io-6f17d22bba15001f/unicode-ident-1.0.12/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=312 -Zallow-features= --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C metadata=19688c2ad055990d -C extra-filename=-19688c2ad055990d --out-dir /Users/fandree/sources/rust-crates/test-crate/target/debug/deps -L dependency=/Users/fandree/sources/rust-crates/test-crate/target/debug/deps --cap-lints allow`
Running `/Users/fandree/sources/rust-crates/test-crate/target/debug/build/proc-macro2-643d0f678a6ab910/build-script-build`
Running `/Users/fandree/.rustup/toolchains/nightly-2023-09-25-aarch64-apple-darwin/bin/rustc --crate-name proc_macro2 --edition=2021 /Users/fandree/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.67/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=312 -Zallow-features= --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=aef881fdd2157960 -C extra-filename=-aef881fdd2157960 --out-dir /Users/fandree/sources/rust-crates/test-crate/target/debug/deps -L dependency=/Users/fandree/sources/rust-crates/test-crate/target/debug/deps --extern unicode_ident=/Users/fandree/sources/rust-crates/test-crate/target/debug/deps/libunicode_ident-19688c2ad055990d.rmeta --cap-lints allow --cfg wrap_proc_macro --cfg proc_macro_span`
error[E0725]: the feature `proc_macro_span` is not in the list of allowed features
--> /Users/fandree/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.67/src/lib.rs:90:59
|
90 | #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
```

The `--cfg proc_macro_span` was added even though we also pass the `-Zallow-features=` flag. Is this the expected behavior?

I would like to be able to build proc-macro2 with nightly without having to enable the unstable feature. Is this possible?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.