Skip to content

impl [Trait for] value {} gives impl coherence/resolve errors, rather than indicating that the impl head is not a type #18119

Closed
@huonw

Description

@huonw
const X: u8 = 1;
static Y: u8 = 1;
fn foo() {}

impl X {}
impl Y {}
impl foo {}

fn main() {}
<anon>:5:6: 5:7 error: inherent implementations are not allowed for types not defined in the current module.
<anon>:5 impl X {}
              ^
<anon>:6:6: 6:7 error: inherent implementations are not allowed for types not defined in the current module.
<anon>:6 impl Y {}
              ^
<anon>:7:6: 7:9 error: inherent implementations are not allowed for types not defined in the current module.
<anon>:7 impl foo {}
              ^~~
const X: uint = 1;
impl Eq for X {}

fn main() {}
<anon>:9:13: 9:14 error: use of undeclared type name `X`
<anon>:9 impl Eq for X {}
                     ^

These would all preferably indicate that the impl "type" is not actually a type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions