Skip to content

Commit 02857f7

Browse files
committed
Switch upcast projections to allowing opaque types and add a test showing it works.
The old solver was already ICEing on this test before this change
1 parent 97152da commit 02857f7

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/illegal-upcast-from-impl-opaque.rs:26:5
3+
|
4+
LL | type Foo = impl Sized;
5+
| ---------- the found opaque type
6+
LL |
7+
LL | fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
8+
| ----------------------- expected `&dyn Super<Assoc = i32>` because of return type
9+
LL | x
10+
| ^ expected trait `Super`, found trait `Sub`
11+
|
12+
= note: expected reference `&dyn Super<Assoc = i32>`
13+
found reference `&dyn Sub<Assoc = Foo>`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: internal compiler error: error performing operation: query type op
2+
--> $DIR/illegal-upcast-from-impl-opaque.rs:25:1
3+
|
4+
LL | fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note:
8+
--> $DIR/illegal-upcast-from-impl-opaque.rs:25:1
9+
|
10+
LL | fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
query stack during panic:
14+
end of query stack
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ revisions: current next
2+
//@[next] compile-flags: -Znext-solver
3+
//@[next] failure-status: 101
4+
//@[next] known-bug: unknown
5+
//@[next] normalize-stderr-test "note: .*\n\n" -> ""
6+
//@[next] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> ""
7+
//@[next] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
8+
//@[next] normalize-stderr-test "delayed at .*" -> ""
9+
//@[next] rustc-env:RUST_BACKTRACE=0
10+
11+
#![feature(trait_upcasting, type_alias_impl_trait)]
12+
13+
trait Super {
14+
type Assoc;
15+
}
16+
17+
trait Sub: Super {}
18+
19+
impl<T: ?Sized> Super for T {
20+
type Assoc = i32;
21+
}
22+
23+
type Foo = impl Sized;
24+
25+
fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
26+
x //[current]~ mismatched types
27+
}
28+
29+
fn main() {}

0 commit comments

Comments
 (0)