Skip to content

Commit

Permalink
check for inferred params in a clearer way
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Jun 13, 2022
1 parent 451e030 commit dc2977e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

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

0 comments on commit dc2977e

Please sign in to comment.