Skip to content

Commit 24424d0

Browse files
authored
Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type` The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2 parents c5d4456 + 70f3c79 commit 24424d0

File tree

27 files changed

+32
-32
lines changed

27 files changed

+32
-32
lines changed

Diff for: compiler/rustc_ast_lowering/src/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
908908
|this| match ty {
909909
None => {
910910
let ty = this.arena.alloc(this.ty(i.span, hir::TyKind::Err));
911-
hir::ImplItemKind::TyAlias(ty)
911+
hir::ImplItemKind::Type(ty)
912912
}
913913
Some(ty) => {
914914
let ty = this.lower_ty(ty, &ImplTraitContext::TypeAliasesOpaqueTy);
915-
hir::ImplItemKind::TyAlias(ty)
915+
hir::ImplItemKind::Type(ty)
916916
}
917917
},
918918
)

Diff for: compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,7 @@ pub enum ImplItemKind<'hir> {
23152315
/// An associated function implementation with the given signature and body.
23162316
Fn(FnSig<'hir>, BodyId),
23172317
/// An associated type.
2318-
TyAlias(&'hir Ty<'hir>),
2318+
Type(&'hir Ty<'hir>),
23192319
}
23202320

23212321
// The name of the associated type for `Fn` return types.

Diff for: compiler/rustc_hir/src/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
979979
impl_item.hir_id(),
980980
);
981981
}
982-
ImplItemKind::TyAlias(ref ty) => {
982+
ImplItemKind::Type(ref ty) => {
983983
visitor.visit_id(impl_item.hir_id());
984984
visitor.visit_ty(ty);
985985
}

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ fn check_impl_items_against_trait<'tcx>(
10621062
opt_trait_span,
10631063
);
10641064
}
1065-
hir::ImplItemKind::TyAlias(impl_ty) => {
1065+
hir::ImplItemKind::Type(impl_ty) => {
10661066
let opt_trait_span = tcx.hir().span_if_local(ty_trait_item.def_id);
10671067
compare_ty_impl(
10681068
tcx,

Diff for: compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ fn check_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) {
837837
let (method_sig, span) = match impl_item.kind {
838838
hir::ImplItemKind::Fn(ref sig, _) => (Some(sig), impl_item.span),
839839
// Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
840-
hir::ImplItemKind::TyAlias(ty) if ty.span != DUMMY_SP => (None, ty.span),
840+
hir::ImplItemKind::Type(ty) if ty.span != DUMMY_SP => (None, ty.span),
841841
_ => (None, impl_item.span),
842842
};
843843

Diff for: compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) {
738738
hir::ImplItemKind::Fn(..) => {
739739
tcx.ensure().fn_sig(def_id);
740740
}
741-
hir::ImplItemKind::TyAlias(_) => {
741+
hir::ImplItemKind::Type(_) => {
742742
// Account for `type T = _;`
743743
let mut visitor = HirPlaceholderCollector::default();
744744
visitor.visit_impl_item(impl_item);

Diff for: compiler/rustc_hir_analysis/src/collect/generics_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
213213
Node::TraitItem(item) if matches!(item.kind, TraitItemKind::Type(..)) => {
214214
(None, Defaults::Deny)
215215
}
216-
Node::ImplItem(item) if matches!(item.kind, ImplItemKind::TyAlias(..)) => {
216+
Node::ImplItem(item) if matches!(item.kind, ImplItemKind::Type(..)) => {
217217
(None, Defaults::Deny)
218218
}
219219

Diff for: compiler/rustc_hir_analysis/src/collect/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
284284
icx.to_ty(ty)
285285
}
286286
}
287-
ImplItemKind::TyAlias(ty) => {
287+
ImplItemKind::Type(ty) => {
288288
if tcx.impl_trait_ref(tcx.hir().get_parent_item(hir_id)).is_none() {
289289
check_feature_inherent_assoc_ty(tcx, item.span);
290290
}

Diff for: compiler/rustc_hir_analysis/src/hir_wf_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn diagnostic_hir_wf_check<'tcx>(
117117
let ty = match loc {
118118
WellFormedLoc::Ty(_) => match hir.get(hir_id) {
119119
hir::Node::ImplItem(item) => match item.kind {
120-
hir::ImplItemKind::TyAlias(ty) => Some(ty),
120+
hir::ImplItemKind::Type(ty) => Some(ty),
121121
hir::ImplItemKind::Const(ty, _) => Some(ty),
122122
ref item => bug!("Unexpected ImplItem {:?}", item),
123123
},

Diff for: compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ impl<'a> State<'a> {
887887
self.end(); // need to close a box
888888
self.ann.nested(self, Nested::Body(body));
889889
}
890-
hir::ImplItemKind::TyAlias(ty) => {
890+
hir::ImplItemKind::Type(ty) => {
891891
self.print_associated_type(ii.ident, ii.generics, None, Some(ty));
892892
}
893893
}

Diff for: compiler/rustc_incremental/src/persist/dirty_clean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
302302
HirNode::ImplItem(item) => match item.kind {
303303
ImplItemKind::Fn(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
304304
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
305-
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
305+
ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
306306
},
307307
_ => self.tcx.sess.span_fatal(
308308
attr.span,

Diff for: compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
25982598
for h in self.tcx.hir().parent_iter(param.hir_id) {
25992599
break 'origin match h.1 {
26002600
Node::ImplItem(hir::ImplItem {
2601-
kind: hir::ImplItemKind::TyAlias(..),
2601+
kind: hir::ImplItemKind::Type(..),
26022602
generics,
26032603
..
26042604
})

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'hir> Map<'hir> {
241241
Node::ImplItem(item) => match item.kind {
242242
ImplItemKind::Const(..) => DefKind::AssocConst,
243243
ImplItemKind::Fn(..) => DefKind::AssocFn,
244-
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
244+
ImplItemKind::Type(..) => DefKind::AssocTy,
245245
},
246246
Node::Variant(_) => DefKind::Variant,
247247
Node::Ctor(variant_data) => {
@@ -1244,7 +1244,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
12441244
format!("assoc const {} in {}{}", ii.ident, path_str(), id_str)
12451245
}
12461246
ImplItemKind::Fn(..) => format!("method {} in {}{}", ii.ident, path_str(), id_str),
1247-
ImplItemKind::TyAlias(_) => {
1247+
ImplItemKind::Type(_) => {
12481248
format!("assoc type {} in {}{}", ii.ident, path_str(), id_str)
12491249
}
12501250
},

Diff for: compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) fn target_from_impl_item<'tcx>(
4949
Target::Method(MethodKind::Inherent)
5050
}
5151
}
52-
hir::ImplItemKind::TyAlias(..) => Target::AssocTy,
52+
hir::ImplItemKind::Type(..) => Target::AssocTy,
5353
}
5454
}
5555

Diff for: compiler/rustc_passes/src/hir_stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
391391
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem<'v>) {
392392
record_variants!(
393393
(self, ii, ii.kind, Id::Node(ii.hir_id()), hir, ImplItem, ImplItemKind),
394-
[Const, Fn, TyAlias]
394+
[Const, Fn, Type]
395395
);
396396
hir_visit::walk_impl_item(self, ii)
397397
}

Diff for: compiler/rustc_passes/src/reachable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'tcx> ReachableContext<'tcx> {
155155
let impl_did = self.tcx.hir().get_parent_item(hir_id);
156156
method_might_be_inlined(self.tcx, impl_item, impl_did.def_id)
157157
}
158-
hir::ImplItemKind::TyAlias(_) => false,
158+
hir::ImplItemKind::Type(_) => false,
159159
},
160160
Some(_) => false,
161161
None => false, // This will happen for default methods.
@@ -271,7 +271,7 @@ impl<'tcx> ReachableContext<'tcx> {
271271
self.visit_nested_body(body)
272272
}
273273
}
274-
hir::ImplItemKind::TyAlias(_) => {}
274+
hir::ImplItemKind::Type(_) => {}
275275
},
276276
Node::Expr(&hir::Expr {
277277
kind: hir::ExprKind::Closure(&hir::Closure { body, .. }),

Diff for: compiler/rustc_privacy/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
15741574
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Fn(..) => {
15751575
self.access_levels.is_reachable(impl_item_ref.id.def_id.def_id)
15761576
}
1577-
hir::ImplItemKind::TyAlias(_) => false,
1577+
hir::ImplItemKind::Type(_) => false,
15781578
}
15791579
});
15801580

@@ -1596,7 +1596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
15961596
{
15971597
intravisit::walk_impl_item(self, impl_item)
15981598
}
1599-
hir::ImplItemKind::TyAlias(..) => {
1599+
hir::ImplItemKind::Type(..) => {
16001600
intravisit::walk_impl_item(self, impl_item)
16011601
}
16021602
_ => {}
@@ -1622,7 +1622,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
16221622
// Those in 3. are warned with this call.
16231623
for impl_item_ref in impl_.items {
16241624
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
1625-
if let hir::ImplItemKind::TyAlias(ty) = impl_item.kind {
1625+
if let hir::ImplItemKind::Type(ty) = impl_item.kind {
16261626
self.visit_ty(ty);
16271627
}
16281628
}

Diff for: compiler/rustc_resolve/src/late/lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
898898
Fn(..) => self.visit_early_late(impl_item.hir_id(), &impl_item.generics, |this| {
899899
intravisit::walk_impl_item(this, impl_item)
900900
}),
901-
TyAlias(ref ty) => {
901+
Type(ref ty) => {
902902
let generics = &impl_item.generics;
903903
let lifetimes: FxIndexMap<LocalDefId, Region> = generics
904904
.params

Diff for: compiler/rustc_save_analysis/src/dump_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ impl<'tcx> DumpVisitor<'tcx> {
10691069
impl_item.span,
10701070
);
10711071
}
1072-
hir::ImplItemKind::TyAlias(ref ty) => {
1072+
hir::ImplItemKind::Type(ref ty) => {
10731073
// FIXME: uses of the assoc type should ideally point to this
10741074
// 'def' and the name here should be a ref to the def in the
10751075
// trait.

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
16591659
..
16601660
})
16611661
| hir::Node::ImplItem(hir::ImplItem {
1662-
kind: hir::ImplItemKind::TyAlias(ty),
1662+
kind: hir::ImplItemKind::Type(ty),
16631663
..
16641664
}),
16651665
) => Some((ty.span, format!("type mismatch resolving `{}`", predicate))),

Diff for: compiler/rustc_trait_selection/src/traits/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
224224
};
225225
let fix_span =
226226
|impl_item_ref: &hir::ImplItemRef| match tcx.hir().impl_item(impl_item_ref.id).kind {
227-
hir::ImplItemKind::Const(ty, _) | hir::ImplItemKind::TyAlias(ty) => ty.span,
227+
hir::ImplItemKind::Const(ty, _) | hir::ImplItemKind::Type(ty) => ty.span,
228228
_ => impl_item_ref.span,
229229
};
230230

Diff for: compiler/rustc_ty_utils/src/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
161161
}) => hir::Constness::Const,
162162

163163
hir::Node::ImplItem(hir::ImplItem {
164-
kind: hir::ImplItemKind::TyAlias(..) | hir::ImplItemKind::Fn(..),
164+
kind: hir::ImplItemKind::Type(..) | hir::ImplItemKind::Fn(..),
165165
..
166166
}) => {
167167
let parent_hir_id = tcx.hir().get_parent_node(hir_id);

Diff for: src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub(crate) fn build_impl(
410410
let assoc_kind = match item.kind {
411411
hir::ImplItemKind::Const(..) => ty::AssocKind::Const,
412412
hir::ImplItemKind::Fn(..) => ty::AssocKind::Fn,
413-
hir::ImplItemKind::TyAlias(..) => ty::AssocKind::Type,
413+
hir::ImplItemKind::Type(..) => ty::AssocKind::Type,
414414
};
415415
let trait_item = tcx
416416
.associated_items(associated_trait.def_id)

Diff for: src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ pub(crate) fn clean_impl_item<'tcx>(
10941094
let defaultness = cx.tcx.impl_defaultness(impl_.def_id);
10951095
MethodItem(m, Some(defaultness))
10961096
}
1097-
hir::ImplItemKind::TyAlias(hir_ty) => {
1097+
hir::ImplItemKind::Type(hir_ty) => {
10981098
let type_ = clean_ty(hir_ty, cx);
10991099
let generics = clean_generics(impl_.generics, cx);
11001100
let item_type = clean_middle_ty(hir_ty_to_ty(cx.tcx, hir_ty), cx, None);

Diff for: src/tools/clippy/clippy_lints/src/missing_inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
148148

149149
let desc = match impl_item.kind {
150150
hir::ImplItemKind::Fn(..) => "a method",
151-
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) => return,
151+
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(_) => return,
152152
};
153153

154154
let assoc_item = cx.tcx.associated_item(impl_item.def_id);

Diff for: src/tools/clippy/clippy_lints/src/types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
374374
// Methods are covered by check_fn.
375375
// Type aliases are ignored because oftentimes it's impossible to
376376
// make type alias declaration in trait simpler, see #1013
377-
ImplItemKind::Fn(..) | ImplItemKind::TyAlias(..) => (),
377+
ImplItemKind::Fn(..) | ImplItemKind::Type(..) => (),
378378
}
379379
}
380380

Diff for: src/tools/clippy/clippy_utils/src/check_proc_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn trait_item_search_pat(item: &TraitItem<'_>) -> (Pat, Pat) {
220220
fn impl_item_search_pat(item: &ImplItem<'_>) -> (Pat, Pat) {
221221
let (start_pat, end_pat) = match &item.kind {
222222
ImplItemKind::Const(..) => (Pat::Str("const"), Pat::Str(";")),
223-
ImplItemKind::TyAlias(..) => (Pat::Str("type"), Pat::Str(";")),
223+
ImplItemKind::Type(..) => (Pat::Str("type"), Pat::Str(";")),
224224
ImplItemKind::Fn(sig, ..) => (fn_header_search_pat(sig.header), Pat::Str("")),
225225
};
226226
if item.vis_span.is_empty() {

0 commit comments

Comments
 (0)