Skip to content

Commit add4d6b

Browse files
Remove a suggestion that is redundant
1 parent c763f83 commit add4d6b

File tree

6 files changed

+5
-31
lines changed

6 files changed

+5
-31
lines changed

compiler/rustc_hir_typeck/src/_match.rs

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
118118
prior_arm_ty,
119119
prior_arm_span,
120120
scrut_span: scrut.span,
121-
scrut_hir_id: scrut.hir_id,
122121
source: match_src,
123122
prior_non_diverging_arms: prior_non_diverging_arms.clone(),
124123
opt_suggest_box_span,

compiler/rustc_infer/src/infer/error_reporting/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
780780
ref prior_non_diverging_arms,
781781
opt_suggest_box_span,
782782
scrut_span,
783-
scrut_hir_id,
784783
..
785784
}) => match source {
786785
hir::MatchSource::TryDesugar(scrut_hir_id) => {
@@ -848,18 +847,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
848847
) {
849848
err.subdiagnostic(subdiag);
850849
}
851-
if let hir::Node::Expr(m) = self.tcx.parent_hir_node(scrut_hir_id)
852-
&& let hir::Node::Stmt(stmt) = self.tcx.parent_hir_node(m.hir_id)
853-
&& let hir::StmtKind::Expr(_) = stmt.kind
854-
{
855-
err.span_suggestion_verbose(
856-
stmt.span.shrink_to_hi(),
857-
"consider using a semicolon here, but this will discard any values \
858-
in the match arms",
859-
";",
860-
Applicability::MaybeIncorrect,
861-
);
862-
}
863850
if let Some(ret_sp) = opt_suggest_box_span {
864851
// Get return type span and point to it.
865852
self.suggest_boxing_for_return_impl_trait(

compiler/rustc_middle/src/traits/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ pub struct MatchExpressionArmCause<'tcx> {
569569
pub prior_arm_ty: Ty<'tcx>,
570570
pub prior_arm_span: Span,
571571
pub scrut_span: Span,
572-
pub scrut_hir_id: hir::HirId,
573572
pub source: hir::MatchSource,
574573
pub prior_non_diverging_arms: Vec<Span>,
575574
pub opt_suggest_box_span: Option<Span>,

tests/ui/match/dont-highlight-diverging-arms.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ fn main() {
1414

1515
None
1616
};
17-
}
17+
}

tests/ui/match/dont-highlight-diverging-arms.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ LL | | }
1515
|
1616
= note: expected enum `Option<u16>`
1717
found unit type `()`
18-
help: consider using a semicolon here, but this will discard any values in the match arms
19-
|
20-
LL | };
21-
| +
2218

2319
error: aborting due to 1 previous error
2420

tests/ui/suggestions/issue-81839.stderr

+4-11
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,15 @@ error[E0308]: `match` arms have incompatible types
44
LL | / match num {
55
LL | | 1 => {
66
LL | | cx.answer_str("hi");
7-
| | -------------------- this is found to be of type `()`
7+
| | --------------------
8+
| | | |
9+
| | | help: consider removing this semicolon
10+
| | this is found to be of type `()`
811
LL | | }
912
LL | | _ => cx.answer_str("hi"),
1013
| | ^^^^^^^^^^^^^^^^^^^ expected `()`, found future
1114
LL | | }
1215
| |_____- `match` arms have incompatible types
13-
|
14-
help: consider removing this semicolon
15-
|
16-
LL - cx.answer_str("hi");
17-
LL + cx.answer_str("hi")
18-
|
19-
help: consider using a semicolon here, but this will discard any values in the match arms
20-
|
21-
LL | };
22-
| +
2316

2417
error: aborting due to 1 previous error
2518

0 commit comments

Comments
 (0)