Skip to content

Commit 592fb72

Browse files
committed
Fix dyn* trait resolution
1 parent 06f95e2 commit 592fb72

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
384384

385385
if self.tcx().trait_is_auto(def_id) {
386386
match self_ty.kind() {
387-
ty::Dynamic(..) => {
387+
ty::Dynamic(..) | ty::DynStar(..) => {
388388
// For object types, we don't know what the closed
389389
// over types are. This means we conservatively
390390
// say nothing; a candidate may be added by
@@ -453,7 +453,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
453453
// any LBR.
454454
let self_ty = self.tcx().erase_late_bound_regions(obligation.self_ty());
455455
let poly_trait_ref = match self_ty.kind() {
456-
ty::Dynamic(ref data, ..) => {
456+
ty::Dynamic(ref data, ..) | ty::DynStar(ref data, ..) => {
457457
if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
458458
debug!(
459459
"assemble_candidates_from_object_ty: matched builtin bound, \
@@ -548,7 +548,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
548548
.ty()
549549
.unwrap();
550550

551-
if let ty::Dynamic(data, ..) = ty.kind() { data.principal() } else { None }
551+
if let ty::Dynamic(data, ..) | ty::DynStar(data, ..) = ty.kind() {
552+
data.principal()
553+
} else {
554+
None
555+
}
552556
})
553557
}
554558

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
430430
let trait_predicate = self.infcx.instantiate_binder_with_placeholders(obligation.predicate);
431431
let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
432432
let obligation_trait_ref = ty::Binder::dummy(trait_predicate.trait_ref);
433-
let ty::Dynamic(data, ..) = *self_ty.kind() else {
433+
let (ty::Dynamic(data, ..) | ty::DynStar(data, ..)) = *self_ty.kind() else {
434434
span_bug!(obligation.cause.span, "object candidate with non-object");
435435
};
436436

0 commit comments

Comments
 (0)