forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#110399 - cjgillot:infer-variance, r=aliemjay
Account for opaque variance in outlives Fixes rust-lang#108591 Fixes rust-lang#108592 cc `@aliemjay`
- Loading branch information
Showing
5 changed files
with
116 additions
and
13 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
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,30 @@ | ||
// check-pass | ||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
struct MyTy<'a>(Vec<u8>, &'a ()); | ||
|
||
impl MyTy<'_> { | ||
fn one(&mut self) -> &mut impl Sized { | ||
&mut self.0 | ||
} | ||
fn two(&mut self) -> &mut (impl Sized + 'static) { | ||
self.one() | ||
} | ||
} | ||
|
||
type Opaque<'a> = impl Sized; | ||
fn define<'a>() -> Opaque<'a> {} | ||
|
||
fn test<'a>() { | ||
None::<&'static Opaque<'a>>; | ||
} | ||
|
||
fn one<'a, 'b: 'b>() -> &'a impl Sized { | ||
&() | ||
} | ||
fn two<'a, 'b>() { | ||
one::<'a, 'b>(); | ||
} | ||
|
||
fn main() {} |
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,21 @@ | ||
// check-pass | ||
#![feature(type_alias_impl_trait)] | ||
|
||
fn opaque<'a: 'a>() -> impl Sized {} | ||
fn assert_static<T: 'static>(_: T) {} | ||
|
||
fn test_closure() { | ||
let closure = |_| { | ||
assert_static(opaque()); | ||
}; | ||
closure(&opaque()); | ||
} | ||
|
||
type Opaque<'a> = impl Sized; | ||
fn define<'a>() -> Opaque<'a> {} | ||
|
||
fn test_tait(_: &Opaque<'_>) { | ||
None::<&'static Opaque<'_>>; | ||
} | ||
|
||
fn main() {} |