Skip to content

Commit 42cc1d2

Browse files
author
Lukas Markeffsky
committed
new solver: improve normalization of Pointee::Metadata
1 parent 0c1f401 commit 42cc1d2

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
378378
goal: Goal<'tcx, Self>,
379379
) -> QueryResult<'tcx> {
380380
let tcx = ecx.tcx();
381+
let metadata_def_id = tcx.require_lang_item(LangItem::Metadata, None);
382+
assert_eq!(metadata_def_id, goal.predicate.def_id());
381383
ecx.probe_misc_candidate("builtin pointee").enter(|ecx| {
382384
let metadata_ty = match goal.predicate.self_ty().kind() {
383385
ty::Bool
@@ -422,30 +424,16 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
422424

423425
ty::Adt(def, args) if def.is_struct() => match def.non_enum_variant().tail_opt() {
424426
None => tcx.types.unit,
425-
Some(field_def) => {
426-
let self_ty = field_def.ty(tcx, args);
427-
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
428-
ecx.add_goal(
429-
GoalSource::Misc,
430-
goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)),
431-
);
432-
return ecx
433-
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
427+
Some(tail_def) => {
428+
let tail_ty = tail_def.ty(tcx, args);
429+
Ty::new_projection(tcx, metadata_def_id, [tail_ty])
434430
}
435431
},
436432
ty::Adt(_, _) => tcx.types.unit,
437433

438434
ty::Tuple(elements) => match elements.last() {
439435
None => tcx.types.unit,
440-
Some(&self_ty) => {
441-
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
442-
ecx.add_goal(
443-
GoalSource::Misc,
444-
goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)),
445-
);
446-
return ecx
447-
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
448-
}
436+
Some(&tail_ty) => Ty::new_projection(tcx, metadata_def_id, [tail_ty]),
449437
},
450438

451439
ty::Infer(

tests/ui/traits/pointee-normalize-equate.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// revisions: old next
3+
//[next] compile-flags: -Znext-solver
24

35
#![feature(ptr_metadata)]
46

0 commit comments

Comments
 (0)