Add tests for lifetime-swaps, not just type param swaps

This commit is contained in:
Oli Scherer 2022-02-03 14:48:05 +00:00
parent d526a8d594
commit 80c7b6108f
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#![feature(type_alias_impl_trait)]
type Foo<'a, 'b> = impl std::fmt::Debug;
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
(i, i) //~^ ERROR concrete type differs from previous
}
fn main() {}

View File

@ -0,0 +1,14 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:1
|
LL | fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&'a i32`, got `&'b i32`
|
note: previous use here
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:1
|
LL | fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -7,6 +7,15 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>)
(a.clone(), a)
}
type Foo<'a, 'b> = impl std::fmt::Debug;
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
(i, j)
}
fn main() {
println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1));
let meh = 42;
let muh = 69;
println!("{:?}", foo(&meh, &muh));
}