about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-01-26 19:02:05 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-01-30 19:07:18 +0000
commit20b1c2aafca8d8861d193d3476ffc8d09c0479e2 (patch)
treeab1bb779e17a76d41312f0c7ff0dcc27f1821fb9 /compiler/rustc_pattern_analysis/src
parentd34b0fa495bfbc3bd7de14a691822706074fcbb6 (diff)
downloadrust-20b1c2aafca8d8861d193d3476ffc8d09c0479e2.tar.gz
rust-20b1c2aafca8d8861d193d3476ffc8d09c0479e2.zip
Account for unbounded type param receiver in suggestions
When encountering

```rust
fn f<T>(a: T, b: T) -> std::cmp::Ordering {
    a.cmp(&b) //~ ERROR E0599
}
```

output

```
error[E0599]: no method named `cmp` found for type parameter `T` in the current scope
  --> $DIR/method-on-unbounded-type-param.rs:2:7
   |
LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering {
   |      - method `cmp` not found for this type parameter
LL |     a.cmp(&b)
   |       ^^^ method cannot be called on `T` due to unsatisfied trait bounds
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix #120186.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions