Skip to content

Commit 4387eea

Browse files
committed
Support constraining opaque types while trait upcasting with binders
1 parent 7f292f4 commit 4387eea

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
25942594
self.infcx
25952595
.at(&obligation.cause, obligation.param_env)
25962596
.eq(
2597-
DefineOpaqueTypes::No,
2597+
DefineOpaqueTypes::Yes,
25982598
upcast_principal.map_bound(|trait_ref| {
25992599
ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
26002600
}),

Diff for: tests/ui/traits/trait-upcasting/type-checking-test-opaques.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(trait_upcasting, type_alias_impl_trait)]
22

3+
//@ check-pass
4+
35
type Tait = impl Sized;
46

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

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

2122
fn main() {}

Diff for: tests/ui/traits/trait-upcasting/type-checking-test-opaques.stderr

-9
This file was deleted.

0 commit comments

Comments
 (0)