Partially implement ConstArgHasType
This commit is contained in:
parent
da159eb331
commit
d5bd4e233d
30 changed files with 206 additions and 327 deletions
|
@ -197,8 +197,30 @@ impl<'a, 'tcx> EvalCtxt<'a, InferCtxt<'tcx>> {
|
|||
goal: Goal<'tcx, (ty::Const<'tcx>, Ty<'tcx>)>,
|
||||
) -> QueryResult<'tcx> {
|
||||
let (ct, ty) = goal.predicate;
|
||||
self.eq(goal.param_env, ct.ty(), ty)?;
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
|
||||
// FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant
|
||||
// other than `ConstKind::Value`. Unfortunately this would require looking in the
|
||||
// env for any `ConstArgHasType` assumptions for parameters and placeholders. I
|
||||
// have not yet gotten around to implementing this though.
|
||||
//
|
||||
// We do still stall on infer vars though as otherwise a goal like:
|
||||
// `ConstArgHasType(?x: usize, usize)` can succeed even though it might later
|
||||
// get unified with some const that is not of type `usize`.
|
||||
match ct.kind() {
|
||||
// FIXME: Ignore effect vars because canonicalization doesn't handle them correctly
|
||||
// and if we stall on the var then we wind up creating ambiguity errors in a probe
|
||||
// for this goal which contains an effect var. Which then ends up ICEing.
|
||||
ty::ConstKind::Infer(ty::InferConst::Var(_)) => {
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
|
||||
}
|
||||
ty::ConstKind::Error(_) => {
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
_ => {
|
||||
self.eq(goal.param_env, ct.ty(), ty)?;
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue