Skip to content

Commit

Permalink
Support constraining opaque types while trait upcasting with binders
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 17, 2024
1 parent 5c7942f commit d17e651
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 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 @@ -2579,7 +2579,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
self.infcx
.at(&obligation.cause, obligation.param_env)
.eq(
DefineOpaqueTypes::No,
DefineOpaqueTypes::Yes,
upcast_principal.map_bound(|trait_ref| {
ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![feature(trait_upcasting, type_alias_impl_trait)]

//@ check-pass

type Tait = impl Sized;

trait Foo<'a>: Bar<'a, 'a, Tait> {}
Expand All @@ -15,7 +17,6 @@ fn test_correct2<'a>(x: &dyn Foo<'a>) {

fn test_correct3<'a>(x: &dyn Foo<'a>, _: Tait) {
let _ = x as &dyn Bar<'_, '_, ()>;
//~^ ERROR: non-primitive cast
}

fn main() {}

This file was deleted.

0 comments on commit d17e651

Please sign in to comment.