Skip to content

Nonsequitur error message when trying to use Self in odd way #31168

Closed
@ketsuban

Description

@ketsuban

This doesn't seem that unreasonable.

enum FooBar {
    Foo,
    Bar
}

impl Default for FooBar {
    fn default() -> Self {
        Self::Foo
    }
}

However, it doesn't work. That's not so bad, but the error message is very unintuitive.

error: no associated item named `Foo` found for type 'hallo::salut::sunt_eu::un_haiduc::FooBar` in the current scope

I can see FooBar::Foo, it's right there. Telling me I can't use Self like this would be fine, but as it stands it's ludicrous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions