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

1.67 regression with ……::{opaque#0}<'_> does not live long enough error #107516

Closed
steffahn opened this issue Jan 31, 2023 · 12 comments · Fixed by #108691
Closed

1.67 regression with ……::{opaque#0}<'_> does not live long enough error #107516

steffahn opened this issue Jan 31, 2023 · 12 comments · Fixed by #108691
Assignees
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

steffahn commented Jan 31, 2023

Discussed in https://users.rust-lang.org/t/rust-1-67-lifetime-error-compiles-with-1-66-what-changed/88483 and described on zotero/citeproc-rs#154. I can reproduce a regression in 1.67.0 using the current latest commit “2ab195a1e6f84f0ff284813ece61dc62096abbfe” in the zotero/citeproc-rs repo.

This issue was first incorrectly thought of as a sort of “duplicate” of #107426, since that issue originally claimed a 1.67 regression, too, but actually regressed in 1.66, and on a deliberate soundness fix (#95474).

However, bisection of the above-mentioned commit on citeproc-rs points to a different PR, that is

Glancing at it, that PR does not look like it’s supposed to break anything. @rustbot label regression-from-stable-to-stable, T-compiler, E-needs-mcve

Compilation error

error: `QuoteSplitter<'_, impl Iterator<Item = (usize, char)> + '_>::events::{opaque#0}<'_>` does not live long enough
   --> crates/io/src/output/parse_quotes.rs:419:47
    |
419 |                 | MicroNode::Formatted(..) => EachSplitter::Index(Some(ix)),
    |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `QuoteSplitter<'_, impl Iterator<Item = (usize, char)> + '_>::events::{opaque#0}<'_>` does not live long enough
   --> crates/io/src/output/parse_quotes.rs:430:21
    |
430 | /                     EachSplitter::Splitter {
431 | |                         index: ix,
432 | |                         splitter,
433 | |                         seen_any: Some(false),
434 | |                     }
    | |_____________________^

error: could not compile `citeproc-io` due to 2 previous errors

bisection

searched toolchains a28f3c88e50a77bc2a91889241248c4543854e61 through b7bc90fea3b441234a84b49fdafeb75815eebbab


********************************************************************************
Regression in 7fe6f36224e92db6fbde952e0b7e50863161f6ee
********************************************************************************

==================================================================================
= Please file this regression report on the rust-lang/rust GitHub repository     =
=        New issue: https://github.com/rust-lang/rust/issues/new                 =
=     Known issues: https://github.com/rust-lang/rust/issues                     =
= Copy and paste the text below into the issue report thread.  Thanks!           =
==================================================================================

searched nightlies: from nightly-2022-09-10 to nightly-2023-01-20
regressed nightly: nightly-2022-11-22
searched commit range: https://github.com/rust-lang/rust/compare/a28f3c88e50a77bc2a91889241248c4543854e61...b7bc90fea3b441234a84b49fdafeb75815eebbab
regressed commit: https://github.com/rust-lang/rust/commit/7fe6f36224e92db6fbde952e0b7e50863161f6ee

<details>
<summary>bisected with <a href='https://github.com/rust-lang/cargo-bisect-rustc'>cargo-bisect-rustc</a> v0.6.5</summary>


Host triple: x86_64-unknown-linux-gnu
Reproduce with:
```bash
cargo bisect-rustc --prompt --access github --start 2022-09-10 --end 2023-01-20 --regress error 
```
@steffahn steffahn added the C-bug Category: This is a bug. label Jan 31, 2023
@rustbot rustbot added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 31, 2023
@steffahn steffahn changed the title 1.67 regression with ……::{opaque#0}<'_> does not live long enough` error 1.67 regression with ` ……::{opaque#0}<'_> does not live long enough error Jan 31, 2023
@steffahn steffahn changed the title 1.67 regression with ` ……::{opaque#0}<'_> does not live long enough error 1.67 regression with ` ……::{opaque#0}<'_>` does not live long enough error Jan 31, 2023
@steffahn steffahn changed the title 1.67 regression with ` ……::{opaque#0}<'_>` does not live long enough error 1.67 regression with ` ……::{opaque#0}<'_> does not live long enough` error Jan 31, 2023
@steffahn steffahn changed the title 1.67 regression with ` ……::{opaque#0}<'_> does not live long enough` error 1.67 regression with ……::{opaque#0}<'_> does not live long enough error Jan 31, 2023
@steffahn
Copy link
Member Author

@rustbot label A-impl-trait

Ping @cjgillot because of the regressing PR.

@rustbot rustbot added the A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. label Jan 31, 2023
@apiraino
Copy link
Contributor

apiraino commented Feb 2, 2023

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-critical

@rustbot rustbot added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 2, 2023
@pnkfelix
Copy link
Member

pnkfelix commented Feb 2, 2023

(I'm planning to do a MCVE hunt for this after I take care of a beta- and stable-backport that is slightly higher priority.)

@steffahn
Copy link
Member Author

steffahn commented Feb 2, 2023

Perhaps this is obvious, but to avoid any wasted time, I’ll rather write the remark than not: While reducing/minimizing – given the experience described in #107426 (comment) – make sure to keep an eye on that the regression point doesn’t shift 🐱

@compiler-errors
Copy link
Member

compiler-errors commented Feb 9, 2023

Ah, guess I should note that @cjgillot has not been tagged here. I may work on MCVE here, but they know that PR best.

edit: nvm, steffahn did tag them. Ignore me 😄
(I need to get better at reading)

@compiler-errors
Copy link
Member

compiler-errors commented Feb 14, 2023

Partially minimized:

#[derive(Debug)]
struct QuoteMatcher<'a>(&'a Vec<String>);

impl<'a> QuoteMatcher<'a> {
    fn intermediates(&'a self) -> impl Iterator<Item = Intermediate> + 'a {
        self.0.iter().enumerate().flat_map(move |(ix, string)| {
            let splitter = new_quote_splitter(&string).events();
            EachSplitter::Splitter { index: ix, splitter, seen_any: Some(false) }
        })
    }
}

impl<'a, I: Iterator<Item = (usize, char)>> QuoteSplitter<'a, I> {
    fn events(self) -> impl Iterator<Item = Event<'a>> {
        self.flat_map(|x| x)
    }
}

#[derive(Debug)]
enum EachSplitter<'a, I: Iterator<Item = Event<'a>> + 'a> {
    Splitter { splitter: I, seen_any: Option<bool>, index: usize },
}

impl<'a, I: Iterator<Item = Event<'a>>> Iterator for EachSplitter<'a, I> {
    type Item = Intermediate;
    fn next(&mut self) -> Option<Self::Item> {
        todo!()
    }
}

struct Event<'a>(&'a str);

struct Intermediate;

fn leaning_text(node: &str, rightmost: bool) -> Option<&str> {
    todo!()
}

#[derive(Debug)]
struct QuoteSplitter<'a, I: Iterator<Item = (usize, char)> + 'a> {
    string: &'a str,
    possibles: I,
}

fn new_quote_splitter<'a>(
    string: &'a str,
) -> QuoteSplitter<'a, impl Iterator<Item = (usize, char)> + 'a> {
    QuoteSplitter {
        string,
        possibles: string.char_indices().filter(|_| true),
    }
}

impl<'a, I: Iterator<Item = (usize, char)>> Iterator for QuoteSplitter<'a, I> {
    type Item = Thingo<'a>;
    fn next(&mut self) -> Option<Self::Item> {
        todo!()
    }
}

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

impl<'a> Iterator for Thingo<'a> {
    type Item = Event<'a>;
    fn next(&mut self) -> Option<Self::Item> {
        todo!()
    }
}

fn main() {}

@apiraino apiraino removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 14, 2023
@wesleywiser wesleywiser added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Feb 16, 2023
@wesleywiser
Copy link
Member

Would someone from @rust-lang/types be able to investigate this regression a bit? Thanks! 🙂

@jackh726 jackh726 self-assigned this Feb 23, 2023
@aliemjay
Copy link
Member

aliemjay commented Feb 28, 2023

Minimized further:

type It = u32;

fn iter<'a: 'a>() -> impl Iterator<Item = &'static It> {
    [].into_iter()
}

struct Bivar<'a, I: Iterator<Item = &'a It> + 'a>(I);

fn main() {
    || {
        Bivar(iter())
    };
}

(edit: pnkfelix took liberty of updating the example so that it is more clearly a regression, in terms of having something that successfully compiles on sufficiently old compilers.)

@pnkfelix
Copy link
Member

pnkfelix commented Mar 2, 2023

Hmm. I get errors from @aliemjay 's example even on old compilers, of the form:

  = help: the trait `Sized` is not implemented for `str`
  = note: required because of the requirements on the impl of `Iterator` for `std::slice::Iter<'_, str>`

The easiest way to sidestep this is to revise the supposed MCVE with one that uses a sized type, like () or u32, instead of str. (I went ahead and edited the example to reflect this.)

@jackh726
Copy link
Member

jackh726 commented Mar 2, 2023

@pnkfelix I was also having trouble, but all it takes is edition 2021

@pnkfelix
Copy link
Member

pnkfelix commented Mar 2, 2023

Oh yeah, this is the Array::into_iter thing I bet, okay.

@aliemjay
Copy link
Member

aliemjay commented Mar 3, 2023

Fixed by #108691 (hopefully, because there are many ways for minimization to get wrong). It turned out fixing #108592 first was not necessary.

@rustbot claim

@rustbot rustbot assigned aliemjay and unassigned jackh726 Mar 3, 2023
@bors bors closed this as completed in 8824994 Mar 7, 2023
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. C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants