Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recommending the wrong Arbitrary #126447

Open
lolbinarycat opened this issue Jun 13, 2024 · 0 comments
Open

recommending the wrong Arbitrary #126447

lolbinarycat opened this issue Jun 13, 2024 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

lolbinarycat commented Jun 13, 2024

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

@lolbinarycat lolbinarycat added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 13, 2024
@fmease fmease added the S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants