Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
binarycrusader opened this issue Jan 22, 2017 · 1 comment
Closed

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

binarycrusader opened this issue Jan 22, 2017 · 1 comment

Comments

@binarycrusader
Copy link
Contributor

binarycrusader commented Jan 22, 2017

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.

@durka
Copy link
Contributor

durka commented Jan 23, 2017

Looks like we could just duplicate this line to here?

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 28, 2017
Add note for E0117

Fixes rust-lang#39249.

I just applied the suggestion of @durka since I don't see anything else to add.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants