Skip to content

Commit

Permalink
Switch upcast projections to allowing opaque types and add a test sho…
Browse files Browse the repository at this point in the history
…wing it works.

The old solver was already ICEing on this test before this change
  • Loading branch information
oli-obk committed Apr 4, 2024
1 parent cdcca7e commit 169a045
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0308]: mismatched types
--> $DIR/illegal-upcast-from-impl-opaque.rs:26:5
|
LL | type Foo = impl Sized;
| ---------- the found opaque type
LL |
LL | fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
| ----------------------- expected `&dyn Super<Assoc = i32>` because of return type
LL | x
| ^ expected trait `Super`, found trait `Sub`
|
= note: expected reference `&dyn Super<Assoc = i32>`
found reference `&dyn Sub<Assoc = Foo>`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: internal compiler error: error performing operation: query type op
--> $DIR/illegal-upcast-from-impl-opaque.rs:25:1
|
LL | fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note:
--> $DIR/illegal-upcast-from-impl-opaque.rs:25:1
|
LL | fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

query stack during panic:
end of query stack
29 changes: 29 additions & 0 deletions tests/ui/traits/trait-upcasting/illegal-upcast-from-impl-opaque.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@[next] failure-status: 101
//@[next] known-bug: unknown
//@[next] normalize-stderr-test "note: .*\n\n" -> ""
//@[next] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> ""
//@[next] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
//@[next] normalize-stderr-test "delayed at .*" -> ""
//@[next] rustc-env:RUST_BACKTRACE=0

#![feature(trait_upcasting, type_alias_impl_trait)]

trait Super {
type Assoc;
}

trait Sub: Super {}

impl<T: ?Sized> Super for T {
type Assoc = i32;
}

type Foo = impl Sized;

fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
x //[current]~ mismatched types
}

fn main() {}

0 comments on commit 169a045

Please sign in to comment.