Skip to content

Commit 05a872d

Browse files
committed
wf: {Int,Float}Var can only infer to always-WF ints/floats.
1 parent d1dc2af commit 05a872d

File tree

1 file changed

+8
-2
lines changed
  • src/librustc_trait_selection/traits

1 file changed

+8
-2
lines changed

src/librustc_trait_selection/traits/wf.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn obligations<'a, 'tcx>(
2424
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
2525
// Handle the "livelock" case (see comment above) by bailing out if necessary.
2626
let ty = match ty.kind {
27-
ty::Infer(_) => {
27+
ty::Infer(ty::TyVar(_)) => {
2828
let resolved_ty = infcx.shallow_resolve(ty);
2929
if resolved_ty == ty {
3030
// No progress, bail out to prevent "livelock".
@@ -356,6 +356,12 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
356356
// WfScalar, WfParameter, etc
357357
}
358358

359+
// Can only infer to `ty::Int(_) | ty::Uint(_)`.
360+
ty::Infer(ty::IntVar(_)) => {}
361+
362+
// Can only infer to `ty::Float(_)`.
363+
ty::Infer(ty::FloatVar(_)) => {}
364+
359365
ty::Slice(subty) => {
360366
self.require_sized(subty, traits::SliceOrArrayElem);
361367
}
@@ -514,7 +520,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
514520
// prevention, which happens before this can be reached.
515521
ty::Infer(_) => {
516522
let ty = self.infcx.shallow_resolve(ty);
517-
if let ty::Infer(_) = ty.kind {
523+
if let ty::Infer(ty::TyVar(_)) = ty.kind {
518524
// Not yet resolved, but we've made progress.
519525
let cause = self.cause(traits::MiscObligation);
520526
self.out.push(traits::Obligation::new(

0 commit comments

Comments
 (0)