Skip to content

Commit aa7ac6e

Browse files
committed
Remove notes, increase S/N ratio
1 parent 63fb294 commit aa7ac6e

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+11-18
Original file line numberDiff line numberDiff line change
@@ -366,24 +366,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
366366
fn if_let_expr_with_parens(&mut self, cond: &Expr, paren: &Expr) {
367367
let start = cond.span.until(paren.span);
368368
let end = paren.span.shrink_to_hi().until(cond.span.shrink_to_hi());
369-
let mut err = self.sess.struct_span_err(
370-
vec![start, end],
371-
"invalid parentheses around `let` expression in `if let`",
372-
);
373-
if self.sess.opts.unstable_features.is_nightly_build() {
374-
err.note(
375-
"only supported directly without parentheses in conditions of `if`- and \
376-
`while`-expressions, as well as in `let` chains within parentheses",
377-
);
378-
} else {
379-
err.note("variable declaration using `let` is a statement, not a condition");
380-
}
381-
err.multipart_suggestion(
382-
"`if let` needs to be written without parentheses",
383-
vec![(start, String::new()), (end, String::new())],
384-
rustc_errors::Applicability::MachineApplicable,
385-
);
386-
err.emit();
369+
self.sess
370+
.struct_span_err(
371+
vec![start, end],
372+
"invalid parentheses around `let` expression in `if let`",
373+
)
374+
.multipart_suggestion(
375+
"`if let` needs to be written without parentheses",
376+
vec![(start, String::new()), (end, String::new())],
377+
rustc_errors::Applicability::MachineApplicable,
378+
)
379+
.emit();
387380
// Ideally, we'd remove the feature gating of a `let` expression since we are already
388381
// complaining about it here, but `feature_gate::check_crate` has already run by now:
389382
// self.sess.parse_sess.gated_spans.ungate_last(sym::let_chains, paren.span);

src/test/ui/rfc-2497-if-let-chains/feature-gate.stderr

-3
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ error: invalid parentheses around `let` expression in `if let`
333333
LL | if (let 0 = 1) {}
334334
| ^ ^
335335
|
336-
= note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses
337336
help: `if let` needs to be written without parentheses
338337
|
339338
LL | if let 0 = 1 {}
@@ -345,7 +344,6 @@ error: invalid parentheses around `let` expression in `if let`
345344
LL | if (((let 0 = 1))) {}
346345
| ^^^ ^^^
347346
|
348-
= note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses
349347
help: `if let` needs to be written without parentheses
350348
|
351349
LL | if let 0 = 1 {}
@@ -581,7 +579,6 @@ error: invalid parentheses around `let` expression in `if let`
581579
LL | use_expr!((let 0 = 1));
582580
| ^ ^
583581
|
584-
= note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses
585582
help: `if let` needs to be written without parentheses
586583
|
587584
LL | use_expr!(let 0 = 1);

0 commit comments

Comments
 (0)