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

E0623 gives wrong error message for following example with fn items #43937

Closed
gaurikholkar-zz opened this issue Aug 17, 2017 · 2 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@gaurikholkar-zz
Copy link

gaurikholkar-zz commented Aug 17, 2017

fn foo(x:  fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
  y.push(z); 
}

fn main(){}

gives

2 | fn foo(x:  fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
  |               ---  --- these references are not declared with the same lifetime...
3 |   y.push(z);
  |          ^ ...but data from `z` flows into `y` here

but should be giving

2 | fn foo(x:  fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
  |                                 ---      --- these references are not declared with the same lifetime...
3 |   y.push(z); // index will be zero or one
  |          ^ ...but data from `z` flows into `y` here

cc @nikomatsakis

@gaurikholkar-zz gaurikholkar-zz changed the title E0623 gives wrong error message E0623 gives wrong error message for fn items Aug 17, 2017
@gaurikholkar-zz gaurikholkar-zz changed the title E0623 gives wrong error message for fn items E0623 gives wrong error message for following example with fn items Aug 17, 2017
@Mark-Simulacrum Mark-Simulacrum added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Aug 20, 2017
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Aug 21, 2017

There is a similar problem around trait objects:

fn foo(x: Box<Fn(&u8, &u8)>, y: Vec<&u8>, z: &u8) {
  y.push(z); 
}

fn main(){}

Which currently gives:

error[E0623]: lifetime mismatch
 --> src/main.rs:2:10
  |
1 | fn foo(x: Box<Fn(&u8, &u8)>, y: Vec<&u8>, z: &u8) {
  |                  ---  --- these references are not declared with the same lifetime...
2 |   y.push(z); 
  |          ^ ...but data from `z` flows into `y` here

but it should be highlighting the regions in y and z.

@gaurikholkar-zz
Copy link
Author

Fixed in #44516. @nikomatsakis, hence closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants