forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch upcast projections to allowing opaque types and add a test sho…
…wing it works. The old solver was already ICEing on this test before this change
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
tests/ui/traits/trait-upcasting/illegal-upcast-from-impl-opaque.current.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
14 changes: 14 additions & 0 deletions
14
tests/ui/traits/trait-upcasting/illegal-upcast-from-impl-opaque.next.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
tests/ui/traits/trait-upcasting/illegal-upcast-from-impl-opaque.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |