diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-04-03 01:01:30 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-04-30 23:01:26 +0300 |
| commit | 05a872df2ba4942f86141bfdbefd171eb419a3cc (patch) | |
| tree | 47dc9a1bd97ac1d6b0848608f70c47a7b511af4b /src | |
| parent | d1dc2afd05a0f501512d9ed24f2d1785f7228eba (diff) | |
| download | rust-05a872df2ba4942f86141bfdbefd171eb419a3cc.tar.gz rust-05a872df2ba4942f86141bfdbefd171eb419a3cc.zip | |
wf: {Int,Float}Var can only infer to always-WF ints/floats.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trait_selection/traits/wf.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index d11a3e61c65..1d4afeaae42 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -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". @@ -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); } @@ -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( |
