mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
lint: port ...
range pattern diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
3c9bda5b20
commit
3a498a7436
@ -368,3 +368,6 @@ lint-builtin-type-alias-generic-bounds = bounds on generic parameters are not en
|
||||
.suggestion = the bound will not be checked when the type alias is used, and should be removed
|
||||
|
||||
lint-builtin-trivial-bounds = {$predicate_kind_name} bound {$predicate} does not depend on any type or lifetime parameters
|
||||
|
||||
lint-builtin-ellipsis-inclusive-range-patterns = `...` range patterns are deprecated
|
||||
.suggestion = use `..=` for an inclusive range
|
||||
|
@ -1775,8 +1775,8 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
};
|
||||
|
||||
if let Some((start, end, join)) = endpoints {
|
||||
let msg = "`...` range patterns are deprecated";
|
||||
let suggestion = "use `..=` for an inclusive range";
|
||||
let msg = fluent::lint::builtin_ellipsis_inclusive_range_patterns;
|
||||
let suggestion = fluent::lint::suggestion;
|
||||
if parenthesise {
|
||||
self.node_id = Some(pat.id);
|
||||
let end = expr_to_string(&end);
|
||||
@ -1785,8 +1785,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
None => format!("&(..={})", end),
|
||||
};
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err =
|
||||
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
||||
let mut err = cx.sess().struct_span_err_with_code(
|
||||
pat.span,
|
||||
msg,
|
||||
rustc_errors::error_code!(E0783),
|
||||
);
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
suggestion,
|
||||
@ -1809,8 +1812,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
} else {
|
||||
let replace = "..=";
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err =
|
||||
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
||||
let mut err = cx.sess().struct_span_err_with_code(
|
||||
pat.span,
|
||||
msg,
|
||||
rustc_errors::error_code!(E0783),
|
||||
);
|
||||
err.span_suggestion_short(
|
||||
join,
|
||||
suggestion,
|
||||
|
Loading…
Reference in New Issue
Block a user