Skip to content

rustc --explain E0117 confusingly refers to Drop trait #69980

Closed
@davepacheco

Description

@davepacheco

The detailed help for compiler error E0117 opens with this summary:

The Drop trait was implemented on a non-struct type.

The rest of the help output correctly (and clearly -- thank you!) explains what happened -- namely, that the user tried to violate the orphan rules for trait implementations. However that first line is confusing since it's apparently unrelated and wrong.

Here's a simple chunk of code that generates error E0117 (as expected):

impl From<String> for Result<String, String>
{
    fn from(s: String) -> Result<String, String>
    {
        Ok(s)
    }
}

Here it is on the playground:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=427d7c85706b598fa8232108769a8552

The error is expected. It's the help output that's confusing:

$ rustc +nightly --explain E0117 
The `Drop` trait was implemented on a non-struct type.

...

The content is also here: https://doc.rust-lang.org/error-index.html#E0117
and I think comes from here: https://github.com/rust-lang/rust/blob/master/src/librustc_error_codes/error_codes/E0117.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions