Make diangostic item names consistent
This commit is contained in:
parent
f03eb6bef8
commit
eec856bfbc
123 changed files with 244 additions and 248 deletions
|
@ -966,8 +966,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
_ => None,
|
||||
});
|
||||
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
|
||||
tcx.is_diagnostic_item(sym::option_type, def_id)
|
||||
|| tcx.is_diagnostic_item(sym::result_type, def_id)
|
||||
tcx.is_diagnostic_item(sym::Option, def_id)
|
||||
|| tcx.is_diagnostic_item(sym::Result, def_id)
|
||||
});
|
||||
FnSelfUseKind::Normal { self_arg, implicit_into_iter, is_option_or_result }
|
||||
});
|
||||
|
|
|
@ -400,8 +400,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
| ty::Opaque(def_id, _) => def_id,
|
||||
_ => return err,
|
||||
};
|
||||
let is_option = self.infcx.tcx.is_diagnostic_item(sym::option_type, def_id);
|
||||
let is_result = self.infcx.tcx.is_diagnostic_item(sym::result_type, def_id);
|
||||
let is_option = self.infcx.tcx.is_diagnostic_item(sym::Option, def_id);
|
||||
let is_result = self.infcx.tcx.is_diagnostic_item(sym::Result, def_id);
|
||||
if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) {
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_hi(),
|
||||
|
|
|
@ -2533,7 +2533,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
/// within `?` desugaring.
|
||||
pub fn is_try_conversion(&self, span: Span, trait_def_id: DefId) -> bool {
|
||||
span.is_desugaring(DesugaringKind::QuestionMark)
|
||||
&& self.tcx.is_diagnostic_item(sym::from_trait, trait_def_id)
|
||||
&& self.tcx.is_diagnostic_item(sym::From, trait_def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -133,7 +133,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
|
|||
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
||||
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
||||
if let ty::PredicateKind::Trait(predicate) = bound {
|
||||
if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) {
|
||||
if self.tcx.is_diagnostic_item(sym::Pointer, predicate.def_id()) {
|
||||
Some(predicate.trait_ref.self_ty())
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -169,6 +169,7 @@ symbols! {
|
|||
Default,
|
||||
Deref,
|
||||
DirBuilder,
|
||||
Display,
|
||||
DoubleEndedIterator,
|
||||
Duration,
|
||||
Encodable,
|
||||
|
@ -194,6 +195,7 @@ symbols! {
|
|||
Hasher,
|
||||
Implied,
|
||||
Input,
|
||||
Into,
|
||||
IntoIterator,
|
||||
IoRead,
|
||||
IoWrite,
|
||||
|
@ -204,6 +206,7 @@ symbols! {
|
|||
Left,
|
||||
LinkedList,
|
||||
LintPass,
|
||||
Mutex,
|
||||
None,
|
||||
Ok,
|
||||
Option,
|
||||
|
@ -219,6 +222,7 @@ symbols! {
|
|||
PathBuf,
|
||||
Pending,
|
||||
Pin,
|
||||
Pointer,
|
||||
Poll,
|
||||
ProcMacro,
|
||||
ProcMacroHack,
|
||||
|
@ -242,6 +246,7 @@ symbols! {
|
|||
Send,
|
||||
SeqCst,
|
||||
Some,
|
||||
String,
|
||||
StructuralEq,
|
||||
StructuralPartialEq,
|
||||
Sync,
|
||||
|
@ -249,12 +254,15 @@ symbols! {
|
|||
ToOwned,
|
||||
ToString,
|
||||
Try,
|
||||
TryFrom,
|
||||
TryInto,
|
||||
Ty,
|
||||
TyCtxt,
|
||||
TyKind,
|
||||
Unknown,
|
||||
UnsafeArg,
|
||||
Vec,
|
||||
VecDeque,
|
||||
Yield,
|
||||
_DECLS,
|
||||
_Self,
|
||||
|
@ -507,7 +515,6 @@ symbols! {
|
|||
debug_assert_macro,
|
||||
debug_assertions,
|
||||
debug_struct,
|
||||
debug_trait,
|
||||
debug_trait_builder,
|
||||
debug_tuple,
|
||||
decl_macro,
|
||||
|
@ -653,7 +660,6 @@ symbols! {
|
|||
from_output,
|
||||
from_residual,
|
||||
from_size_align_unchecked,
|
||||
from_trait,
|
||||
from_usize,
|
||||
fsub_fast,
|
||||
fundamental,
|
||||
|
@ -676,8 +682,6 @@ symbols! {
|
|||
gt,
|
||||
half_open_range_patterns,
|
||||
hash,
|
||||
hashmap_type,
|
||||
hashset_type,
|
||||
hexagon_target_feature,
|
||||
hidden,
|
||||
homogeneous_aggregate,
|
||||
|
@ -722,7 +726,6 @@ symbols! {
|
|||
instruction_set,
|
||||
intel,
|
||||
into_iter,
|
||||
into_trait,
|
||||
intra_doc_pointers,
|
||||
intrinsics,
|
||||
irrefutable_let_patterns,
|
||||
|
@ -913,7 +916,6 @@ symbols! {
|
|||
optin_builtin_traits,
|
||||
option,
|
||||
option_env,
|
||||
option_type,
|
||||
options,
|
||||
or,
|
||||
or_patterns,
|
||||
|
@ -955,7 +957,6 @@ symbols! {
|
|||
plugins,
|
||||
pointee_trait,
|
||||
pointer,
|
||||
pointer_trait,
|
||||
pointer_trait_fmt,
|
||||
poll,
|
||||
position,
|
||||
|
@ -1051,7 +1052,6 @@ symbols! {
|
|||
repr_transparent,
|
||||
residual,
|
||||
result,
|
||||
result_type,
|
||||
rhs,
|
||||
rintf32,
|
||||
rintf64,
|
||||
|
@ -1152,7 +1152,6 @@ symbols! {
|
|||
self_in_typedefs,
|
||||
self_struct_ctor,
|
||||
semitransparent,
|
||||
send_trait,
|
||||
shl,
|
||||
shl_assign,
|
||||
should_panic,
|
||||
|
@ -1262,7 +1261,6 @@ symbols! {
|
|||
store,
|
||||
str,
|
||||
str_alloc,
|
||||
string_type,
|
||||
stringify,
|
||||
struct_field_attributes,
|
||||
struct_inherit,
|
||||
|
@ -1277,7 +1275,6 @@ symbols! {
|
|||
suggestion,
|
||||
sym,
|
||||
sync,
|
||||
sync_trait,
|
||||
t32,
|
||||
target_abi,
|
||||
target_arch,
|
||||
|
@ -1323,9 +1320,7 @@ symbols! {
|
|||
truncf64,
|
||||
try_blocks,
|
||||
try_from,
|
||||
try_from_trait,
|
||||
try_into,
|
||||
try_into_trait,
|
||||
try_trait_v2,
|
||||
tt,
|
||||
tuple,
|
||||
|
@ -1397,8 +1392,6 @@ symbols! {
|
|||
var,
|
||||
variant_count,
|
||||
vec,
|
||||
vec_type,
|
||||
vecdeque_type,
|
||||
version,
|
||||
vis,
|
||||
visible_private_types,
|
||||
|
|
|
@ -533,9 +533,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// example).
|
||||
|
||||
let trait_is_debug =
|
||||
self.tcx.is_diagnostic_item(sym::debug_trait, trait_ref.def_id());
|
||||
self.tcx.is_diagnostic_item(sym::Debug, trait_ref.def_id());
|
||||
let trait_is_display =
|
||||
self.tcx.is_diagnostic_item(sym::display_trait, trait_ref.def_id());
|
||||
self.tcx.is_diagnostic_item(sym::Display, trait_ref.def_id());
|
||||
|
||||
let in_std_macro =
|
||||
match obligation.cause.span.ctxt().outer_expn_data().macro_def_id {
|
||||
|
|
|
@ -702,7 +702,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
.filter_map(|lang_item| self.tcx.lang_items().require(*lang_item).ok())
|
||||
.collect();
|
||||
|
||||
never_suggest_borrow.push(self.tcx.get_diagnostic_item(sym::send_trait).unwrap());
|
||||
never_suggest_borrow.push(self.tcx.get_diagnostic_item(sym::Send).unwrap());
|
||||
|
||||
let param_env = obligation.param_env;
|
||||
let trait_ref = trait_ref.skip_binder();
|
||||
|
@ -1634,8 +1634,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
// Special case the primary error message when send or sync is the trait that was
|
||||
// not implemented.
|
||||
let is_send = self.tcx.is_diagnostic_item(sym::send_trait, trait_ref.def_id);
|
||||
let is_sync = self.tcx.is_diagnostic_item(sym::sync_trait, trait_ref.def_id);
|
||||
let is_send = self.tcx.is_diagnostic_item(sym::Send, trait_ref.def_id);
|
||||
let is_sync = self.tcx.is_diagnostic_item(sym::Sync, trait_ref.def_id);
|
||||
let hir = self.tcx.hir();
|
||||
let trait_explanation = if is_send || is_sync {
|
||||
let (trait_name, trait_verb) =
|
||||
|
|
|
@ -438,7 +438,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
let mut label = true;
|
||||
// Check `impl From<self.expr_ty> for self.cast_ty {}` for accurate suggestion:
|
||||
if let Ok(snippet) = fcx.tcx.sess.source_map().span_to_snippet(self.expr.span) {
|
||||
if let Some(from_trait) = fcx.tcx.get_diagnostic_item(sym::from_trait) {
|
||||
if let Some(from_trait) = fcx.tcx.get_diagnostic_item(sym::From) {
|
||||
let ty = fcx.resolve_vars_if_possible(self.cast_ty);
|
||||
// Erase regions to avoid panic in `prove_value` when calling
|
||||
// `type_implements_trait`.
|
||||
|
|
|
@ -983,7 +983,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
sym::Copy,
|
||||
sym::Hash,
|
||||
sym::Default,
|
||||
sym::debug_trait,
|
||||
sym::Debug,
|
||||
];
|
||||
let mut derives = unsatisfied_predicates
|
||||
.iter()
|
||||
|
|
|
@ -572,7 +572,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
on the left and may require reallocation. This \
|
||||
requires ownership of the string on the left";
|
||||
|
||||
let string_type = self.tcx.get_diagnostic_item(sym::string_type);
|
||||
let string_type = self.tcx.get_diagnostic_item(sym::String);
|
||||
let is_std_string = |ty: Ty<'tcx>| match ty.ty_adt_def() {
|
||||
Some(ty_def) => Some(ty_def.did) == string_type,
|
||||
None => false,
|
||||
|
|
|
@ -126,7 +126,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
{
|
||||
match adjusted_ty.kind() {
|
||||
ty::Adt(ty::AdtDef { did, .. }, _)
|
||||
if self.tcx.is_diagnostic_item(sym::vec_type, *did) =>
|
||||
if self.tcx.is_diagnostic_item(sym::Vec, *did) =>
|
||||
{
|
||||
return self.negative_index(adjusted_ty, index_expr.span, base_expr);
|
||||
}
|
||||
|
|
|
@ -877,7 +877,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let auto_traits_def_id = vec![
|
||||
self.tcx.lang_items().clone_trait(),
|
||||
self.tcx.lang_items().sync_trait(),
|
||||
self.tcx.get_diagnostic_item(sym::send_trait),
|
||||
self.tcx.get_diagnostic_item(sym::Send),
|
||||
self.tcx.lang_items().unpin_trait(),
|
||||
self.tcx.get_diagnostic_item(sym::unwind_safe_trait),
|
||||
self.tcx.get_diagnostic_item(sym::ref_unwind_safe_trait),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue