Skip to content

Poor error suggestion from failure to use trait #79579

Description

@jnqnfe

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`A-trait-systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions