new solver: improve normalization of Pointee::Metadata
This commit is contained in:
parent
0c1f401d98
commit
42cc1d2f97
2 changed files with 8 additions and 18 deletions
|
@ -378,6 +378,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
||||||
goal: Goal<'tcx, Self>,
|
goal: Goal<'tcx, Self>,
|
||||||
) -> QueryResult<'tcx> {
|
) -> QueryResult<'tcx> {
|
||||||
let tcx = ecx.tcx();
|
let tcx = ecx.tcx();
|
||||||
|
let metadata_def_id = tcx.require_lang_item(LangItem::Metadata, None);
|
||||||
|
assert_eq!(metadata_def_id, goal.predicate.def_id());
|
||||||
ecx.probe_misc_candidate("builtin pointee").enter(|ecx| {
|
ecx.probe_misc_candidate("builtin pointee").enter(|ecx| {
|
||||||
let metadata_ty = match goal.predicate.self_ty().kind() {
|
let metadata_ty = match goal.predicate.self_ty().kind() {
|
||||||
ty::Bool
|
ty::Bool
|
||||||
|
@ -422,30 +424,16 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
||||||
|
|
||||||
ty::Adt(def, args) if def.is_struct() => match def.non_enum_variant().tail_opt() {
|
ty::Adt(def, args) if def.is_struct() => match def.non_enum_variant().tail_opt() {
|
||||||
None => tcx.types.unit,
|
None => tcx.types.unit,
|
||||||
Some(field_def) => {
|
Some(tail_def) => {
|
||||||
let self_ty = field_def.ty(tcx, args);
|
let tail_ty = tail_def.ty(tcx, args);
|
||||||
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
|
Ty::new_projection(tcx, metadata_def_id, [tail_ty])
|
||||||
ecx.add_goal(
|
|
||||||
GoalSource::Misc,
|
|
||||||
goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)),
|
|
||||||
);
|
|
||||||
return ecx
|
|
||||||
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ty::Adt(_, _) => tcx.types.unit,
|
ty::Adt(_, _) => tcx.types.unit,
|
||||||
|
|
||||||
ty::Tuple(elements) => match elements.last() {
|
ty::Tuple(elements) => match elements.last() {
|
||||||
None => tcx.types.unit,
|
None => tcx.types.unit,
|
||||||
Some(&self_ty) => {
|
Some(&tail_ty) => Ty::new_projection(tcx, metadata_def_id, [tail_ty]),
|
||||||
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
|
|
||||||
ecx.add_goal(
|
|
||||||
GoalSource::Misc,
|
|
||||||
goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)),
|
|
||||||
);
|
|
||||||
return ecx
|
|
||||||
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ty::Infer(
|
ty::Infer(
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
// check-pass
|
// check-pass
|
||||||
|
// revisions: old next
|
||||||
|
//[next] compile-flags: -Znext-solver
|
||||||
|
|
||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue