Regression building proc-macro2 1.0.59 with nightly-2023-06-28
davidv1992 opened this issue ยท 5 comments
How to fix it:
update proc-macro2
to the latest version.
proc_macro2 1.0.59 Fails to build with nightly-2023-06-28 but succeeds building on nightly-2023-06-27
Code
Create a new binary project with cargo new --bin buildtest
add dependency on proc_macro2 with proc_macro feature:
[dependencies]
proc-macro2 = { version = "=1.0.59", features=["default", "proc-macro"] }
Try building binary with cargo build, it will not work and fail with the following error:
error[E0635]: unknown feature `proc_macro_span_shrink`
--> /home/david/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.59/src/lib.rs:92:30
|
92 | feature(proc_macro_span, proc_macro_span_shrink)
| ^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0635`.
error: could not compile `proc-macro2` (lib) due to previous error
Version it worked on
It most recently worked on: nightly-2023-06-27
Version with regression
rustc --version --verbose
:
rustc 1.72.0-nightly (5bd28f5ea 2023-06-28)
binary: rustc
commit-hash: 5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0
commit-date: 2023-06-28
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
It is fixed in proc-macro2 1.0.60+ dtolnay/proc-macro2#391
Good to know it is intended breakage, will upgrade then.
This is very unfortunate bug. I have many Rust projects on my computer. And many of them don't build anymore with recent nightly. So just now I have to find all possibly affected Rust project on my computer using command find ~ -name Cargo.lock
, then go one-by-one and fix them all (by removing Cargo.lock
).
My experience shows that if Rust project was created around May 2023 and it does have proc-macro2 as dependency (nearly all big enough projects have it), then it doesn't build with current nightly. I. e. zillions of projects are affected!!! This is very massive breakage! Again: nearly all projects created near May 2023 are affected!
So, please, publish postmortem similar to this: https://blog.rust-lang.org/inside-rust/2023/05/01/cargo-postmortem.html . Cargo maintainers was able to fix the bug in the last minute, so massive breakage did not happen, but they decided to publish postmortem anyway. But in case of proc-macro2 massive breakage did happen. And of course, make sure this will not happen again
The proc-macro2 crate is using unstable features when it detects nightly. It is fully expected that unstable features break occasionally, hence why they are only available on nightly If you are using stable proc-macro2 will not attempt to use them and as such an older version will keep working. You could argue that proc-macro2 shouldn't use unstable features without opt-in, but this breakage is not the fault of rustc, nor is stable rustc affected by it.