Use non-short suggestion for parenthesised ..=
This commit is contained in:
parent
c148714549
commit
c63df7c64f
@ -1432,20 +1432,26 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P<Expr>, &P<Expr>, Span)> {
|
||||
if let Some((start, end, join)) = endpoints {
|
||||
let msg = "`...` range patterns are deprecated";
|
||||
let suggestion = "use `..=` for an inclusive range";
|
||||
let (span, replacement) = if parenthesise {
|
||||
if parenthesise {
|
||||
*visit_subpats = false;
|
||||
(pat.span, format!("&({}..={})", expr_to_string(&start), expr_to_string(&end)))
|
||||
} else {
|
||||
(join, "..=".to_owned())
|
||||
};
|
||||
let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, span, msg);
|
||||
err.span_suggestion_short_with_applicability(
|
||||
span,
|
||||
let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, msg);
|
||||
err.span_suggestion_with_applicability(
|
||||
pat.span,
|
||||
suggestion,
|
||||
replacement,
|
||||
format!("&({}..={})", expr_to_string(&start), expr_to_string(&end)),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
} else {
|
||||
let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, msg);
|
||||
err.span_suggestion_short_with_applicability(
|
||||
join,
|
||||
suggestion,
|
||||
"..=".to_owned(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ warning: `...` range patterns are deprecated
|
||||
--> $DIR/inclusive-range-pattern-syntax.rs:25:9
|
||||
|
|
||||
LL | &1...2 => {}
|
||||
| ^^^^^^ help: use `..=` for an inclusive range
|
||||
| ^^^^^^ help: use `..=` for an inclusive range: `&(1..=2)`
|
||||
|
||||
|
@ -14,7 +14,7 @@ warning: `...` range patterns are deprecated
|
||||
--> $DIR/range-inclusive-pattern-precedence.rs:24:9
|
||||
|
|
||||
LL | &0...9 => {}
|
||||
| ^^^^^^ help: use `..=` for an inclusive range
|
||||
| ^^^^^^ help: use `..=` for an inclusive range: `&(0..=9)`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/range-inclusive-pattern-precedence.rs:19:9
|
||||
|
Loading…
Reference in New Issue
Block a user