Skip to content

Commit 9822fff

Browse files
committed
Add a test showing that we don't infer across multiple uses of the same opaque type but with a different order of generic arguments
1 parent c93f571 commit 9822fff

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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(type_alias_impl_trait)]
6+
7+
type Y<A, B> = impl std::fmt::Debug;
8+
9+
fn g<A, B>() -> (Y<A, B>, Y<B, A>) {
10+
(42_i64, 60) //~^ ERROR concrete type differs from previous defining opaque type use
11+
}
12+
13+
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-infer.rs:9:1
3+
|
4+
LL | fn g<A, B>() -> (Y<A, B>, Y<B, A>) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i64`, got `i32`
6+
|
7+
note: previous use here
8+
--> $DIR/multiple-def-uses-in-one-fn-infer.rs:9:1
9+
|
10+
LL | fn g<A, B>() -> (Y<A, B>, Y<B, A>) {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+

0 commit comments

Comments
 (0)