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

impl_header_lifetime_elision errors can mention in-band lifetimes when that feature is disabled #54456

Closed
scottmcm opened this issue Sep 22, 2018 · 0 comments

Comments

@scottmcm
Copy link
Member

scottmcm commented Sep 22, 2018

https://play.rust-lang.org/?gist=63df9129c4f3d2c76f2620acc38d0e57&version=nightly&edition=2018

fn foo<'a>(x: &str, y: &'a str) {}

trait Foo<T> {}
impl<'a> Foo<&str> for &'a str {}

The fn elision is totally fine, but the translation to an impl header gives

error[E0688]: cannot mix in-band and explicit lifetime definitions
 --> src/lib.rs:4:14
  |
4 | impl<'a> Foo<&str> for &'a str {}
  |      --      ^ in-band lifetime definition here
  |      |
  |      explicit lifetime definition here

This 1) shouldn't be an error, and 2) shouldn't mention "in-band lifetime"s even if it is.

cc impl_header_lifetime_elision tracking issue, #15872

(This feature is on-by-default in 2018, but not yet stable in 2015.)

pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 2, 2018
Allow both explicit and elided lifetimes in the same impl header

While still prohibiting explicit and in-band in the same header.

Fixes rust-lang#54456

As usual, I don't know the broader context of the code I'm changing, so please let me know whatever I can do better.

Pre-existing test that mixing explicit and in-band remains an error: https://github.com/rust-lang/rust/blob/master/src/test/ui/in-band-lifetimes/E0688.rs
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

No branches or pull requests

1 participant