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 from error on elided lifetime in path in -> impl Trait<...> #96540

Closed
BoxyUwU opened this issue Apr 29, 2022 · 2 comments · Fixed by #96559
Closed

regression from error on elided lifetime in path in -> impl Trait<...> #96540

BoxyUwU opened this issue Apr 29, 2022 · 2 comments · Fixed by #96559
Assignees
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. A-lifetimes Area: lifetime related C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Apr 29, 2022

Code

I tried this code:

use std::marker::PhantomData;

struct Foo<'a>(PhantomData<&'a ()>);

fn foo() -> impl Fn(Foo) {
    |_| ()
}

fn main() {}

I expected to see this happen: it compile

Instead, this happened: it didnt

error[E0106]: missing lifetime specifier
 --> src/main.rs:5:21
  |
5 | fn foo() -> impl Fn(Foo) {
  |                     ^^^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
  |
5 | fn foo() -> impl Fn(Foo<'static>) {
  |                     ~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0106`.

Version it worked on

It most recently worked on Rust 1.60 and this nighty:

rustc 1.62.0-nightly (69a5d2481 2022-04-27)
binary: rustc
commit-hash: 69a5d2481e856a5a18885390b8cf6950b9ff8dd3
commit-date: 2022-04-27
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

Version with regression

rustc --version --verbose:

rustc 1.62.0-nightly (e85edd9a8 2022-04-28)
binary: rustc
commit-hash: e85edd9a844b523a02dbd89f3c02cd13e4c9fe46
commit-date: 2022-04-28
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

cargo bisect

searched nightlies: from nightly-2022-04-26 to nightly-2022-04-29
regressed nightly: nightly-2022-04-29
searched commit range: 69a5d24...e85edd9
regressed commit: c95346b

bisected with cargo-bisect-rustc v0.6.3

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2022-04-26 
@BoxyUwU BoxyUwU added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. labels Apr 29, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 29, 2022
@BoxyUwU BoxyUwU changed the title regression from error on elided lifetime in path regression from error on elided lifetime in path in -> impl Fn(...) Apr 29, 2022
@BoxyUwU BoxyUwU changed the title regression from error on elided lifetime in path in -> impl Fn(...) regression from error on elided lifetime in path in -> impl Trait<...> Apr 29, 2022
@inquisitivecrystal
Copy link
Contributor

inquisitivecrystal commented Apr 29, 2022

Slightly simplified reproduction:

struct Foo<'a>(&'a ());

fn foo() -> impl Fn(Foo) {
    |_| ()
}

fn main() {}

In other words, this isn't specific to PhantomData.

@inquisitivecrystal inquisitivecrystal added A-lifetimes Area: lifetime related A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 29, 2022
@cjgillot cjgillot self-assigned this Apr 29, 2022
@bors bors closed this as completed in 2003d83 Apr 30, 2022
@inquisitivecrystal
Copy link
Contributor

Since this has been fixed now and we never received any reports outside of bevy, I'm going to go ahead and retroactively mark this as P-high. I had suggested P-critical on the assumption that this would hit a lot more code, but that appears not to have been correct.

@inquisitivecrystal inquisitivecrystal added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. A-lifetimes Area: lifetime related C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants