forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#104936 - cjgillot:self-rpit-orig-too, r=oli…
…-obk Ignore bivariant parameters in test_type_match. rust-lang#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#104815 r? `@oli-obk`
- Loading branch information
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// check-pass | ||
|
||
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 get2<'a, 'b: 'b>(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<_>>(); | ||
|
||
let resolver = get2(data.content()); | ||
|
||
let _ = ["a", "b"] | ||
.iter() | ||
.map(|&n| Container::new(n, &resolver)) | ||
.map(|c| c.name) | ||
.collect::<Vec<_>>(); | ||
} |