Skip to content

Commit 22462af

Browse files
committed
fix: another missing verify of whether self is callee
1 parent af6b300 commit 22462af

File tree

3 files changed

+525
-527
lines changed

3 files changed

+525
-527
lines changed

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,10 @@ fn report_unexpected_variant_res(
422422
let mut suggestion = vec![];
423423
match tcx.parent_hir_node(expr.hir_id) {
424424
hir::Node::Expr(hir::Expr {
425-
kind: hir::ExprKind::Call(..),
425+
kind: hir::ExprKind::Call(callee, ..),
426426
span: call_span,
427427
..
428-
}) => {
428+
}) if callee.hir_id == expr.hir_id => {
429429
suggestion.push((span.shrink_to_hi().with_hi(call_span.hi()), sugg));
430430
}
431431
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Binary(..), hir_id, .. }) => {

tests/ui/suggestions/incorrect-variant-in-arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn foo(_: Enum) {}
1414
fn main() {
1515
foo(Enum::Unit);
1616
foo(Enum::Tuple);
17-
foo(Enum::Struct); // Highlight is wrong and suggestion is malformed
17+
foo(Enum::Struct); // Suggestion was malformed
1818
foo(Enum::Unit());
1919
foo(Enum::Tuple());
2020
foo(Enum::Struct());

0 commit comments

Comments
 (0)