Fully implement ConstArgHasType
This commit is contained in:
parent
a9702a6668
commit
8d6705cdb8
7 changed files with 158 additions and 103 deletions
|
@ -994,23 +994,25 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
|
||||
// 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
|
||||
// don't really want to implement this in the old solver so I haven't.
|
||||
//
|
||||
// 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`.
|
||||
let ct = self.infcx.shallow_resolve_const(ct);
|
||||
let ct_ty = match ct.kind() {
|
||||
ty::ConstKind::Infer(ty::InferConst::Var(_)) => {
|
||||
ty::ConstKind::Infer(_) => {
|
||||
return Ok(EvaluatedToAmbig);
|
||||
}
|
||||
ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
|
||||
// THISPR
|
||||
_ => todo!(),
|
||||
// _ => ct.ty(),
|
||||
ty::ConstKind::Value(ty, _) => ty,
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
self.tcx().type_of(uv.def).instantiate(self.tcx(), uv.args)
|
||||
}
|
||||
// FIXME(generic_const_exprs): See comment in `fulfill.rs`
|
||||
ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
|
||||
ty::ConstKind::Placeholder(_) => {
|
||||
bug!("placeholder const {:?} in old solver", ct)
|
||||
}
|
||||
ty::ConstKind::Bound(_, _) => bug!("escaping bound vars in {:?}", ct),
|
||||
ty::ConstKind::Param(param_ct) => {
|
||||
param_ct.find_ty_from_env(obligation.param_env)
|
||||
}
|
||||
};
|
||||
|
||||
match self.infcx.at(&obligation.cause, obligation.param_env).eq(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue