Skip to content

Rust suggests implementing private trait #25358

Closed
@daboross

Description

@daboross

With the following code:

struct Foo;

fn main() {
    Foo::new();
}

(playpen: http://is.gd/H05mfZ)

Rust tries to help with:

<anon>:4:5: 4:13 help: methods from traits can only be called if the trait is implemented and in scope; the following trait defines a method `new`, perhaps you need to implement it:
<anon>:4:5: 4:13 help: candidate #1: `std::sys_common::thread_info::NewThread`

This trait is impossible to implement however, as it is private - when implemented, rust will give a separate error about the trait being private. If this is the case, rust shouldn't suggest it at all.

Here's a playpen actually implementing the trait in question: http://is.gd/UQakvD

While this really isn't that much of a problem, as it is pretty obvious (to me) that I don't want to implement a NewThread trait, suggestions like this from the compiler may be confusing and discourage new users of the language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.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