Make diangostic item names consistent

This commit is contained in:
Cameron Steffen 2021-10-02 18:51:01 -05:00
parent f03eb6bef8
commit eec856bfbc
123 changed files with 244 additions and 248 deletions

View file

@ -812,7 +812,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
_ => return,
}
let debug = match cx.tcx.get_diagnostic_item(sym::debug_trait) {
let debug = match cx.tcx.get_diagnostic_item(sym::Debug) {
Some(debug) => debug,
None => return,
};

View file

@ -33,9 +33,9 @@ impl LateLintPass<'_> for DefaultHashTypes {
// don't lint imports, only actual usages
return;
}
let replace = if cx.tcx.is_diagnostic_item(sym::hashmap_type, def_id) {
let replace = if cx.tcx.is_diagnostic_item(sym::HashMap, def_id) {
"FxHashMap"
} else if cx.tcx.is_diagnostic_item(sym::hashset_type, def_id) {
} else if cx.tcx.is_diagnostic_item(sym::HashSet, def_id) {
"FxHashSet"
} else {
return;

View file

@ -84,7 +84,7 @@ fn lint_cstring_as_ptr(
) {
let source_type = cx.typeck_results().expr_ty(source);
if let ty::Adt(def, substs) = source_type.kind() {
if cx.tcx.is_diagnostic_item(sym::result_type, def.did) {
if cx.tcx.is_diagnostic_item(sym::Result, def.did) {
if let ty::Adt(adt, _) = substs.type_at(0).kind() {
if cx.tcx.is_diagnostic_item(sym::cstring_type, adt.did) {
cx.struct_span_lint(TEMPORARY_CSTRING_AS_PTR, as_ptr_span, |diag| {

View file

@ -130,14 +130,14 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
ty::Ref(_, r, _) if *r.kind() == ty::Str,
) || matches!(
ty.ty_adt_def(),
Some(ty_def) if cx.tcx.is_diagnostic_item(sym::string_type, ty_def.did),
Some(ty_def) if cx.tcx.is_diagnostic_item(sym::String, ty_def.did),
);
let (suggest_display, suggest_debug) = cx.tcx.infer_ctxt().enter(|infcx| {
let display = is_str || cx.tcx.get_diagnostic_item(sym::display_trait).map(|t| {
let display = is_str || cx.tcx.get_diagnostic_item(sym::Display).map(|t| {
infcx.type_implements_trait(t, ty, InternalSubsts::empty(), cx.param_env).may_apply()
}) == Some(true);
let debug = !display && cx.tcx.get_diagnostic_item(sym::debug_trait).map(|t| {
let debug = !display && cx.tcx.get_diagnostic_item(sym::Debug).map(|t| {
infcx.type_implements_trait(t, ty, InternalSubsts::empty(), cx.param_env).may_apply()
}) == Some(true);
(display, debug)