diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-01-26 19:02:05 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-01-30 19:07:18 +0000 |
| commit | 20b1c2aafca8d8861d193d3476ffc8d09c0479e2 (patch) | |
| tree | ab1bb779e17a76d41312f0c7ff0dcc27f1821fb9 /compiler/rustc_pattern_analysis/src | |
| parent | d34b0fa495bfbc3bd7de14a691822706074fcbb6 (diff) | |
| download | rust-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
