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

improve case with both anonymous lifetime parameters in functions and trait objects. #43276

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

Comments

@gaurikholkar-zz
Copy link

gaurikholkar-zz commented Jul 16, 2017

An example of the above iss

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

cc @nikomatsakis

@nikomatsakis
Copy link
Contributor

So, this particular example is a special-case of #43269 -- but I think that there is an analogous version where the user already has given a name:

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

fn main() { }

This seem to give the correct error message, though, so I guess we just need a test:

error[E0621]: explicit lifetime required in the type of `y`
 --> src/main.rs:2:10
  |
1 | fn foo<'a>(x:  fn(&u8, &u8), y: Vec<&u8>, z: &'a u8) {
  |                              - consider changing the type of `y` to `std::vec::Vec<&'a u8>`
2 |   y.push(z); 
  |          ^ lifetime `'a` required

@Mark-Simulacrum Mark-Simulacrum added A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions labels Jul 19, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@gaurikholkar-zz
Copy link
Author

Done in #44516. Closing the issue.
cc @nikomatsakis

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 A-lifetimes Area: Lifetimes / regions C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants