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
|
.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-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 {
|
if let Some((start, end, join)) = endpoints {
|
||||||
let msg = "`...` range patterns are deprecated";
|
let msg = fluent::lint::builtin_ellipsis_inclusive_range_patterns;
|
||||||
let suggestion = "use `..=` for an inclusive range";
|
let suggestion = fluent::lint::suggestion;
|
||||||
if parenthesise {
|
if parenthesise {
|
||||||
self.node_id = Some(pat.id);
|
self.node_id = Some(pat.id);
|
||||||
let end = expr_to_string(&end);
|
let end = expr_to_string(&end);
|
||||||
@ -1785,8 +1785,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||||||
None => format!("&(..={})", end),
|
None => format!("&(..={})", end),
|
||||||
};
|
};
|
||||||
if join.edition() >= Edition::Edition2021 {
|
if join.edition() >= Edition::Edition2021 {
|
||||||
let mut err =
|
let mut err = cx.sess().struct_span_err_with_code(
|
||||||
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
pat.span,
|
||||||
|
msg,
|
||||||
|
rustc_errors::error_code!(E0783),
|
||||||
|
);
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
pat.span,
|
pat.span,
|
||||||
suggestion,
|
suggestion,
|
||||||
@ -1809,8 +1812,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||||||
} else {
|
} else {
|
||||||
let replace = "..=";
|
let replace = "..=";
|
||||||
if join.edition() >= Edition::Edition2021 {
|
if join.edition() >= Edition::Edition2021 {
|
||||||
let mut err =
|
let mut err = cx.sess().struct_span_err_with_code(
|
||||||
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
pat.span,
|
||||||
|
msg,
|
||||||
|
rustc_errors::error_code!(E0783),
|
||||||
|
);
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
join,
|
join,
|
||||||
suggestion,
|
suggestion,
|
||||||
|
Loading…
Reference in New Issue
Block a user