Allow defining opaque types during trait object upcasting.
No stable code is affected, as this requires the `trait_upcasting` feature gate.
This commit is contained in:
parent
29a630eb72
commit
7f292f41a0
3 changed files with 3 additions and 20 deletions
|
@ -2631,7 +2631,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
nested.extend(
|
||||
self.infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(DefineOpaqueTypes::No, source_projection, target_projection)
|
||||
.eq(DefineOpaqueTypes::Yes, source_projection, target_projection)
|
||||
.map_err(|_| SelectionError::Unimplemented)?
|
||||
.into_obligations(),
|
||||
);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/upcast-defining-opaque.rs:21:5
|
||||
|
|
||||
LL | type Foo = impl Sized;
|
||||
| ---------- the found opaque type
|
||||
LL |
|
||||
LL | fn upcast(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`.
|
|
@ -1,7 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] check-pass
|
||||
//@check-pass
|
||||
|
||||
#![feature(trait_upcasting, type_alias_impl_trait)]
|
||||
|
||||
|
@ -18,7 +18,7 @@ impl<T: ?Sized> Super for T {
|
|||
type Foo = impl Sized;
|
||||
|
||||
fn upcast(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
|
||||
x //[current]~ mismatched types
|
||||
x
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Add table
Reference in a new issue