Skip to content

Commit dc2977e

Browse files
committed
check for inferred params in a clearer way
1 parent 451e030 commit dc2977e

File tree

1 file changed

+3
-1
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+3
-1
lines changed

compiler/rustc_typeck/src/check/pat.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
664664
};
665665

666666
match binding_parent {
667-
hir::Node::Param(hir::Param { ty_span, .. }) if binding.span.hi() <= ty_span.lo() => {
667+
// Check that there is explicit type (ie this is not a closure param with inferred type)
668+
// so we don't suggest moving something to the type that does not exist
669+
hir::Node::Param(hir::Param { ty_span, .. }) if binding.span != *ty_span => {
668670
err.multipart_suggestion_verbose(
669671
format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"),
670672
vec![

0 commit comments

Comments
 (0)