Skip to content

improve error message on attempt to impl on typedef #9767

Closed
@pnkfelix

Description

@pnkfelix

Support for impl on typedefs was removed (IIUC) in PR #6087.

However, the current error you get for attempting to do such a thing is . . . suboptimal:

type Board = [char, ..9];
impl Board { }
fn main() { }
% ./objdir-dbgopt/x86_64-apple-darwin/stage2/bin/rustc  /tmp/u.rs
/tmp/u.rs:2:0: 2:14 error: no base type found for inherent implementation; implement a trait or new type instead
/tmp/u.rs:2 impl Board { }
            ^~~~~~~~~~~~~~
/tmp/u.rs:2:0: 2:14 error: cannot associate methods with a type outside the crate the type is defined in; define and implement a trait or new type instead
/tmp/u.rs:2 impl Board { }
            ^~~~~~~~~~~~~~
error: aborting due to 2 previous errors

Or better still, maybe we could actually put in correct support for impl on typedef, which I think was part of what pcwalton was proposing in his mailing list post here: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003866.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions