lint: port type alias bounds diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
dbced105db
commit
01a64af4dd
2 changed files with 13 additions and 10 deletions
|
@ -358,3 +358,11 @@ lint-builtin-unstable-features = unstable feature
|
|||
lint-builtin-unreachable-pub = unreachable `pub` {$what}
|
||||
.suggestion = consider restricting its visibility
|
||||
.help = or consider exporting it for use by other crates
|
||||
|
||||
lint-builtin-type-alias-bounds-help = use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to associated types in type aliases
|
||||
|
||||
lint-builtin-type-alias-where-clause = where clauses are not enforced in type aliases
|
||||
.suggestion = the clause will not be checked when the type alias is used, and should be removed
|
||||
|
||||
lint-builtin-type-alias-generic-bounds = bounds on generic parameters are not enforced in type aliases
|
||||
.suggestion = the bound will not be checked when the type alias is used, and should be removed
|
||||
|
|
|
@ -1499,11 +1499,7 @@ impl TypeAliasBounds {
|
|||
impl Visitor<'_> for WalkAssocTypes<'_> {
|
||||
fn visit_qpath(&mut self, qpath: &hir::QPath<'_>, id: hir::HirId, span: Span) {
|
||||
if TypeAliasBounds::is_type_variable_assoc(qpath) {
|
||||
self.err.span_help(
|
||||
span,
|
||||
"use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to \
|
||||
associated types in type aliases",
|
||||
);
|
||||
self.err.span_help(span, fluent::lint::builtin_type_alias_bounds_help);
|
||||
}
|
||||
intravisit::walk_qpath(self, qpath, id, span)
|
||||
}
|
||||
|
@ -1547,11 +1543,11 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
|
|||
let mut suggested_changing_assoc_types = false;
|
||||
if !where_spans.is_empty() {
|
||||
cx.lint(TYPE_ALIAS_BOUNDS, |lint| {
|
||||
let mut err = lint.build("where clauses are not enforced in type aliases");
|
||||
let mut err = lint.build(fluent::lint::builtin_type_alias_where_clause);
|
||||
err.set_span(where_spans);
|
||||
err.span_suggestion(
|
||||
type_alias_generics.where_clause_span,
|
||||
"the clause will not be checked when the type alias is used, and should be removed",
|
||||
fluent::lint::suggestion,
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
@ -1565,11 +1561,10 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
|
|||
|
||||
if !inline_spans.is_empty() {
|
||||
cx.lint(TYPE_ALIAS_BOUNDS, |lint| {
|
||||
let mut err =
|
||||
lint.build("bounds on generic parameters are not enforced in type aliases");
|
||||
let mut err = lint.build(fluent::lint::builtin_type_alias_generic_bounds);
|
||||
err.set_span(inline_spans);
|
||||
err.multipart_suggestion(
|
||||
"the bound will not be checked when the type alias is used, and should be removed",
|
||||
fluent::lint::suggestion,
|
||||
inline_sugg,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue