Skip to content
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

Regression in return type error quality with impl trait #50652

Closed
jonathandturner opened this issue May 11, 2018 · 3 comments
Closed

Regression in return type error quality with impl trait #50652

jonathandturner opened this issue May 11, 2018 · 3 comments

Comments

@jonathandturner
Copy link
Contributor

@jonathandturner jonathandturner commented May 11, 2018

In playing with impl trait this morning, I noticed that if you do the classic "oops, I left a ; after my return value" error, instead of the helpful message asking if you meant to have the semi-colon, you get this:

screen shot 2018-05-11 at 5 20 58 am

We should definitely try to cover this case too with the same improved error messages we have for other return types.

@jonathandturner
Copy link
Contributor Author

@jonathandturner jonathandturner commented May 11, 2018

Test case

trait Bar {}
impl Bar for bool {}

fn baz() -> impl Bar {
    true;
}

fn main() {
    baz();
}
@larsluthman
Copy link

@larsluthman larsluthman commented May 12, 2018

The same error message appears if your function body consists of 'unimplemented!()' or 'panic!()'. In that case it should probably say something like 'Failed to infer return type' instead.

@estebank
Copy link
Contributor

@estebank estebank commented Apr 29, 2019

Current output:

error[E0277]: the trait bound `(): Bar` is not satisfied
 --> src/main.rs:4:13
  |
4 | fn baz() -> impl Bar {
  |             ^^^^^^^^ the trait `Bar` is not implemented for `()`
5 |     true;
  |         - consider removing this semicolon
  |
  = note: the return type of a function must have a statically known size

It does not check wether the type actually impl Bar.

@estebank estebank closed this Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants