Files
rust/compiler
Matthias Krüger 91f222f931 Rollup merge of #111659 - y21:suggest-as-deref, r=cjgillot
suggest `Option::as_deref(_mut)` on type mismatch in option combinator if it passes typeck

Fixes #106342.
This adds a suggestion to call `.as_deref()` (or `.as_deref_mut()` resp.) if typeck fails due to a type mismatch in the function passed to an `Option` combinator such as `.map()` or `.and_then()`.
For example:
```rs
fn foo(_: &str) {}
Some(String::new()).map(foo);
```
The `.map()` method requires its argument to satisfy `F: FnOnce(String)`, but it received `fn(&str)`, which won't pass. However, placing a `.as_deref()` before the `.map()` call fixes this since `&str == &<String as Deref>::Target`
2023-06-03 20:38:10 +02:00
..
2023-03-11 10:53:47 -06:00
2023-06-03 09:44:30 +08:00
2023-05-02 10:45:16 -07:00
2023-06-03 09:44:30 +08:00
2023-05-26 15:18:54 -04:00
2023-04-10 17:24:23 +09:00
2023-04-10 22:02:52 +02:00
2023-05-26 13:03:47 +03:00
2023-05-26 18:55:02 +01:00