Skip to content

Commit

Permalink
wf: {Int,Float}Var can only infer to always-WF ints/floats.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 30, 2020
1 parent d1dc2af commit 05a872d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/librustc_trait_selection/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn obligations<'a, 'tcx>(
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
// Handle the "livelock" case (see comment above) by bailing out if necessary.
let ty = match ty.kind {
ty::Infer(_) => {
ty::Infer(ty::TyVar(_)) => {
let resolved_ty = infcx.shallow_resolve(ty);
if resolved_ty == ty {
// No progress, bail out to prevent "livelock".
Expand Down Expand Up @@ -356,6 +356,12 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
// WfScalar, WfParameter, etc
}

// Can only infer to `ty::Int(_) | ty::Uint(_)`.
ty::Infer(ty::IntVar(_)) => {}

// Can only infer to `ty::Float(_)`.
ty::Infer(ty::FloatVar(_)) => {}

ty::Slice(subty) => {
self.require_sized(subty, traits::SliceOrArrayElem);
}
Expand Down Expand Up @@ -514,7 +520,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
// prevention, which happens before this can be reached.
ty::Infer(_) => {
let ty = self.infcx.shallow_resolve(ty);
if let ty::Infer(_) = ty.kind {
if let ty::Infer(ty::TyVar(_)) = ty.kind {
// Not yet resolved, but we've made progress.
let cause = self.cause(traits::MiscObligation);
self.out.push(traits::Obligation::new(
Expand Down

0 comments on commit 05a872d

Please sign in to comment.