v2 resolver: a proc macro being specified with the key "proc_macro" vs "proc-macro" causes different results
sunshowers opened this issue · 2 comments
sunshowers commented
Problem
A proc-macro is usually specified as:
[lib]
proc-macro = true
but can also be specified as
[lib]
proc_macro = true
The first one appears to be fine, but the second one appears to cause some strange issues with the v2 resolver.
Steps
git clone https://github.com/facebookincubator/cargo-guppy && cd cargo-guppy
git checkout d5781f069ea57b2d0ec80fddb410978eb1b0f2d5
cd fixtures/workspace/inside-outside/workspace
cargo clean && cargo +nightly build -Zfeatures=all --verbose 2>&1 | grep -F -- '--crate-name internal_macro'
You'll see one line:
Running `rustc --crate-name internal_macro --edition=2018 internal-macro/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type
proc-macro --emit=dep-info,link -C prefer-dynamic -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="internal-normal-feature"' --cfg 'feature="main-build-feature"' [...]`
Now edit internal-macro/Cargo.toml
and change proc-macro = true
to proc_macro = true
.
Afterwards:
$ cargo clean && cargo +nightly build -Zfeatures=all --verbose 2>&1 | grep -F -- '--crate-name internal_macro'
Running `rustc --crate-name internal_macro --edition=2018 internal-macro/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type
proc-macro --emit=dep-info,link -C prefer-dynamic -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="internal-normal-feature"' --cfg 'feature="main-build-feature"' [...]
Running `rustc --crate-name internal_macro --edition=2018 internal-macro/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type
proc-macro --emit=dep-info,link -C prefer-dynamic -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="internal-normal-feature"' [...]
Possible Solution(s)
I guess you could either treat both the same or warn/error on specifying it as proc_macro
.
Notes
Output of cargo version
:
cargo 1.45.0-nightly (9fcb8c1d2 2020-05-25)
cc @ehuss again I guess!
sunshowers commented
We addressed this in the libra repo in diem/diem#4212
alexcrichton commented
What a bizarre bug, wow thanks for the detailed report, And wow I can't believe this was found!