Skip to content

Commit

Permalink
Allow defining opaque types during trait object upcasting.
Browse files Browse the repository at this point in the history
No stable code is affected, as this requires the `trait_upcasting` feature gate.
  • Loading branch information
oli-obk committed May 23, 2024
1 parent 29a630e commit 7f292f4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions tests/ui/traits/trait-upcasting/upcast-defining-opaque.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand All @@ -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() {}

0 comments on commit 7f292f4

Please sign in to comment.