Skip to content

Commit d17e651

Browse files
committed
Support constraining opaque types while trait upcasting with binders
1 parent 5c7942f commit d17e651

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
25792579
self.infcx
25802580
.at(&obligation.cause, obligation.param_env)
25812581
.eq(
2582-
DefineOpaqueTypes::No,
2582+
DefineOpaqueTypes::Yes,
25832583
upcast_principal.map_bound(|trait_ref| {
25842584
ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
25852585
}),

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

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

-9
This file was deleted.

0 commit comments

Comments
 (0)