Skip to content

Commit 0404a5d

Browse files
committed
do it for new solver too
1 parent 0ba3509 commit 0404a5d

File tree

1 file changed

+21
-2
lines changed
  • compiler/rustc_trait_selection/src/solve

1 file changed

+21
-2
lines changed

compiler/rustc_trait_selection/src/solve/mod.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,27 @@ impl<'a, 'tcx> EvalCtxt<'a, InferCtxt<'tcx>> {
197197
goal: Goal<'tcx, (ty::Const<'tcx>, Ty<'tcx>)>,
198198
) -> QueryResult<'tcx> {
199199
let (ct, ty) = goal.predicate;
200-
self.eq(goal.param_env, ct.ty(), ty)?;
201-
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
200+
201+
// FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant
202+
// other than `ConstKind::Value`. Unfortunately this would require looking in the
203+
// env for any `ConstArgHasType` assumptions for parameters and placeholders. I
204+
// have not yet gotten around to implementing this though.
205+
//
206+
// We do still stall on infer vars though as otherwise a goal like:
207+
// `ConstArgHasType(?x: usize, usize)` can succeed even though it might later
208+
// get unified with some const that is not of type `usize`.
209+
match ct.kind() {
210+
ty::ConstKind::Infer(_) => {
211+
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
212+
}
213+
ty::ConstKind::Error(_) => {
214+
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
215+
}
216+
_ => {
217+
self.eq(goal.param_env, ct.ty(), ty)?;
218+
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
219+
}
220+
}
202221
}
203222
}
204223

0 commit comments

Comments
 (0)