Skip to content

Commit 81b9d0b

Browse files
authored
Rollup merge of rust-lang#102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type` Thanks `@camsteffen` for catching this in ast too, cc rust-lang#102829 (comment)
2 parents 5a09b72 + d3bd6be commit 81b9d0b

File tree

18 files changed

+37
-37
lines changed

18 files changed

+37
-37
lines changed

compiler/rustc_ast/src/ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,7 @@ pub enum AssocItemKind {
29532953
/// An associated function.
29542954
Fn(Box<Fn>),
29552955
/// An associated type.
2956-
TyAlias(Box<TyAlias>),
2956+
Type(Box<TyAlias>),
29572957
/// A macro expanding to associated items.
29582958
MacCall(P<MacCall>),
29592959
}
@@ -2963,7 +2963,7 @@ impl AssocItemKind {
29632963
match *self {
29642964
Self::Const(defaultness, ..)
29652965
| Self::Fn(box Fn { defaultness, .. })
2966-
| Self::TyAlias(box TyAlias { defaultness, .. }) => defaultness,
2966+
| Self::Type(box TyAlias { defaultness, .. }) => defaultness,
29672967
Self::MacCall(..) => Defaultness::Final,
29682968
}
29692969
}
@@ -2974,7 +2974,7 @@ impl From<AssocItemKind> for ItemKind {
29742974
match assoc_item_kind {
29752975
AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c),
29762976
AssocItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
2977-
AssocItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
2977+
AssocItemKind::Type(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
29782978
AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
29792979
}
29802980
}
@@ -2987,7 +2987,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
29872987
Ok(match item_kind {
29882988
ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c),
29892989
ItemKind::Fn(fn_kind) => AssocItemKind::Fn(fn_kind),
2990-
ItemKind::TyAlias(ty_alias_kind) => AssocItemKind::TyAlias(ty_alias_kind),
2990+
ItemKind::TyAlias(ty_kind) => AssocItemKind::Type(ty_kind),
29912991
ItemKind::MacCall(a) => AssocItemKind::MacCall(a),
29922992
_ => return Err(item_kind),
29932993
})

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
11061106
visit_fn_sig(sig, visitor);
11071107
visit_opt(body, |body| visitor.visit_block(body));
11081108
}
1109-
AssocItemKind::TyAlias(box TyAlias {
1109+
AssocItemKind::Type(box TyAlias {
11101110
defaultness,
11111111
generics,
11121112
where_clauses,

compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
683683
let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref());
684684
visitor.visit_fn(kind, span, id);
685685
}
686-
AssocItemKind::TyAlias(box TyAlias { generics, bounds, ty, .. }) => {
686+
AssocItemKind::Type(box TyAlias { generics, bounds, ty, .. }) => {
687687
visitor.visit_generics(generics);
688688
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
689689
walk_list!(visitor, visit_ty, ty);

compiler/rustc_ast_lowering/src/item.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
804804
);
805805
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id)), true)
806806
}
807-
AssocItemKind::TyAlias(box TyAlias {
807+
AssocItemKind::Type(box TyAlias {
808808
ref generics,
809809
where_clauses,
810810
ref bounds,
@@ -850,7 +850,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
850850
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
851851
let kind = match &i.kind {
852852
AssocItemKind::Const(..) => hir::AssocItemKind::Const,
853-
AssocItemKind::TyAlias(..) => hir::AssocItemKind::Type,
853+
AssocItemKind::Type(..) => hir::AssocItemKind::Type,
854854
AssocItemKind::Fn(box Fn { sig, .. }) => {
855855
hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }
856856
}
@@ -898,7 +898,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
898898

899899
(generics, hir::ImplItemKind::Fn(sig, body_id))
900900
}
901-
AssocItemKind::TyAlias(box TyAlias { generics, where_clauses, ty, .. }) => {
901+
AssocItemKind::Type(box TyAlias { generics, where_clauses, ty, .. }) => {
902902
let mut generics = generics.clone();
903903
add_ty_alias_where_clause(&mut generics, *where_clauses, false);
904904
self.lower_generics(
@@ -941,7 +941,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
941941
span: self.lower_span(i.span),
942942
kind: match &i.kind {
943943
AssocItemKind::Const(..) => hir::AssocItemKind::Const,
944-
AssocItemKind::TyAlias(..) => hir::AssocItemKind::Type,
944+
AssocItemKind::Type(..) => hir::AssocItemKind::Type,
945945
AssocItemKind::Fn(box Fn { sig, .. }) => {
946946
hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }
947947
}

compiler/rustc_ast_passes/src/ast_validation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
15561556
});
15571557
}
15581558
}
1559-
AssocItemKind::TyAlias(box TyAlias {
1559+
AssocItemKind::Type(box TyAlias {
15601560
generics,
15611561
where_clauses,
15621562
where_predicates_split,
@@ -1595,7 +1595,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
15951595
}
15961596

15971597
match item.kind {
1598-
AssocItemKind::TyAlias(box TyAlias { ref generics, ref bounds, ref ty, .. })
1598+
AssocItemKind::Type(box TyAlias { ref generics, ref bounds, ref ty, .. })
15991599
if ctxt == AssocCtxt::Trait =>
16001600
{
16011601
self.visit_vis(&item.vis);

compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
517517
fn visit_assoc_item(&mut self, i: &'a ast::AssocItem, ctxt: AssocCtxt) {
518518
let is_fn = match i.kind {
519519
ast::AssocItemKind::Fn(_) => true,
520-
ast::AssocItemKind::TyAlias(box ast::TyAlias { ref ty, .. }) => {
520+
ast::AssocItemKind::Type(box ast::TyAlias { ref ty, .. }) => {
521521
if let (Some(_), AssocCtxt::Trait) = (ty, ctxt) {
522522
gate_feature_post!(
523523
&self,

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl<'a> State<'a> {
516516
ast::AssocItemKind::Const(def, ty, body) => {
517517
self.print_item_const(ident, None, ty, body.as_deref(), vis, *def);
518518
}
519-
ast::AssocItemKind::TyAlias(box ast::TyAlias {
519+
ast::AssocItemKind::Type(box ast::TyAlias {
520520
defaultness,
521521
generics,
522522
where_clauses,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl<'a> TraitDef<'a> {
566566
tokens: None,
567567
},
568568
attrs: ast::AttrVec::new(),
569-
kind: ast::AssocItemKind::TyAlias(Box::new(ast::TyAlias {
569+
kind: ast::AssocItemKind::Type(Box::new(ast::TyAlias {
570570
defaultness: ast::Defaultness::Final,
571571
generics: Generics::default(),
572572
where_clauses: (

compiler/rustc_lint/src/nonstandard_style.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl EarlyLintPass for NonCamelCaseTypes {
187187
}
188188

189189
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
190-
if let ast::AssocItemKind::TyAlias(..) = it.kind {
190+
if let ast::AssocItemKind::Type(..) = it.kind {
191191
self.check_case(cx, "associated type", &it.ident);
192192
}
193193
}

compiler/rustc_passes/src/hir_stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
620620
fn visit_assoc_item(&mut self, i: &'v ast::AssocItem, ctxt: ast_visit::AssocCtxt) {
621621
record_variants!(
622622
(self, i, i.kind, Id::None, ast, AssocItem, AssocItemKind),
623-
[Const, Fn, TyAlias, MacCall]
623+
[Const, Fn, Type, MacCall]
624624
);
625625
ast_visit::walk_assoc_item(self, i, ctxt);
626626
}

compiler/rustc_resolve/src/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
14251425
}
14261426
(DefKind::AssocFn, ValueNS)
14271427
}
1428-
AssocItemKind::TyAlias(..) => (DefKind::AssocTy, TypeNS),
1428+
AssocItemKind::Type(..) => (DefKind::AssocTy, TypeNS),
14291429
AssocItemKind::MacCall(_) => bug!(), // handled above
14301430
};
14311431

compiler/rustc_resolve/src/def_collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
239239
fn visit_assoc_item(&mut self, i: &'a AssocItem, ctxt: visit::AssocCtxt) {
240240
let def_data = match &i.kind {
241241
AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(i.ident.name),
242-
AssocItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.name),
242+
AssocItemKind::Type(..) => DefPathData::TypeNs(i.ident.name),
243243
AssocItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
244244
};
245245

compiler/rustc_resolve/src/late.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
24982498
AssocItemKind::Fn(box Fn { generics, .. }) => {
24992499
walk_assoc_item(self, generics, LifetimeBinderKind::Function, item);
25002500
}
2501-
AssocItemKind::TyAlias(box TyAlias { generics, .. }) => self
2501+
AssocItemKind::Type(box TyAlias { generics, .. }) => self
25022502
.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| {
25032503
walk_assoc_item(this, generics, LifetimeBinderKind::Item, item)
25042504
}),
@@ -2694,8 +2694,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
26942694
},
26952695
);
26962696
}
2697-
AssocItemKind::TyAlias(box TyAlias { generics, .. }) => {
2698-
debug!("resolve_implementation AssocItemKind::TyAlias");
2697+
AssocItemKind::Type(box TyAlias { generics, .. }) => {
2698+
debug!("resolve_implementation AssocItemKind::Type");
26992699
// We also need a new scope for the impl item type parameters.
27002700
self.with_generic_param_rib(
27012701
&generics.params,
@@ -2770,7 +2770,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
27702770
let res = binding.res();
27712771
let Res::Def(def_kind, _) = res else { bug!() };
27722772
match (def_kind, kind) {
2773-
(DefKind::AssocTy, AssocItemKind::TyAlias(..))
2773+
(DefKind::AssocTy, AssocItemKind::Type(..))
27742774
| (DefKind::AssocFn, AssocItemKind::Fn(..))
27752775
| (DefKind::AssocConst, AssocItemKind::Const(..)) => {
27762776
self.r.record_partial_res(id, PartialRes::new(res));
@@ -2784,7 +2784,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
27842784
let (code, kind) = match kind {
27852785
AssocItemKind::Const(..) => (rustc_errors::error_code!(E0323), "const"),
27862786
AssocItemKind::Fn(..) => (rustc_errors::error_code!(E0324), "method"),
2787-
AssocItemKind::TyAlias(..) => (rustc_errors::error_code!(E0325), "type"),
2787+
AssocItemKind::Type(..) => (rustc_errors::error_code!(E0325), "type"),
27882788
AssocItemKind::MacCall(..) => span_bug!(span, "unexpanded macro"),
27892789
};
27902790
let trait_path = path_names_to_string(path);

compiler/rustc_resolve/src/late/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
14821482
.filter(|(_, res)| match (kind, res) {
14831483
(AssocItemKind::Const(..), Res::Def(DefKind::AssocConst, _)) => true,
14841484
(AssocItemKind::Fn(_), Res::Def(DefKind::AssocFn, _)) => true,
1485-
(AssocItemKind::TyAlias(..), Res::Def(DefKind::AssocTy, _)) => true,
1485+
(AssocItemKind::Type(..), Res::Def(DefKind::AssocTy, _)) => true,
14861486
_ => false,
14871487
})
14881488
.map(|(key, _)| key.ident.name)
@@ -1546,7 +1546,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
15461546
AssocSuggestion::MethodWithSelf
15471547
}
15481548
ast::AssocItemKind::Fn(..) => AssocSuggestion::AssocFn,
1549-
ast::AssocItemKind::TyAlias(..) => AssocSuggestion::AssocType,
1549+
ast::AssocItemKind::Type(..) => AssocSuggestion::AssocType,
15501550
ast::AssocItemKind::MacCall(_) => continue,
15511551
});
15521552
}

src/test/ui/stats/hir-stats.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ast-stats-1 Block 288 ( 3.4%) 6 48
2626
ast-stats-1 GenericBound 352 ( 4.2%) 4 88
2727
ast-stats-1 - Trait 352 ( 4.2%) 4
2828
ast-stats-1 AssocItem 416 ( 4.9%) 4 104
29-
ast-stats-1 - TyAlias 208 ( 2.5%) 2
29+
ast-stats-1 - Type 208 ( 2.5%) 2
3030
ast-stats-1 - Fn 208 ( 2.5%) 2
3131
ast-stats-1 GenericParam 480 ( 5.7%) 5 96
3232
ast-stats-1 PathSegment 720 ( 8.6%) 30 24
@@ -84,7 +84,7 @@ ast-stats-2 Block 288 ( 3.1%) 6 48
8484
ast-stats-2 GenericBound 352 ( 3.8%) 4 88
8585
ast-stats-2 - Trait 352 ( 3.8%) 4
8686
ast-stats-2 AssocItem 416 ( 4.5%) 4 104
87-
ast-stats-2 - TyAlias 208 ( 2.3%) 2
87+
ast-stats-2 - Type 208 ( 2.3%) 2
8888
ast-stats-2 - Fn 208 ( 2.3%) 2
8989
ast-stats-2 GenericParam 480 ( 5.2%) 5 96
9090
ast-stats-2 PathSegment 792 ( 8.7%) 33 24

src/tools/clippy/clippy_utils/src/ast_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,14 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
438438
eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
439439
},
440440
(
441-
TyAlias(box ast::TyAlias {
441+
Type(box ast::TyAlias {
442442
defaultness: ld,
443443
generics: lg,
444444
bounds: lb,
445445
ty: lt,
446446
..
447447
}),
448-
TyAlias(box ast::TyAlias {
448+
Type(box ast::TyAlias {
449449
defaultness: rd,
450450
generics: rg,
451451
bounds: rb,

src/tools/rustfmt/src/items.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a> FmtVisitor<'a> {
594594
let both_type = |l: &TyOpt, r: &TyOpt| is_type(l) && is_type(r);
595595
let both_opaque = |l: &TyOpt, r: &TyOpt| is_opaque(l) && is_opaque(r);
596596
let need_empty_line = |a: &ast::AssocItemKind, b: &ast::AssocItemKind| match (a, b) {
597-
(TyAlias(lty), TyAlias(rty))
597+
(Type(lty), Type(rty))
598598
if both_type(&lty.ty, &rty.ty) || both_opaque(&lty.ty, &rty.ty) =>
599599
{
600600
false
@@ -612,7 +612,7 @@ impl<'a> FmtVisitor<'a> {
612612
}
613613

614614
buffer.sort_by(|(_, a), (_, b)| match (&a.kind, &b.kind) {
615-
(TyAlias(lty), TyAlias(rty))
615+
(Type(lty), Type(rty))
616616
if both_type(&lty.ty, &rty.ty) || both_opaque(&lty.ty, &rty.ty) =>
617617
{
618618
a.ident.as_str().cmp(b.ident.as_str())
@@ -621,10 +621,10 @@ impl<'a> FmtVisitor<'a> {
621621
a.ident.as_str().cmp(b.ident.as_str())
622622
}
623623
(Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()),
624-
(TyAlias(ty), _) if is_type(&ty.ty) => Ordering::Less,
625-
(_, TyAlias(ty)) if is_type(&ty.ty) => Ordering::Greater,
626-
(TyAlias(..), _) => Ordering::Less,
627-
(_, TyAlias(..)) => Ordering::Greater,
624+
(Type(ty), _) if is_type(&ty.ty) => Ordering::Less,
625+
(_, Type(ty)) if is_type(&ty.ty) => Ordering::Greater,
626+
(Type(..), _) => Ordering::Less,
627+
(_, Type(..)) => Ordering::Greater,
628628
(Const(..), _) => Ordering::Less,
629629
(_, Const(..)) => Ordering::Greater,
630630
(MacCall(..), _) => Ordering::Less,

src/tools/rustfmt/src/visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
660660
self.push_rewrite(ai.span, rewrite);
661661
}
662662
}
663-
(ast::AssocItemKind::TyAlias(ref ty_alias), _) => {
663+
(ast::AssocItemKind::Type(ref ty_alias), _) => {
664664
self.visit_ty_alias_kind(ty_alias, visitor_kind, ai.span);
665665
}
666666
(ast::AssocItemKind::MacCall(ref mac), _) => {

0 commit comments

Comments
 (0)