mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 10:33:34 +00:00
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
@ -2631,7 +2631,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||||||
nested.extend(
|
nested.extend(
|
||||||
self.infcx
|
self.infcx
|
||||||
.at(&obligation.cause, obligation.param_env)
|
.at(&obligation.cause, obligation.param_env)
|
||||||
.eq(DefineOpaqueTypes::No, source_projection, target_projection)
|
.eq(DefineOpaqueTypes::Yes, source_projection, target_projection)
|
||||||
.map_err(|_| SelectionError::Unimplemented)?
|
.map_err(|_| SelectionError::Unimplemented)?
|
||||||
.into_obligations(),
|
.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
|
//@ revisions: current next
|
||||||
//@[next] compile-flags: -Znext-solver
|
//@[next] compile-flags: -Znext-solver
|
||||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||||
//@[next] check-pass
|
//@check-pass
|
||||||
|
|
||||||
#![feature(trait_upcasting, type_alias_impl_trait)]
|
#![feature(trait_upcasting, type_alias_impl_trait)]
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ impl<T: ?Sized> Super for T {
|
|||||||
type Foo = impl Sized;
|
type Foo = impl Sized;
|
||||||
|
|
||||||
fn upcast(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
|
fn upcast(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
|
||||||
x //[current]~ mismatched types
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user