Skip to content

Commit 3a498a7

Browse files
committed
lint: port ... range pattern diagnostics
Signed-off-by: David Wood <[email protected]>
1 parent 3c9bda5 commit 3a498a7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

compiler/rustc_error_messages/locales/en-US/lint.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,6 @@ lint-builtin-type-alias-generic-bounds = bounds on generic parameters are not en
368368
.suggestion = the bound will not be checked when the type alias is used, and should be removed
369369
370370
lint-builtin-trivial-bounds = {$predicate_kind_name} bound {$predicate} does not depend on any type or lifetime parameters
371+
372+
lint-builtin-ellipsis-inclusive-range-patterns = `...` range patterns are deprecated
373+
.suggestion = use `..=` for an inclusive range

compiler/rustc_lint/src/builtin.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,8 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
17751775
};
17761776

17771777
if let Some((start, end, join)) = endpoints {
1778-
let msg = "`...` range patterns are deprecated";
1779-
let suggestion = "use `..=` for an inclusive range";
1778+
let msg = fluent::lint::builtin_ellipsis_inclusive_range_patterns;
1779+
let suggestion = fluent::lint::suggestion;
17801780
if parenthesise {
17811781
self.node_id = Some(pat.id);
17821782
let end = expr_to_string(&end);
@@ -1785,8 +1785,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
17851785
None => format!("&(..={})", end),
17861786
};
17871787
if join.edition() >= Edition::Edition2021 {
1788-
let mut err =
1789-
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
1788+
let mut err = cx.sess().struct_span_err_with_code(
1789+
pat.span,
1790+
msg,
1791+
rustc_errors::error_code!(E0783),
1792+
);
17901793
err.span_suggestion(
17911794
pat.span,
17921795
suggestion,
@@ -1809,8 +1812,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
18091812
} else {
18101813
let replace = "..=";
18111814
if join.edition() >= Edition::Edition2021 {
1812-
let mut err =
1813-
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
1815+
let mut err = cx.sess().struct_span_err_with_code(
1816+
pat.span,
1817+
msg,
1818+
rustc_errors::error_code!(E0783),
1819+
);
18141820
err.span_suggestion_short(
18151821
join,
18161822
suggestion,

0 commit comments

Comments
 (0)