1
Fork 0

Test TAITs different lifetimes in defining uses fail

This commit is contained in:
Santiago Pastorino 2021-08-21 12:26:25 -03:00
parent a9ab2e5539
commit 10b3325d26
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]
type OneLifetime<'a, 'b> = impl std::fmt::Debug;
fn foo<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> {
a
}
fn bar<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> {
//~^ ERROR: concrete type differs from previous defining opaque type use
b
}
fn main() {}

View file

@ -0,0 +1,14 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/different_lifetimes_defining_uses.rs:10:1
|
LL | fn bar<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&'a u32`, got `&'b u32`
|
note: previous use here
--> $DIR/different_lifetimes_defining_uses.rs:6:1
|
LL | fn foo<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error