Skip to content

Commit 01a64af

Browse files
committed
lint: port type alias bounds diagnostics
Signed-off-by: David Wood <[email protected]>
1 parent dbced10 commit 01a64af

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,11 @@ lint-builtin-unstable-features = unstable feature
358358
lint-builtin-unreachable-pub = unreachable `pub` {$what}
359359
.suggestion = consider restricting its visibility
360360
.help = or consider exporting it for use by other crates
361+
362+
lint-builtin-type-alias-bounds-help = use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to associated types in type aliases
363+
364+
lint-builtin-type-alias-where-clause = where clauses are not enforced in type aliases
365+
.suggestion = the clause will not be checked when the type alias is used, and should be removed
366+
367+
lint-builtin-type-alias-generic-bounds = bounds on generic parameters are not enforced in type aliases
368+
.suggestion = the bound will not be checked when the type alias is used, and should be removed

compiler/rustc_lint/src/builtin.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,11 +1499,7 @@ impl TypeAliasBounds {
14991499
impl Visitor<'_> for WalkAssocTypes<'_> {
15001500
fn visit_qpath(&mut self, qpath: &hir::QPath<'_>, id: hir::HirId, span: Span) {
15011501
if TypeAliasBounds::is_type_variable_assoc(qpath) {
1502-
self.err.span_help(
1503-
span,
1504-
"use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to \
1505-
associated types in type aliases",
1506-
);
1502+
self.err.span_help(span, fluent::lint::builtin_type_alias_bounds_help);
15071503
}
15081504
intravisit::walk_qpath(self, qpath, id, span)
15091505
}
@@ -1547,11 +1543,11 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
15471543
let mut suggested_changing_assoc_types = false;
15481544
if !where_spans.is_empty() {
15491545
cx.lint(TYPE_ALIAS_BOUNDS, |lint| {
1550-
let mut err = lint.build("where clauses are not enforced in type aliases");
1546+
let mut err = lint.build(fluent::lint::builtin_type_alias_where_clause);
15511547
err.set_span(where_spans);
15521548
err.span_suggestion(
15531549
type_alias_generics.where_clause_span,
1554-
"the clause will not be checked when the type alias is used, and should be removed",
1550+
fluent::lint::suggestion,
15551551
"",
15561552
Applicability::MachineApplicable,
15571553
);
@@ -1565,11 +1561,10 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
15651561

15661562
if !inline_spans.is_empty() {
15671563
cx.lint(TYPE_ALIAS_BOUNDS, |lint| {
1568-
let mut err =
1569-
lint.build("bounds on generic parameters are not enforced in type aliases");
1564+
let mut err = lint.build(fluent::lint::builtin_type_alias_generic_bounds);
15701565
err.set_span(inline_spans);
15711566
err.multipart_suggestion(
1572-
"the bound will not be checked when the type alias is used, and should be removed",
1567+
fluent::lint::suggestion,
15731568
inline_sugg,
15741569
Applicability::MachineApplicable,
15751570
);

0 commit comments

Comments
 (0)