Skip to content

Add error explaination for E0182, E0230 and E0399 #37244

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 22, 2016

Conversation

senior
Copy link

@senior senior commented Oct 18, 2016

This PR adds some error descriptions requested in issue #32777.

r? @GuillaumeGomez

Specifically this adds descriptions for

E0182 - unexpected binding of associated item in expression path
E0230 - missing type parameter from on_unimplemented description
E0399 - overriding a trait type without re-implementing default methods

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -1915,6 +1915,47 @@ More details can be found in [RFC 438].
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
"##,

E0182: r##"
You bound an associated type in an expression path which is not
allowed. Erroneous code example:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Erroneous code example" sentence needs to be on its own line.

fn bar() -> isize { 42 }
}

pub fn main() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to avoid putting the main function in the examples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking it would be better to just have that line floating after the trait impl?

trait Foo {
    type A;
    fn bar() -> isize;
}

impl Foo for isize {
    type A = usize;
    fn bar() -> isize { 42 }
}

// error: unexpected binding of associated item in expression path
let x: isize = Foo::<A=usize>::bar();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The point is to avoid any unneeded "noise". Everyone knows that code needs to go inside a function and it's not what we're trying to do in here. In the generated output, everything (or almost) is put inside a main function so don't worry about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't fix this one.

@@ -2752,6 +2793,28 @@ fn main() {
```
"##,

E0230: r##"
The trait has more type parameters specified than appear in it's definition.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"its"

@@ -2752,6 +2793,28 @@ fn main() {
```
"##,

E0230: r##"
The trait has more type parameters specified than appear in it's definition.
Erroneous example code:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing empty line before this one.

{}
```

Include the correct number of type params and compilation should proceed:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"params" -> "parameters"
"compilation" -> "the compilation" (I find it better this way but totally open to debate)

@@ -3567,6 +3630,42 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
```
"##,

E0399: r##"
You implemented a trait, overriding one or more of it's associated types but did
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"its"

@@ -3567,6 +3630,42 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
```
"##,

E0399: r##"
You implemented a trait, overriding one or more of it's associated types but did
not reimplement it's default methods. Example of erroneous code:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"its"

}
```

Add an implementation for the default methods:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation isn't really explaining anything in here. :-/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "To fix this, add an implementation for each default method from the trait:"?

}
```

To give a concrete type when using the Universal Function Call Syntax,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there are enough details or not... Hard to say from my point of view... :-/

What do you think of this @steveklabnik ?

@GuillaumeGomez
Copy link
Member

Thanks for your work! Just a few typos/nits/improvements and it should be good. :)

@senior
Copy link
Author

senior commented Oct 21, 2016

@GuillaumeGomez Just pushed up another commit with the fixes

@GuillaumeGomez
Copy link
Member

All good, thanks again!

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 21, 2016

📌 Commit 94c1220 has been approved by GuillaumeGomez

@GuillaumeGomez
Copy link
Member

@bors: r-

fn bar() -> isize { 42 }
}

pub fn main() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't fix this one.

@@ -3567,6 +3632,42 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
```
"##,

E0399: r##"
You implemented a trait, overriding one or more of its associated types but did
not reimplement its default methods. Example of erroneous code:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Example of erroneous code example" should be on its own line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, good catch.

@GuillaumeGomez
Copy link
Member

Sorry, missed remaining things... Also, once done, can you squash the extra commits please (just keep the 3 first ones). If you don't know how to do it, take a look here.

@senior senior force-pushed the add-error-desc-182-230-399 branch from 94c1220 to 9365586 Compare October 21, 2016 12:25
@senior
Copy link
Author

senior commented Oct 21, 2016

@GuillaumeGomez No problem, I must have missed that. I fixed up the original 3 commits to include the fixes.

@GuillaumeGomez
Copy link
Member

Ok, now it's good! Thanks again. :)

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 21, 2016

📌 Commit 9365586 has been approved by GuillaumeGomez

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 21, 2016
…r=GuillaumeGomez

Add error explaination for E0182, E0230 and E0399

This PR adds some error descriptions requested in issue rust-lang#32777.

r? @GuillaumeGomez

Specifically this adds descriptions for

E0182 - unexpected binding of associated item in expression path
E0230 - missing type parameter from on_unimplemented description
E0399 - overriding a trait type without re-implementing default methods
bors added a commit that referenced this pull request Oct 22, 2016
Rollup of 10 pull requests

- Successful merges: #37043, #37209, #37211, #37219, #37244, #37253, #37286, #37297, #37309, #37314
- Failed merges:
@bors bors merged commit 9365586 into rust-lang:master Oct 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants