diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-04-03 15:23:08 +0000 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-04-03 15:25:06 +0000 |
| commit | ca79b82c6cff632c98ed355e7d0f554ef8b5cc5d (patch) | |
| tree | 8c72de4afd01f3cbf4ed0be8904c8426290631ad /tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs | |
| parent | d0eed58a1e78eb1a25bb54076e4b0f7ea5ff7401 (diff) | |
| download | rust-ca79b82c6cff632c98ed355e7d0f554ef8b5cc5d.tar.gz rust-ca79b82c6cff632c98ed355e7d0f554ef8b5cc5d.zip | |
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.
Diffstat (limited to 'tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs')
| -rw-r--r-- | tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs | 10 |
1 files changed, 10 insertions, 0 deletions
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<F: FnPtr> Ord for F` is never considered for int and float infer vars. + 0.0.cmp(); +} |
