Skip to content

Commit

Permalink
Add tests for lifetime-swaps, not just type param swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 3, 2022
1 parent d526a8d commit 80c7b61
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
@@ -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() {}
@@ -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

Expand Up @@ -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));
}

0 comments on commit 80c7b61

Please sign in to comment.