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

Wrong lifetime error on nightly 1.67.0-nightly (ff8c8dfbe 2022-11-22) #104815

Closed
la10736 opened this issue Nov 24, 2022 · 1 comment · Fixed by #104936 or rust-skia/rust-skia#740
Closed
Assignees
Labels
C-bug Category: This is a bug. 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

@la10736
Copy link
Contributor

la10736 commented Nov 24, 2022

Some rstest users report an error on nightly-2022-11-22 (see la10736/rstest#169 ).
I narrowed down the regression to the following code:

Code

I tried this code:

struct It;

struct Data {
    items: Vec<It>,
}

impl Data {
    fn new() -> Self {
        Self {
            items: vec![It, It],
        }
    }

    fn content(&self) -> impl Iterator<Item = &It> {
        self.items.iter()
    }
}

struct Container<'a> {
    name: String,
    resolver: Box<dyn Resolver + 'a>,
}

impl<'a> Container<'a> {
    fn new<R: Resolver + 'a>(name: &str, resolver: R) -> Self {
        Self {
            name: name.to_owned(),
            resolver: Box::new(resolver),
        }
    }
}

trait Resolver {}

impl<R: Resolver> Resolver for &R {}

impl Resolver for It {}

fn get<'a>(mut items: impl Iterator<Item = &'a It>) -> impl Resolver + 'a {
    items.next().unwrap()
}

fn main() {
    let data = Data::new();
    let resolver = get(data.content());

    let _ = ["a", "b"]
        .iter()
        .map(|&n| Container::new(n, &resolver))
        .map(|c| c.name)
        .collect::<Vec<_>>();
}

I expected to see this happen: It should compile

Instead, this happened: not compile

mdamico@miklap:~/dev_random/lifetime$ cargo build
   Compiling lifetime v0.1.0 (/home/mdamico/dev_random/lifetime)
error: `get<'_, impl Iterator<Item = &It>>::{opaque#1}<'_>` does not live long enough
  --> src/main.rs:49:19
   |
49 |         .map(|&n| Container::new(n, &resolver))
   |                   ^^^^^^^^^^^^^^

error: `get<'_, impl Iterator<Item = &It>>::{opaque#1}<'_>` does not live long enough
  --> src/main.rs:49:19
   |
49 |         .map(|&n| Container::new(n, &resolver))
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `lifetime` due to 2 previous errors

Version it worked on

It most recently worked on: 1.65.0 stable, 1.66.0-beta.2 (0040709 2022-11-20), nightly-2022-11-21

Version with regression

rustc --version --verbose:

mdamico@miklap:~/dev_random/lifetime$ rustc --version --verbose
rustc 1.67.0-nightly (b7bc90fea 2022-11-21)
binary: rustc
commit-hash: b7bc90fea3b441234a84b49fdafeb75815eebbab
commit-date: 2022-11-21
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Backtrace

Backtrace

<backtrace>

@la10736 la10736 added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Nov 24, 2022
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed regression-untriaged Untriaged performance or correctness regression. labels Nov 24, 2022
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 24, 2022
@albertlarsan68
Copy link
Member

searched nightlies: from nightly-2022-11-21 to nightly-2022-11-22
regressed nightly: nightly-2022-11-22
searched commit range: a28f3c8...b7bc90f
regressed commit: 7fe6f36 (#103491)

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-pc-windows-msvc
Reproduce with:

cargo bisect-rustc --access=github --start 2022-11-21 --end 2022-11-22 -- check

@cjgillot cjgillot self-assigned this Nov 25, 2022
asomers added a commit to asomers/tokio-file that referenced this issue Nov 25, 2022
tarcieri pushed a commit to RustCrypto/actions that referenced this issue Nov 26, 2022
This commit is to be reverted once rust-lang/rust#104815 is fixed.
asomers added a commit to bfffs/bfffs that referenced this issue Nov 26, 2022
asomers added a commit to bfffs/bfffs that referenced this issue Nov 26, 2022
ryzhyk added a commit to vmware-archive/database-stream-processor that referenced this issue Nov 28, 2022
Some of the CI tests use nightly Rust, which no longer works due to a
regression: la10736/rstest#169

We are going to use one of the latest nightly versions that works while
keeping an eye on rust-lang/rust#104815
ryzhyk added a commit to vmware-archive/database-stream-processor that referenced this issue Nov 28, 2022
Some of the CI tests use nightly Rust, which no longer works due to a
regression: la10736/rstest#169

We are going to use one of the latest nightly versions that works while
keeping an eye on rust-lang/rust#104815
@bors bors closed this as completed in 60d1360 Nov 28, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 29, 2022
ryzhyk added a commit to vmware-archive/database-stream-processor that referenced this issue Nov 29, 2022
Some of the CI tests use nightly Rust, which no longer works due to a
regression: la10736/rstest#169

We are going to use one of the latest nightly versions that works while
keeping an eye on rust-lang/rust#104815
ryzhyk added a commit to vmware-archive/database-stream-processor that referenced this issue Nov 29, 2022
Some of the CI tests use nightly Rust, which no longer works due to a
regression: la10736/rstest#169

We are going to use one of the latest nightly versions that works while
keeping an eye on rust-lang/rust#104815
RalfJung pushed a commit to RalfJung/miri that referenced this issue Dec 3, 2022
Ignore bivariant parameters in test_type_match.

rust-lang/rust#103491 made opaque types bivariant with respect of some of their lifetime parameters.  Because of this bivariance, some lifetime variables were not unified to anything during borrowck, and were considered as unequal by borrowck type test.

This PR makes type test ignore the bivariant parameters in test_type_match.

Fixes rust-lang/rust#104815

r? `@oli-obk`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. 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
5 participants