Skip to content

Commit 80c7b61

Browse files
committed
Add tests for lifetime-swaps, not just type param swaps
1 parent d526a8d commit 80c7b61

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
#![feature(type_alias_impl_trait)]
3+
4+
type Foo<'a, 'b> = impl std::fmt::Debug;
5+
6+
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
7+
(i, i) //~^ ERROR concrete type differs from previous
8+
}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: concrete type differs from previous defining opaque type use
2+
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:1
3+
|
4+
LL | fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&'a i32`, got `&'b i32`
6+
|
7+
note: previous use here
8+
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:1
9+
|
10+
LL | fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+

src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>)
77
(a.clone(), a)
88
}
99

10+
type Foo<'a, 'b> = impl std::fmt::Debug;
11+
12+
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
13+
(i, j)
14+
}
15+
1016
fn main() {
1117
println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1));
18+
let meh = 42;
19+
let muh = 69;
20+
println!("{:?}", foo(&meh, &muh));
1221
}

0 commit comments

Comments
 (0)