rust/tests/ui/traits/suggest-fully-qualified-closure.rs
Esteban Küber 5fae665924 Replace closures with _ when suggesting fully qualified path for method call
```
error[E0283]: type annotations needed
  --> $DIR/into-inference-needs-type.rs:12:10
   |
LL |         .into()?;
   |          ^^^^
   |
   = note: cannot satisfy `_: From<...>`
   = note: required for `FilterMap<...>` to implement `Into<_>`
help: try using a fully qualified path to specify the expected types
   |
LL ~     let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec
LL |         .iter()
LL |         .map(|s| s.strip_prefix("t"))
LL ~         .filter_map(Option::Some))?;
   |
```

Fix #122569.
2024-03-21 00:07:44 +00:00

23 lines
402 B
Rust

//@ check-fail
//@ known-bug: #103705
// The output of this currently suggests writing a closure in the qualified path.
trait MyTrait<T> {
fn lol<F:FnOnce()>(&self, f:F) -> u16;
}
struct Qqq;
impl MyTrait<u32> for Qqq{
fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 5 }
}
impl MyTrait<u64> for Qqq{
fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 6 }
}
fn main() {
let q = Qqq;
q.lol(||());
}