about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-06-03 20:38:10 +0200
committerGitHub <noreply@github.com>2023-06-03 20:38:10 +0200
commit91f222f931796225ded16ffe7d26a6c69e9f52f6 (patch)
treea63f2701c4b05475aea06659323fc4665d9cb53a /compiler/rustc_codegen_llvm/src
parent2f5e6bb817c115c067ff47453eb9aa89a0a31358 (diff)
parent268b08b01bfd95d315c03a9e3a69f254176b2a35 (diff)
downloadrust-91f222f931796225ded16ffe7d26a6c69e9f52f6.tar.gz
rust-91f222f931796225ded16ffe7d26a6c69e9f52f6.zip
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`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions