Skip to content

Commit 4f264a1

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 0bb99b0 commit 4f264a1

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2595,7 +2595,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
25952595
nested.extend(
25962596
self.infcx
25972597
.at(&obligation.cause, obligation.param_env)
2598-
.sup(DefineOpaqueTypes::No, source_projection, target_projection)
2598+
.sup(DefineOpaqueTypes::Yes, source_projection, target_projection)
25992599
.map_err(|_| SelectionError::Unimplemented)?
26002600
.into_obligations(),
26012601
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: internal compiler error: error performing operation: query type op
2+
--> $DIR/illegal-upcast-from-impl-opaque.rs:26: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:26: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
15+
error: aborting due to 1 previous error
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//@ revisions: current next
2+
//@[next] compile-flags: -Znext-solver
3+
//@[current] check-pass
4+
//@[next] failure-status: 101
5+
//@[next] known-bug: unknown
6+
//@[next] normalize-stderr-test "note: .*\n\n" -> ""
7+
//@[next] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> ""
8+
//@[next] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
9+
//@[next] normalize-stderr-test "delayed at .*" -> ""
10+
//@[next] rustc-env:RUST_BACKTRACE=0
11+
12+
#![feature(trait_upcasting, type_alias_impl_trait)]
13+
14+
trait Super {
15+
type Assoc;
16+
}
17+
18+
trait Sub: Super {}
19+
20+
impl<T: ?Sized> Super for T {
21+
type Assoc = i32;
22+
}
23+
24+
type Foo = impl Sized;
25+
26+
fn illegal(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
27+
x
28+
}
29+
30+
fn main() {}

0 commit comments

Comments
 (0)