Skip to content

Commit c80d062

Browse files
committed
Add more TAIT multiple defining uses test cases
1 parent 9e547b4 commit c80d062

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
#![feature(min_type_alias_impl_trait)]
3+
4+
type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
5+
6+
fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) {
7+
(a.clone(), a)
8+
}
9+
10+
fn main() {
11+
println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1));
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://github.com/rust-lang/rust/issues/73481
2+
// This test used to cause unsoundness, since one of the two possible
3+
// resolutions was chosen at random instead of erroring due to conflicts.
4+
5+
#![feature(min_type_alias_impl_trait)]
6+
7+
type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
8+
//~^ ERROR could not find defining uses
9+
10+
fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<B, A>) {
11+
(a.clone(), a)
12+
}
13+
14+
fn main() {
15+
println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1));
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: could not find defining uses
2+
--> $DIR/multiple-def-uses-in-one-fn2.rs:7:52
3+
|
4+
LL | type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
5+
| ^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// https://github.com/rust-lang/rust/issues/73481
2+
// This test used to cause unsoundness, since one of the two possible
3+
// resolutions was chosen at random instead of erroring due to conflicts.
4+
5+
#![feature(min_type_alias_impl_trait)]
6+
7+
type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
8+
9+
fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<B, A>) {
10+
(a, b)
11+
}
12+
13+
fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) {
14+
(a, b)
15+
//~^ ERROR mismatched types
16+
}
17+
18+
fn main() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/multiple-def-uses-in-one-fn3.rs:14:9
3+
|
4+
LL | fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) {
5+
| - - found type parameter
6+
| |
7+
| expected type parameter
8+
LL | (a, b)
9+
| ^ expected type parameter `A`, found type parameter `B`
10+
|
11+
= note: expected type parameter `A`
12+
found type parameter `B`
13+
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
14+
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)