Remove notes, increase S/N ratio
This commit is contained in:
parent
63fb294a74
commit
aa7ac6e957
2 changed files with 11 additions and 21 deletions
|
@ -366,24 +366,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
fn if_let_expr_with_parens(&mut self, cond: &Expr, paren: &Expr) {
|
fn if_let_expr_with_parens(&mut self, cond: &Expr, paren: &Expr) {
|
||||||
let start = cond.span.until(paren.span);
|
let start = cond.span.until(paren.span);
|
||||||
let end = paren.span.shrink_to_hi().until(cond.span.shrink_to_hi());
|
let end = paren.span.shrink_to_hi().until(cond.span.shrink_to_hi());
|
||||||
let mut err = self.sess.struct_span_err(
|
self.sess
|
||||||
vec![start, end],
|
.struct_span_err(
|
||||||
"invalid parentheses around `let` expression in `if let`",
|
vec![start, end],
|
||||||
);
|
"invalid parentheses around `let` expression in `if let`",
|
||||||
if self.sess.opts.unstable_features.is_nightly_build() {
|
)
|
||||||
err.note(
|
.multipart_suggestion(
|
||||||
"only supported directly without parentheses in conditions of `if`- and \
|
"`if let` needs to be written without parentheses",
|
||||||
`while`-expressions, as well as in `let` chains within parentheses",
|
vec![(start, String::new()), (end, String::new())],
|
||||||
);
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
} else {
|
)
|
||||||
err.note("variable declaration using `let` is a statement, not a condition");
|
.emit();
|
||||||
}
|
|
||||||
err.multipart_suggestion(
|
|
||||||
"`if let` needs to be written without parentheses",
|
|
||||||
vec![(start, String::new()), (end, String::new())],
|
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
err.emit();
|
|
||||||
// Ideally, we'd remove the feature gating of a `let` expression since we are already
|
// Ideally, we'd remove the feature gating of a `let` expression since we are already
|
||||||
// complaining about it here, but `feature_gate::check_crate` has already run by now:
|
// complaining about it here, but `feature_gate::check_crate` has already run by now:
|
||||||
// self.sess.parse_sess.gated_spans.ungate_last(sym::let_chains, paren.span);
|
// self.sess.parse_sess.gated_spans.ungate_last(sym::let_chains, paren.span);
|
||||||
|
|
|
@ -333,7 +333,6 @@ error: invalid parentheses around `let` expression in `if let`
|
||||||
LL | if (let 0 = 1) {}
|
LL | if (let 0 = 1) {}
|
||||||
| ^ ^
|
| ^ ^
|
||||||
|
|
|
|
||||||
= note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses
|
|
||||||
help: `if let` needs to be written without parentheses
|
help: `if let` needs to be written without parentheses
|
||||||
|
|
|
|
||||||
LL | if let 0 = 1 {}
|
LL | if let 0 = 1 {}
|
||||||
|
@ -345,7 +344,6 @@ error: invalid parentheses around `let` expression in `if let`
|
||||||
LL | if (((let 0 = 1))) {}
|
LL | if (((let 0 = 1))) {}
|
||||||
| ^^^ ^^^
|
| ^^^ ^^^
|
||||||
|
|
|
|
||||||
= note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses
|
|
||||||
help: `if let` needs to be written without parentheses
|
help: `if let` needs to be written without parentheses
|
||||||
|
|
|
|
||||||
LL | if let 0 = 1 {}
|
LL | if let 0 = 1 {}
|
||||||
|
@ -581,7 +579,6 @@ error: invalid parentheses around `let` expression in `if let`
|
||||||
LL | use_expr!((let 0 = 1));
|
LL | use_expr!((let 0 = 1));
|
||||||
| ^ ^
|
| ^ ^
|
||||||
|
|
|
|
||||||
= note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses
|
|
||||||
help: `if let` needs to be written without parentheses
|
help: `if let` needs to be written without parentheses
|
||||||
|
|
|
|
||||||
LL | use_expr!(let 0 = 1);
|
LL | use_expr!(let 0 = 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue