From 977694aaec6dce9b03979cbe1b146352502c2e33 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 30 Mar 2023 01:10:48 +0000 Subject: [PATCH] canonicalize float var as float in new solver --- compiler/rustc_trait_selection/src/solve/canonicalize.rs | 2 +- tests/ui/traits/new-solver/float-canonical.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/ui/traits/new-solver/float-canonical.rs diff --git a/compiler/rustc_trait_selection/src/solve/canonicalize.rs b/compiler/rustc_trait_selection/src/solve/canonicalize.rs index 7ee4f332306..2e5a8b7debc 100644 --- a/compiler/rustc_trait_selection/src/solve/canonicalize.rs +++ b/compiler/rustc_trait_selection/src/solve/canonicalize.rs @@ -291,7 +291,7 @@ impl<'tcx> TypeFolder> for Canonicalizer<'_, 'tcx> { if nt != t { return self.fold_ty(nt); } else { - CanonicalVarKind::Ty(CanonicalTyVarKind::Int) + CanonicalVarKind::Ty(CanonicalTyVarKind::Float) } } ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { diff --git a/tests/ui/traits/new-solver/float-canonical.rs b/tests/ui/traits/new-solver/float-canonical.rs new file mode 100644 index 00000000000..b8748cd433b --- /dev/null +++ b/tests/ui/traits/new-solver/float-canonical.rs @@ -0,0 +1,8 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn foo(x: f64) { + let y = x + 1.0; +} + +fn main() {}