about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-04-24 15:57:36 -0700
committerTyler Mandry <tmandry@gmail.com>2019-04-24 15:57:43 -0700
commit56ab3e70e7eeeaa9801c1e32c2a459df8dfc4ab8 (patch)
treecc9c326306072864c32e0f6b5aa63d0bf534b51c
parentc75e0890beade386ff15acdcc1028497094cd867 (diff)
downloadrust-56ab3e70e7eeeaa9801c1e32c2a459df8dfc4ab8.tar.gz
rust-56ab3e70e7eeeaa9801c1e32c2a459df8dfc4ab8.zip
Add builtin impls for int and float inference vars in chalk
-rw-r--r--src/librustc_traits/chalk_context/program_clauses/builtin.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/librustc_traits/chalk_context/program_clauses/builtin.rs b/src/librustc_traits/chalk_context/program_clauses/builtin.rs
index 0c6e65d405a..27af8511915 100644
--- a/src/librustc_traits/chalk_context/program_clauses/builtin.rs
+++ b/src/librustc_traits/chalk_context/program_clauses/builtin.rs
@@ -137,6 +137,8 @@ crate fn assemble_builtin_sized_impls<'tcx>(
         ty::Int(..) |
         ty::Uint(..) |
         ty::Float(..) |
+        ty::Infer(ty::IntVar(_)) |
+        ty::Infer(ty::FloatVar(_)) |
         ty::Error |
         ty::Never => push_builtin_impl(ty, &[]),
 
@@ -188,14 +190,11 @@ crate fn assemble_builtin_sized_impls<'tcx>(
             push_builtin_impl(adt, &sized_constraint);
         }
 
-        // Artificially trigger an ambiguity.
-        ty::Infer(..) => {
-            // Everybody can find at least two types to unify against:
-            // general ty vars, int vars and float vars.
+        // Artificially trigger an ambiguity by adding two possible types to
+        // unify against.
+        ty::Infer(ty::TyVar(_)) => {
             push_builtin_impl(tcx.types.i32, &[]);
-            push_builtin_impl(tcx.types.u32, &[]);
             push_builtin_impl(tcx.types.f32, &[]);
-            push_builtin_impl(tcx.types.f64, &[]);
         }
 
         ty::Projection(_projection_ty) => {
@@ -216,7 +215,10 @@ crate fn assemble_builtin_sized_impls<'tcx>(
         ty::Opaque(..) => (),
 
         ty::Bound(..) |
-        ty::GeneratorWitness(..) => bug!("unexpected type {:?}", ty),
+        ty::GeneratorWitness(..) |
+        ty::Infer(ty::FreshTy(_)) |
+        ty::Infer(ty::FreshIntTy(_)) |
+        ty::Infer(ty::FreshFloatTy(_)) => bug!("unexpected type {:?}", ty),
     }
 }
 
@@ -243,7 +245,9 @@ crate fn assemble_builtin_copy_clone_impls<'tcx>(
         ty::Never |
         ty::Ref(_, _, hir::MutImmutable) => (),
 
-        // Non parametric primitive type.
+        // Non parametric primitive types.
+        ty::Infer(ty::IntVar(_)) |
+        ty::Infer(ty::FloatVar(_)) |
         ty::Error => push_builtin_impl(ty, &[]),
 
         // These implement `Copy`/`Clone` if their element types do.
@@ -283,13 +287,11 @@ crate fn assemble_builtin_copy_clone_impls<'tcx>(
         // These depend on whatever user-defined impls might exist.
         ty::Adt(_, _) => (),
 
-        // int vars and float vars are always `Copy`.
-        // Other vars will trigger an ambiguity.
-        ty::Infer(..) => {
+        // Artificially trigger an ambiguity by adding two possible types to
+        // unify against.
+        ty::Infer(ty::TyVar(_)) => {
             push_builtin_impl(tcx.types.i32, &[]);
-            push_builtin_impl(tcx.types.u32, &[]);
             push_builtin_impl(tcx.types.f32, &[]);
-            push_builtin_impl(tcx.types.f64, &[]);
         }
 
         ty::Projection(_projection_ty) => {
@@ -312,6 +314,9 @@ crate fn assemble_builtin_copy_clone_impls<'tcx>(
         ty::Ref(_, _, hir::MutMutable) => (),
 
         ty::Bound(..) |
-        ty::GeneratorWitness(..) => bug!("unexpected type {:?}", ty),
+        ty::GeneratorWitness(..) |
+        ty::Infer(ty::FreshTy(_)) |
+        ty::Infer(ty::FreshIntTy(_)) |
+        ty::Infer(ty::FreshFloatTy(_)) => bug!("unexpected type {:?}", ty),
     }
 }