Skip to content

Commit

Permalink
Make diangostic item names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Oct 3, 2021
1 parent f03eb6b commit eec856b
Show file tree
Hide file tree
Showing 123 changed files with 244 additions and 248 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Expand Up @@ -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 }
});
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/internal.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/methods.rs
Expand Up @@ -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| {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/non_fmt_panic.rs
Expand Up @@ -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)
Expand Down
Expand Up @@ -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
Expand Down
23 changes: 8 additions & 15 deletions compiler/rustc_span/src/symbol.rs
Expand Up @@ -169,6 +169,7 @@ symbols! {
Default,
Deref,
DirBuilder,
Display,
DoubleEndedIterator,
Duration,
Encodable,
Expand All @@ -194,6 +195,7 @@ symbols! {
Hasher,
Implied,
Input,
Into,
IntoIterator,
IoRead,
IoWrite,
Expand All @@ -204,6 +206,7 @@ symbols! {
Left,
LinkedList,
LintPass,
Mutex,
None,
Ok,
Option,
Expand All @@ -219,6 +222,7 @@ symbols! {
PathBuf,
Pending,
Pin,
Pointer,
Poll,
ProcMacro,
ProcMacroHack,
Expand All @@ -242,19 +246,23 @@ symbols! {
Send,
SeqCst,
Some,
String,
StructuralEq,
StructuralPartialEq,
Sync,
Target,
ToOwned,
ToString,
Try,
TryFrom,
TryInto,
Ty,
TyCtxt,
TyKind,
Unknown,
UnsafeArg,
Vec,
VecDeque,
Yield,
_DECLS,
_Self,
Expand Down Expand Up @@ -507,7 +515,6 @@ symbols! {
debug_assert_macro,
debug_assertions,
debug_struct,
debug_trait,
debug_trait_builder,
debug_tuple,
decl_macro,
Expand Down Expand Up @@ -653,7 +660,6 @@ symbols! {
from_output,
from_residual,
from_size_align_unchecked,
from_trait,
from_usize,
fsub_fast,
fundamental,
Expand All @@ -676,8 +682,6 @@ symbols! {
gt,
half_open_range_patterns,
hash,
hashmap_type,
hashset_type,
hexagon_target_feature,
hidden,
homogeneous_aggregate,
Expand Down Expand Up @@ -722,7 +726,6 @@ symbols! {
instruction_set,
intel,
into_iter,
into_trait,
intra_doc_pointers,
intrinsics,
irrefutable_let_patterns,
Expand Down Expand Up @@ -913,7 +916,6 @@ symbols! {
optin_builtin_traits,
option,
option_env,
option_type,
options,
or,
or_patterns,
Expand Down Expand Up @@ -955,7 +957,6 @@ symbols! {
plugins,
pointee_trait,
pointer,
pointer_trait,
pointer_trait_fmt,
poll,
position,
Expand Down Expand Up @@ -1051,7 +1052,6 @@ symbols! {
repr_transparent,
residual,
result,
result_type,
rhs,
rintf32,
rintf64,
Expand Down Expand Up @@ -1152,7 +1152,6 @@ symbols! {
self_in_typedefs,
self_struct_ctor,
semitransparent,
send_trait,
shl,
shl_assign,
should_panic,
Expand Down Expand Up @@ -1262,7 +1261,6 @@ symbols! {
store,
str,
str_alloc,
string_type,
stringify,
struct_field_attributes,
struct_inherit,
Expand All @@ -1277,7 +1275,6 @@ symbols! {
suggestion,
sym,
sync,
sync_trait,
t32,
target_abi,
target_arch,
Expand Down Expand Up @@ -1323,9 +1320,7 @@ symbols! {
truncf64,
try_blocks,
try_from,
try_from_trait,
try_into,
try_into_trait,
try_trait_v2,
tt,
tuple,
Expand Down Expand Up @@ -1397,8 +1392,6 @@ symbols! {
var,
variant_count,
vec,
vec_type,
vecdeque_type,
version,
vis,
visible_private_types,
Expand Down
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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();
Expand Down Expand Up @@ -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) =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/cast.rs
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/method/suggest.rs
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/op.rs
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/place_op.rs
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/upvar.rs
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/vec_deque/mod.rs
Expand Up @@ -88,7 +88,7 @@ const MAXIMUM_ZST_CAPACITY: usize = 1 << (usize::BITS - 1); // Largest possible
/// [`extend`]: VecDeque::extend
/// [`append`]: VecDeque::append
/// [`make_contiguous`]: VecDeque::make_contiguous
#[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_type")]
#[cfg_attr(not(test), rustc_diagnostic_item = "VecDeque")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_insignificant_dtor]
pub struct VecDeque<
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/string.rs
Expand Up @@ -289,7 +289,7 @@ use crate::vec::Vec;
/// [`Deref`]: core::ops::Deref "ops::Deref"
/// [`as_str()`]: String::as_str
#[derive(PartialOrd, Eq, Ord)]
#[cfg_attr(not(test), rustc_diagnostic_item = "string_type")]
#[cfg_attr(not(test), rustc_diagnostic_item = "String")]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct String {
vec: Vec<u8>,
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/mod.rs
Expand Up @@ -395,7 +395,7 @@ mod spec_extend;
/// [`MaybeUninit`]: core::mem::MaybeUninit
/// [owned slice]: Box
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_type")]
#[cfg_attr(not(test), rustc_diagnostic_item = "Vec")]
#[rustc_insignificant_dtor]
pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
buf: RawVec<T, A>,
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/convert/mod.rs
Expand Up @@ -269,7 +269,7 @@ pub trait AsMut<T: ?Sized> {
///
/// [`String`]: ../../std/string/struct.String.html
/// [`Vec`]: ../../std/vec/struct.Vec.html
#[rustc_diagnostic_item = "into_trait"]
#[rustc_diagnostic_item = "Into"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Into<T>: Sized {
/// Performs the conversion.
Expand Down Expand Up @@ -358,7 +358,7 @@ pub trait Into<T>: Sized {
/// [`String`]: ../../std/string/struct.String.html
/// [`from`]: From::from
/// [book]: ../../book/ch09-00-error-handling.html
#[rustc_diagnostic_item = "from_trait"]
#[rustc_diagnostic_item = "From"]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_on_unimplemented(on(
all(_Self = "&str", T = "std::string::String"),
Expand All @@ -385,7 +385,7 @@ pub trait From<T>: Sized {
///
/// This suffers the same restrictions and reasoning as implementing
/// [`Into`], see there for details.
#[rustc_diagnostic_item = "try_into_trait"]
#[rustc_diagnostic_item = "TryInto"]
#[stable(feature = "try_from", since = "1.34.0")]
pub trait TryInto<T>: Sized {
/// The type returned in the event of a conversion error.
Expand Down Expand Up @@ -465,7 +465,7 @@ pub trait TryInto<T>: Sized {
/// ```
///
/// [`try_from`]: TryFrom::try_from
#[rustc_diagnostic_item = "try_from_trait"]
#[rustc_diagnostic_item = "TryFrom"]
#[stable(feature = "try_from", since = "1.34.0")]
pub trait TryFrom<T>: Sized {
/// The type returned in the event of a conversion error.
Expand Down

0 comments on commit eec856b

Please sign in to comment.