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

Poor error suggestion from failure to use trait #79579

Open
jnqnfe opened this issue Nov 30, 2020 · 0 comments
Open

Poor error suggestion from failure to use trait #79579

jnqnfe opened this issue Nov 30, 2020 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-trait-system Area: Trait system D-confusing Diagnostics: Confusing error or lint that should be reworked. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. 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

@jnqnfe
Copy link
Contributor

jnqnfe commented Nov 30, 2020

Forwarding: rust-num/num-derive#44

As described in the above issue originally filed against num-derive, I experienced a very poor suggestion in the error message resulting from forgetting to use the trait in question.

I'll duplicate the error here, but please see the linked issue for full details.

error[E0599]: no variant or associated item named `from_i32` found for enum `capi::pa_port_available_t` in the current scope
   --> pulse-binding/src/context/introspect.rs:351:48
    |
351 |                 available: def::PortAvailable::from_i32(src.available).unwrap(),
    |                                                ^^^^^^^^ variant or associated item not found in `capi::pa_port_available_t`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use crate::channelmap::_IMPL_NUM_ToPrimitive_FOR_Position::_num_traits::FromPrimitive;`

Clearly the trait referenced in that suggestion is not one that Rust should be making.

Additionally I pointed out a secondary lesser issue with the type name used in the error being unhelpful as it uses the original name rather than the re-exported name.

I'm currently on Rust 1.47 (Debian Sid).

@camelid camelid added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-confusing Diagnostics: Confusing error or lint that should be reworked. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 1, 2020
@estebank estebank added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 16, 2023
@jackh726 jackh726 added S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Dec 25, 2023
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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-trait-system Area: Trait system D-confusing Diagnostics: Confusing error or lint that should be reworked. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. 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

4 participants