Add more TAIT multiple defining uses test cases

This commit is contained in:
Santiago Pastorino 2021-06-07 18:56:26 -03:00
parent 9e547b4464
commit c80d062084
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
5 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// check-pass
#![feature(min_type_alias_impl_trait)]
type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) {
(a.clone(), a)
}
fn main() {
println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1));
}

View File

@ -0,0 +1,16 @@
// https://github.com/rust-lang/rust/issues/73481
// This test used to cause unsoundness, since one of the two possible
// resolutions was chosen at random instead of erroring due to conflicts.
#![feature(min_type_alias_impl_trait)]
type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
//~^ ERROR could not find defining uses
fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<B, A>) {
(a.clone(), a)
}
fn main() {
println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1));
}

View File

@ -0,0 +1,8 @@
error: could not find defining uses
--> $DIR/multiple-def-uses-in-one-fn2.rs:7:52
|
LL | type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
| ^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -0,0 +1,18 @@
// https://github.com/rust-lang/rust/issues/73481
// This test used to cause unsoundness, since one of the two possible
// resolutions was chosen at random instead of erroring due to conflicts.
#![feature(min_type_alias_impl_trait)]
type X<A: ToString + Clone, B: ToString + Clone> = impl ToString;
fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<B, A>) {
(a, b)
}
fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) {
(a, b)
//~^ ERROR mismatched types
}
fn main() {}

View File

@ -0,0 +1,18 @@
error[E0308]: mismatched types
--> $DIR/multiple-def-uses-in-one-fn3.rs:14:9
|
LL | fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) {
| - - found type parameter
| |
| expected type parameter
LL | (a, b)
| ^ expected type parameter `A`, found type parameter `B`
|
= note: expected type parameter `A`
found type parameter `B`
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.