From ca79b82c6cff632c98ed355e7d0f554ef8b5cc5d Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:23:08 +0000 Subject: Never consider int and float vars for `FnPtr` candidates This solves a regression where `0.0.cmp()` was ambiguous when a custom trait with a `cmp` method was in scope. FOr integers it shouldn't be a problem in practice so I wasn't able to add a test. --- tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs (limited to 'tests') diff --git a/tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs b/tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs new file mode 100644 index 00000000000..eec7da044c0 --- /dev/null +++ b/tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs @@ -0,0 +1,10 @@ +// check-pass +trait MyCmp { + fn cmp(&self) {} +} +impl MyCmp for f32 {} + +fn main() { + // Ensure that `impl Ord for F` is never considered for int and float infer vars. + 0.0.cmp(); +} -- cgit 1.4.1-3-g733a5