I'm getting the following error:
error[E0635]: unknown feature `proc_macro_span_shrink`
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.50/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
I found a fix for this by setting my rust version to a specific older nightly build, but that doesn't work with another project, and I really want a better solution. I'm assuming I'm using an out-of-date version of something, or maybe I have a dependency in my cargo.toml file I can get rid of, but that error doesn't tell me anything about which one.
After some searching I tried running cargo tree -e features -i proc-macro2
, but while that output a lot of stuff referring to several dependencies, nothing referred specifically to proc_macro_span_shrink
.
proc-macro2 v1.0.50
├── quote v1.0.17
│ └── syn v1.0.90
│ └── proc-macro-error v1.0.4
│ ├── proc-macro-error feature "default"
│ │ ├── clap_derive v4.1.8 (proc-macro)
│ │ │ └── clap_derive feature "default"
│ │ │ └── clap v4.1.8
│ │ │ ├── clap feature "color"
│ │ │ │ └── clap feature "default"
│ │ │ │ └── petersburg v0.0.1 (~/Github/petersburg)
│ │ │ │ └── petersburg feature "default" (command-line)
│ │ │ ├── clap feature "default" (*)
│ │ │ ├── clap feature "derive"
│ │ │ │ └── petersburg v0.0.1 (~/Github/petersburg) (*)
│ │ │ ├── clap feature "error-context"
│ │ │ │ ├── clap feature "default" (*)
│ │ │ │ └── clap feature "suggestions"
│ │ │ │ └── clap feature "default" (*)
│ │ │ ├── clap feature "help"
│ │ │ │ └── clap feature "default" (*)
│ │ │ ├── clap feature "std"
│ │ │ │ └── clap feature "default" (*)
│ │ │ ├── clap feature "suggestions" (*)
│ │ │ └── clap feature "usage"
│ │ │ └── clap feature "default" (*)
│ │ ├── glib-macros v0.15.10 (proc-macro)
│ │ │ └── glib-macros feature "default"
│ │ │ └── glib v0.15.10
│ │ │ └── glib feature "default"
│ │ │ ├── atk v0.15.1
│ │ │ │ └── atk feature "default"
│ │ │ │ └── gtk v0.15.4
│ │ │ │ └── gtk feature "default"
│ │ │ │ └── petersburg v0.0.1 ~/Github/petersburg) (*)
│ │ │ ├── cairo-rs v0.15.10
│ │ │ │ ├── cairo-rs feature "default"
│ │ │ │ │ ├── gdk v0.15.4
│ │ │ │ │ │ └── gdk feature "default"
│ │ │ │ │ │ ├── gtk v0.15.4 (*)
│ │ │ │ │ │ └── petersburg v0.0.1 (~/Github/petersburg) (*)
│ │ │ │ │ ├── gtk v0.15.4 (*)
│ │ │ │ │ └── petersburg v0.0.1 (~/Github/petersburg) (*)
│ │ │ │ ├── cairo-rs feature "glib"
│ │ │ │ │ └── cairo-rs feature "use_glib"
│ │ │ │ │ └── cairo-rs feature "default" (*)
│ │ │ │ ├── cairo-rs feature "png"
│ │ │ │ │ └── petersburg v0.0.1 (~/Github/petersburg) (*)
│ │ │ │ └── cairo-rs feature "use_glib" (*)
│ │ │ ├── gdk v0.15.4 (*)
│ │ │ ├── gdk-pixbuf v0.15.10
│ │ │ │ └── gdk-pixbuf feature "default"
│ │ │ │ ├── gdk v0.15.4 (*)
│ │ │ │ └── gtk v0.15.4 (*)
│ │ │ ├── gio v0.15.10
│ │ │ │ └── gio feature "default"
│ │ │ │ ├── gdk v0.15.4 (*)
│ │ │ │ ├── gdk-pixbuf v0.15.10 (*)
│ │ │ │ └── gtk v0.15.4 (*)
│ │ │ ├── gtk v0.15.4 (*)
│ │ │ ├── pango v0.15.10
│ │ │ │ └── pango feature "default"
│ │ │ │ ├── gdk v0.15.4 (*)
│ │ │ │ └── gtk v0.15.4 (*)
│ │ │ └── petersburg v0.0.1 (~/Github/petersburg) (*)
│ │ └── gtk3-macros v0.15.4 (proc-macro)
│ │ └── gtk3-macros feature "default"
│ │ └── gtk v0.15.4 (*)
│ ├── proc-macro-error feature "syn"
│ │ └── proc-macro-error feature "syn-error"
│ │ └── proc-macro-error feature "default" (*)
│ └── proc-macro-error feature "syn-error" (*)
│ ├── syn feature "clone-impls"
│ │ └── syn feature "default"
│ │ ├── clap_derive v4.1.8 (proc-macro) (*)
│ │ └── thiserror-impl v1.0.30 (proc-macro)
│ │ └── thiserror-impl feature "default"
│ │ └── thiserror v1.0.30
│ │ └── thiserror feature "default"
│ │ ├── cairo-rs v0.15.10 (*)
│ │ ├── gio v0.15.10 (*)
│ │ ├── glib v0.15.10 (*)
│ │ └── proc-macro-crate v1.1.3
│ │ └── proc-macro-crate feature "default"
│ │ ├── glib-macros v0.15.10 (proc-macro) (*)
│ │ └── gtk3-macros v0.15.4 (proc-macro) (*)
│ ├── syn feature "default" (*)
│ ├── syn feature "derive"
│ │ └── syn feature "default" (*)
│ ├── syn feature "full"
│ │ ├── clap_derive v4.1.8 (proc-macro) (*)
│ │ ├── glib-macros v0.15.10 (proc-macro) (*)
│ │ └── gtk3-macros v0.15.4 (proc-macro) (*)
│ ├── syn feature "parsing"
│ │ └── syn feature "default" (*)
│ ├── syn feature "printing"
│ │ └── syn feature "default" (*)
│ ├── syn feature "proc-macro"
│ │ └── syn feature "default" (*)
│ └── syn feature "quote"
│ ├── syn feature "printing" (*)
│ └── syn feature "proc-macro" (*)
│ ├── quote feature "default"
│ │ ├── clap_derive v4.1.8 (proc-macro) (*)
│ │ ├── glib-macros v0.15.10 (proc-macro) (*)
│ │ ├── gtk3-macros v0.15.4 (proc-macro) (*)
│ │ ├── proc-macro-error v1.0.4 (*)
│ │ ├── proc-macro-error-attr v1.0.4 (proc-macro)
│ │ │ └── proc-macro-error-attr feature "default"
│ │ │ └── proc-macro-error v1.0.4 (*)
│ │ └── thiserror-impl v1.0.30 (proc-macro) (*)
│ └── quote feature "proc-macro"
│ ├── quote feature "default" (*)
│ └── syn feature "proc-macro" (*)
└── syn v1.0.90 (*)
├── proc-macro2 feature "default"
│ ├── clap_derive v4.1.8 (proc-macro) (*)
│ ├── glib-macros v0.15.10 (proc-macro) (*)
│ ├── gtk3-macros v0.15.4 (proc-macro) (*)
│ ├── proc-macro-error v1.0.4 (*)
│ ├── proc-macro-error-attr v1.0.4 (proc-macro) (*)
│ └── thiserror-impl v1.0.30 (proc-macro) (*)
└── proc-macro2 feature "proc-macro"
├── proc-macro2 feature "default" (*)
├── quote feature "proc-macro" (*)
└── syn feature "proc-macro" (*)
To be clear, while a "Package X is at fault" answer would be appreciated, I really want to know how to figure this out myself.
A "feature" as mentioned in the error is for unstable compiler features as you might see in The Unstable Book or any WIP RFCs used for language / std library feature flags. A "feature" as understood by cargo tree
are Cargo features as documented in The Cargo Book for crate-specific feature flags. They are completely different things.
Since this is an error for an unknown compiler feature, there are two possibilities:
cargo update -p proc-macro2
) or updating/upgrading a parent dependency.rustup update
), or potentially you could downgrade the dependency (using cargo update -p proc-macro2 --precise=<OLDER VERSION>
).The first is the solution in this case since the error is from proc-macro2 v1.0.50 and the error was fixed in v1.0.60 as per this issue. The core problem was actually neither of the above possibilities (kind of) since a feature was renamed during development as per this PR.
How do I find the offending dependency?
With a problem like this (an unknown compiler feature), the problem is always an incompatibility between the particular crate and your compiler. You can find the offending crate via its path:
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.50/src/lib.rs:92:30
^^^^^^^^^^^