recommending the wrong Arbitrary
Open
Nobody has claimed this yet.
A-diagnostics
S-needs-repro
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
// sorry, can't replicate this one with just rust, it needs multiple crates.
// specifically, proptest with the derive feature disabled,
// and arbitrary with the derive feature enabled.
// if you import the proptest prelude then try to derive Arbitrary,
// it will suggest using the wrong derive macro
Current output
error: cannot find derive macro `Arbitrary` in this scope
--> src/lib.rs:163:11
|
163 | #[derive(Arbitrary, Debug)]
| ^^^^^^^^^
|
note: `Arbitrary` is imported here, but it is only a trait, without a derive macro
--> src/lib.rs:161:6
|
161 | use proptest::prelude::*;
| ^^^^^^^^^^^^^^^^^^^^
help: consider importing this derive macro
|
159 + use arbitrary::Arbitrary;
|
Desired output
error: cannot find derive macro `Arbitrary` in this scope
--> src/lib.rs:163:11
|
163 | #[derive(Arbitrary, Debug)]
| ^^^^^^^^^
|
note: `Arbitrary` is imported here, but it is only a trait, without a derive macro
--> src/lib.rs:161:6
|
161 | use proptest::prelude::*;
| ^^^^^^^^^^^^^^^^^^^^
help: consider enabling the "derive" feature on the proptest crate
Rationale and extra context
I think the best way of handling this is not suggesting a derive macro with the same name as a trait if that macro has the same path as another trait.
Rust Version
rustc 1.80.0-nightly (debd22da6 2024-05-29)
binary: rustc
commit-hash: debd22da66cfa97c74040ebf68e420672ac8560e
commit-date: 2024-05-29
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic from the issue's src/lib.rs scenario using proptest without derive and arbitrary with derive enabled. Start by locating the Rust compiler logic that chooses derive-macro suggestions, then make the completed behavior suggest enabling proptest's "derive" feature instead of importing arbitrary::Arbitrary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100