lint: port default hash types diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
fd57269e8c
commit
e88916cc92
@ -28,3 +28,6 @@ lint-hidden-unicode-codepoints = unicode codepoint changing visible direction of
|
|||||||
.suggestion-remove = if their presence wasn't intentional, you can remove them
|
.suggestion-remove = if their presence wasn't intentional, you can remove them
|
||||||
.suggestion-escape = if you want to keep them but make them visible in your source code, you can escape them
|
.suggestion-escape = if you want to keep them but make them visible in your source code, you can escape them
|
||||||
.no-suggestion-note-escape = if you want to keep them but make them visible in your source code, you can escape them: {$escaped}
|
.no-suggestion-note-escape = if you want to keep them but make them visible in your source code, you can escape them: {$escaped}
|
||||||
|
|
||||||
|
lint-default-hash-types = prefer `{$preferred}` over `{$used}`, it has better performance
|
||||||
|
.note = a `use rustc_data_structures::fx::{$preferred}` may be necessary
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::{fluent, Applicability};
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
use rustc_hir::{def_id::DefId, Expr, ExprKind, GenericArg, PatKind, Path, PathSegment, QPath};
|
use rustc_hir::{def_id::DefId, Expr, ExprKind, GenericArg, PatKind, Path, PathSegment, QPath};
|
||||||
use rustc_hir::{HirId, Impl, Item, ItemKind, Node, Pat, Ty, TyKind};
|
use rustc_hir::{HirId, Impl, Item, ItemKind, Node, Pat, Ty, TyKind};
|
||||||
@ -36,13 +36,10 @@ impl LateLintPass<'_> for DefaultHashTypes {
|
|||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
cx.struct_span_lint(DEFAULT_HASH_TYPES, path.span, |lint| {
|
cx.struct_span_lint(DEFAULT_HASH_TYPES, path.span, |lint| {
|
||||||
let msg = format!(
|
lint.build(fluent::lint::default_hash_types)
|
||||||
"prefer `{}` over `{}`, it has better performance",
|
.set_arg("preferred", replace)
|
||||||
replace,
|
.set_arg("used", cx.tcx.item_name(def_id))
|
||||||
cx.tcx.item_name(def_id)
|
.note(fluent::lint::note)
|
||||||
);
|
|
||||||
lint.build(&msg)
|
|
||||||
.note(&format!("a `use rustc_data_structures::fx::{}` may be necessary", replace))
|
|
||||||
.emit();
|
.emit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user