mirror of
https://github.com/rust-lang/rust
synced 2024-10-01 22:34:35 +00:00
Dont ICE for dyn* Trait: Trait
goals during selection in new trait solver
This commit is contained in:
parent
d9c13cd453
commit
cd26d10edf
|
@ -213,15 +213,16 @@ fn rematch_object<'tcx>(
|
||||||
mut nested: Vec<PredicateObligation<'tcx>>,
|
mut nested: Vec<PredicateObligation<'tcx>>,
|
||||||
) -> SelectionResult<'tcx, Selection<'tcx>> {
|
) -> SelectionResult<'tcx, Selection<'tcx>> {
|
||||||
let self_ty = goal.predicate.self_ty();
|
let self_ty = goal.predicate.self_ty();
|
||||||
let source_trait_ref = if let ty::Dynamic(data, _, ty::Dyn) = self_ty.kind() {
|
let ty::Dynamic(data, _, source_kind) = *self_ty.kind()
|
||||||
data.principal().unwrap().with_self_ty(infcx.tcx, self_ty)
|
else {
|
||||||
} else {
|
|
||||||
bug!()
|
bug!()
|
||||||
};
|
};
|
||||||
|
let source_trait_ref = data.principal().unwrap().with_self_ty(infcx.tcx, self_ty);
|
||||||
|
|
||||||
let (is_upcasting, target_trait_ref_unnormalized) = if Some(goal.predicate.def_id())
|
let (is_upcasting, target_trait_ref_unnormalized) = if Some(goal.predicate.def_id())
|
||||||
== infcx.tcx.lang_items().unsize_trait()
|
== infcx.tcx.lang_items().unsize_trait()
|
||||||
{
|
{
|
||||||
|
assert_eq!(source_kind, ty::Dyn, "cannot upcast dyn*");
|
||||||
if let ty::Dynamic(data, _, ty::Dyn) = goal.predicate.trait_ref.substs.type_at(1).kind() {
|
if let ty::Dynamic(data, _, ty::Dyn) = goal.predicate.trait_ref.substs.type_at(1).kind() {
|
||||||
(true, data.principal().unwrap().with_self_ty(infcx.tcx, self_ty))
|
(true, data.principal().unwrap().with_self_ty(infcx.tcx, self_ty))
|
||||||
} else {
|
} else {
|
||||||
|
@ -288,7 +289,8 @@ fn rematch_object<'tcx>(
|
||||||
bug!();
|
bug!();
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we're upcasting, get the offset of the vtable pointer, which is
|
// If we're upcasting, get the offset of the vtable pointer, otherwise get
|
||||||
|
// the base of the vtable.
|
||||||
Ok(Some(if is_upcasting {
|
Ok(Some(if is_upcasting {
|
||||||
ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData { vtable_vptr_slot, nested })
|
ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData { vtable_vptr_slot, nested })
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// compile-flags: -C opt-level=0
|
// revisions: current next
|
||||||
|
//[current] compile-flags: -C opt-level=0
|
||||||
|
//[next] compile-flags: -Ztrait-solver=next -C opt-level=0
|
||||||
|
|
||||||
#![feature(dyn_star)]
|
#![feature(dyn_star)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
|
Loading…
Reference in a new issue