Skip to content

improve error message on attempt to impl on type alias #39249

Closed

Description

@binarycrusader

As seen previously in #9767, messaging when attempting to impl a trait involving a type alias could be improved (using current nightly):

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
   --> manifest/mod.rs:169:1
    |
169 |   impl<'a> FromIterator<io::Result<String>> for Result<Manifest<'a>> {
    |  _^ starting here...
170 | |     fn from_iter<I: IntoIterator<Item = io::Result<String>>>(iter: I) -> Result<Self> {
171 | |         let mut m = Manifest::new();
172 | |         Ok(m)
173 | |     }
174 | | }
    | |_^ ...ending here: impl doesn't use types inside crate
    |
    = note: the impl does not reference any types defined in this crate

From line 86 of that file:

pub type Result<Manifest> = ::std::result::Result<Manifest, ManifestError>;

I had expected to see = note: define and implement a trait or new type instead as described in #9767, but did not, so perhaps this is a regression or a subtly different case?

As someone relatively new to rust, it seems like I should be able to impl in this case since it is specialized such that it's only for a Result using my types, but I guess not.

Activity

  1. durka commented on Jan 23, 2017

    @durka
    Contributor

    Looks like we could just duplicate this line to here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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