rust/tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.rs
Esteban Küber 89a3c19832 Be more lax in .into_iter() suggestion when encountering Iterator methods on non-Iterator
```
error[E0599]: no method named `map` found for struct `Vec<bool>` in the current scope
  --> $DIR/vec-on-unimplemented.rs:3:23
   |
LL |     vec![true, false].map(|v| !v).collect::<Vec<_>>();
   |                       ^^^ `Vec<bool>` is not an iterator
   |
help: call `.into_iter()` first
   |
LL |     vec![true, false].into_iter().map(|v| !v).collect::<Vec<_>>();
   |                       ++++++++++++
```

We used to provide some help through `rustc_on_unimplemented` on non-`impl Trait` and non-type-params, but this lets us get rid of some otherwise unnecessary conditions in the annotation on `Iterator`.
2024-03-03 18:53:36 +00:00

23 lines
688 B
Rust

//@ aux-build:issue-104884.rs
use std::collections::BinaryHeap;
#[macro_use]
extern crate issue_104884;
#[derive(PartialEq, Eq, PartialOrd, Ord)]
struct PriorityQueueEntry<T> {
value: T,
}
#[derive(PartialOrd, AddImpl)]
//~^ ERROR can't compare `PriorityQueue<T>` with `PriorityQueue<T>`
//~| ERROR the trait bound `PriorityQueue<T>: Eq` is not satisfied
//~| ERROR can't compare `T` with `T`
//~| ERROR no method named `cmp` found for struct `BinaryHeap<PriorityQueueEntry<T>>`
//~| ERROR no field `height` on type `&PriorityQueue<T>`
struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
//~^ ERROR can't compare `BinaryHeap<PriorityQueueEntry<T>>` with `_`
fn main() {}