Repository navigation
Wrong lifetime error on nightly 1.67.0-nightly (ff8c8dfbe 2022-11-22) #104815
Copy link
Copy link
Closed
rust-skia/rust-skia
#740Labels
C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
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>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Activity
albertlarsan68 commentedon Nov 24, 2022
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:
Workaround a Rust bug in CI
Freeze nightly before regression (#20)
Workaround Rust bug rust-lang/rust#104815
Workaround Rust bug rust-lang/rust#104815
Rollup merge of rust-lang#104936 - cjgillot:self-rpit-orig-too, r=oli…
Use fixed nightly Rust version in CI.
Use fixed nightly Rust version in CI.
Use fixed nightly Rust version in CI.
Use fixed nightly Rust version in CI.
Rollup merge of #104936 - cjgillot:self-rpit-orig-too, r=oli-obk