Rollup merge of #122799 - estebank:issue-122569, r=fee1-dead

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.
This commit is contained in:
Matthias Krüger 2024-03-21 12:05:08 +01:00 committed by GitHub
commit fb1b198cea

View File

@ -70,7 +70,9 @@ impl LateLintPass<'_> for BoxDefault {
"try",
if is_plain_default(cx, arg_path) || given_type(cx, expr) {
"Box::default()".into()
} else if let Some(arg_ty) = cx.typeck_results().expr_ty(arg).make_suggestable(cx.tcx, true) {
} else if let Some(arg_ty) =
cx.typeck_results().expr_ty(arg).make_suggestable(cx.tcx, true, None)
{
// Check if we can copy from the source expression in the replacement.
// We need the call to have no argument (see `explicit_default_type`).
if inner_call_args.is_empty()