Skip to content

improve case with both anonymous lifetime parameters #43269

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
gaurikholkar-zz opened this issue Jul 16, 2017 · 5 comments
Closed

improve case with both anonymous lifetime parameters #43269

gaurikholkar-zz opened this issue Jul 16, 2017 · 5 comments
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 Jul 16, 2017

Address the case where both the regions are anonymous.
Driving example for this case is

12 |   fn foo(x: &mut Vec<&u8>, y:&u8) {
   |                      ---     --- these references must have the same lifetime
13 | 
14 |     x.push(y);
   |            ^ data from `y` flows into `x` here

cc @nikomatsakis

@nikomatsakis nikomatsakis added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 17, 2017
@nikomatsakis
Copy link
Contributor

cc #42516 -- I believe @gaurikholkar is already pretty far along in this particular patch.

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
bors added a commit that referenced this issue Jul 28, 2017
improve case with both anonymous lifetime parameters #43269

This is a fix to #43269.

Sample output message-

```

error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions.rs:12:12
   |
11 | fn foo(x: &mut Vec<&u8>, y: &u8) {
   |                    ---      --- these references must have the same lifetime
12 |     x.push(y);
   |            ^ data from `y` flows into `x` here

error: aborting due to 2 previous errors

```
r? @nikomatsakis
@nikomatsakis
Copy link
Contributor

So I was talking to @aturon and @jonathandturner and they both mentioned that the current message feels a bit confused to them. @jonathandturner turner wrote (hope he doesn't mind me quoting), "my naive brain goes 'can't the compiler magic up the constraint that the lifetimes match if it's inferring them anyway?'"

Anyway, I was thinking that it might be an improvement to change the wording to:

error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions.rs:12:12
   |
11 | fn foo(x: &mut Vec<&u8>, y: &u8) {
   |                    ---      --- these references are not declared with the same lifetime...
12 |     x.push(y);
   |            ^ ...but data from `y` flows into `x` here

error: aborting due to previous error

@gaurikholkar-zz
Copy link
Author

Opened up a PR #43541

@gaurikholkar-zz
Copy link
Author

Working on this now #43877

@nikomatsakis
Copy link
Contributor

This works now, no? Closing.

# for free to join this conversation on GitHub. Already have an account? # 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