Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 77f1e50

Browse files
committed
Auto merge of rust-lang#89479 - camsteffen:diag-naming, r=Manishearth
Make diangostic item naming consistent Right now there is about a 50/50 split of naming diagnostic items as `vec_type` vs `Vec`. So it is hard to guess a diagnostic item name with confidence. I know it's not great to change these retroactively, but I think it will be much easier to maintain consistency after consistency is established.
2 parents c70b35e + eec856b commit 77f1e50

File tree

123 files changed

+244
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+244
-248
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
966966
_ => None,
967967
});
968968
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
969-
tcx.is_diagnostic_item(sym::option_type, def_id)
970-
|| tcx.is_diagnostic_item(sym::result_type, def_id)
969+
tcx.is_diagnostic_item(sym::Option, def_id)
970+
|| tcx.is_diagnostic_item(sym::Result, def_id)
971971
});
972972
FnSelfUseKind::Normal { self_arg, implicit_into_iter, is_option_or_result }
973973
});

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
400400
| ty::Opaque(def_id, _) => def_id,
401401
_ => return err,
402402
};
403-
let is_option = self.infcx.tcx.is_diagnostic_item(sym::option_type, def_id);
404-
let is_result = self.infcx.tcx.is_diagnostic_item(sym::result_type, def_id);
403+
let is_option = self.infcx.tcx.is_diagnostic_item(sym::Option, def_id);
404+
let is_result = self.infcx.tcx.is_diagnostic_item(sym::Result, def_id);
405405
if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) {
406406
err.span_suggestion_verbose(
407407
span.shrink_to_hi(),

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
25332533
/// within `?` desugaring.
25342534
pub fn is_try_conversion(&self, span: Span, trait_def_id: DefId) -> bool {
25352535
span.is_desugaring(DesugaringKind::QuestionMark)
2536-
&& self.tcx.is_diagnostic_item(sym::from_trait, trait_def_id)
2536+
&& self.tcx.is_diagnostic_item(sym::From, trait_def_id)
25372537
}
25382538
}
25392539

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
812812
_ => return,
813813
}
814814

815-
let debug = match cx.tcx.get_diagnostic_item(sym::debug_trait) {
815+
let debug = match cx.tcx.get_diagnostic_item(sym::Debug) {
816816
Some(debug) => debug,
817817
None => return,
818818
};

compiler/rustc_lint/src/internal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ impl LateLintPass<'_> for DefaultHashTypes {
3333
// don't lint imports, only actual usages
3434
return;
3535
}
36-
let replace = if cx.tcx.is_diagnostic_item(sym::hashmap_type, def_id) {
36+
let replace = if cx.tcx.is_diagnostic_item(sym::HashMap, def_id) {
3737
"FxHashMap"
38-
} else if cx.tcx.is_diagnostic_item(sym::hashset_type, def_id) {
38+
} else if cx.tcx.is_diagnostic_item(sym::HashSet, def_id) {
3939
"FxHashSet"
4040
} else {
4141
return;

compiler/rustc_lint/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn lint_cstring_as_ptr(
8484
) {
8585
let source_type = cx.typeck_results().expr_ty(source);
8686
if let ty::Adt(def, substs) = source_type.kind() {
87-
if cx.tcx.is_diagnostic_item(sym::result_type, def.did) {
87+
if cx.tcx.is_diagnostic_item(sym::Result, def.did) {
8888
if let ty::Adt(adt, _) = substs.type_at(0).kind() {
8989
if cx.tcx.is_diagnostic_item(sym::cstring_type, adt.did) {
9090
cx.struct_span_lint(TEMPORARY_CSTRING_AS_PTR, as_ptr_span, |diag| {

compiler/rustc_lint/src/non_fmt_panic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
130130
ty::Ref(_, r, _) if *r.kind() == ty::Str,
131131
) || matches!(
132132
ty.ty_adt_def(),
133-
Some(ty_def) if cx.tcx.is_diagnostic_item(sym::string_type, ty_def.did),
133+
Some(ty_def) if cx.tcx.is_diagnostic_item(sym::String, ty_def.did),
134134
);
135135

136136
let (suggest_display, suggest_debug) = cx.tcx.infer_ctxt().enter(|infcx| {
137-
let display = is_str || cx.tcx.get_diagnostic_item(sym::display_trait).map(|t| {
137+
let display = is_str || cx.tcx.get_diagnostic_item(sym::Display).map(|t| {
138138
infcx.type_implements_trait(t, ty, InternalSubsts::empty(), cx.param_env).may_apply()
139139
}) == Some(true);
140-
let debug = !display && cx.tcx.get_diagnostic_item(sym::debug_trait).map(|t| {
140+
let debug = !display && cx.tcx.get_diagnostic_item(sym::Debug).map(|t| {
141141
infcx.type_implements_trait(t, ty, InternalSubsts::empty(), cx.param_env).may_apply()
142142
}) == Some(true);
143143
(display, debug)

compiler/rustc_mir_transform/src/function_item_references.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
133133
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
134134
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
135135
if let ty::PredicateKind::Trait(predicate) = bound {
136-
if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) {
136+
if self.tcx.is_diagnostic_item(sym::Pointer, predicate.def_id()) {
137137
Some(predicate.trait_ref.self_ty())
138138
} else {
139139
None

compiler/rustc_span/src/symbol.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ symbols! {
169169
Default,
170170
Deref,
171171
DirBuilder,
172+
Display,
172173
DoubleEndedIterator,
173174
Duration,
174175
Encodable,
@@ -194,6 +195,7 @@ symbols! {
194195
Hasher,
195196
Implied,
196197
Input,
198+
Into,
197199
IntoIterator,
198200
IoRead,
199201
IoWrite,
@@ -204,6 +206,7 @@ symbols! {
204206
Left,
205207
LinkedList,
206208
LintPass,
209+
Mutex,
207210
None,
208211
Ok,
209212
Option,
@@ -219,6 +222,7 @@ symbols! {
219222
PathBuf,
220223
Pending,
221224
Pin,
225+
Pointer,
222226
Poll,
223227
ProcMacro,
224228
ProcMacroHack,
@@ -242,19 +246,23 @@ symbols! {
242246
Send,
243247
SeqCst,
244248
Some,
249+
String,
245250
StructuralEq,
246251
StructuralPartialEq,
247252
Sync,
248253
Target,
249254
ToOwned,
250255
ToString,
251256
Try,
257+
TryFrom,
258+
TryInto,
252259
Ty,
253260
TyCtxt,
254261
TyKind,
255262
Unknown,
256263
UnsafeArg,
257264
Vec,
265+
VecDeque,
258266
Yield,
259267
_DECLS,
260268
_Self,
@@ -507,7 +515,6 @@ symbols! {
507515
debug_assert_macro,
508516
debug_assertions,
509517
debug_struct,
510-
debug_trait,
511518
debug_trait_builder,
512519
debug_tuple,
513520
decl_macro,
@@ -653,7 +660,6 @@ symbols! {
653660
from_output,
654661
from_residual,
655662
from_size_align_unchecked,
656-
from_trait,
657663
from_usize,
658664
fsub_fast,
659665
fundamental,
@@ -676,8 +682,6 @@ symbols! {
676682
gt,
677683
half_open_range_patterns,
678684
hash,
679-
hashmap_type,
680-
hashset_type,
681685
hexagon_target_feature,
682686
hidden,
683687
homogeneous_aggregate,
@@ -722,7 +726,6 @@ symbols! {
722726
instruction_set,
723727
intel,
724728
into_iter,
725-
into_trait,
726729
intra_doc_pointers,
727730
intrinsics,
728731
irrefutable_let_patterns,
@@ -913,7 +916,6 @@ symbols! {
913916
optin_builtin_traits,
914917
option,
915918
option_env,
916-
option_type,
917919
options,
918920
or,
919921
or_patterns,
@@ -955,7 +957,6 @@ symbols! {
955957
plugins,
956958
pointee_trait,
957959
pointer,
958-
pointer_trait,
959960
pointer_trait_fmt,
960961
poll,
961962
position,
@@ -1051,7 +1052,6 @@ symbols! {
10511052
repr_transparent,
10521053
residual,
10531054
result,
1054-
result_type,
10551055
rhs,
10561056
rintf32,
10571057
rintf64,
@@ -1152,7 +1152,6 @@ symbols! {
11521152
self_in_typedefs,
11531153
self_struct_ctor,
11541154
semitransparent,
1155-
send_trait,
11561155
shl,
11571156
shl_assign,
11581157
should_panic,
@@ -1262,7 +1261,6 @@ symbols! {
12621261
store,
12631262
str,
12641263
str_alloc,
1265-
string_type,
12661264
stringify,
12671265
struct_field_attributes,
12681266
struct_inherit,
@@ -1277,7 +1275,6 @@ symbols! {
12771275
suggestion,
12781276
sym,
12791277
sync,
1280-
sync_trait,
12811278
t32,
12821279
target_abi,
12831280
target_arch,
@@ -1323,9 +1320,7 @@ symbols! {
13231320
truncf64,
13241321
try_blocks,
13251322
try_from,
1326-
try_from_trait,
13271323
try_into,
1328-
try_into_trait,
13291324
try_trait_v2,
13301325
tt,
13311326
tuple,
@@ -1397,8 +1392,6 @@ symbols! {
13971392
var,
13981393
variant_count,
13991394
vec,
1400-
vec_type,
1401-
vecdeque_type,
14021395
version,
14031396
vis,
14041397
visible_private_types,

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
533533
// example).
534534

535535
let trait_is_debug =
536-
self.tcx.is_diagnostic_item(sym::debug_trait, trait_ref.def_id());
536+
self.tcx.is_diagnostic_item(sym::Debug, trait_ref.def_id());
537537
let trait_is_display =
538-
self.tcx.is_diagnostic_item(sym::display_trait, trait_ref.def_id());
538+
self.tcx.is_diagnostic_item(sym::Display, trait_ref.def_id());
539539

540540
let in_std_macro =
541541
match obligation.cause.span.ctxt().outer_expn_data().macro_def_id {

0 commit comments

Comments
 (0)