Skip to content

Commit

Permalink
Auto merge of #63213 - varkor:itemkind-tyalias, r=Centril
Browse files Browse the repository at this point in the history
Rename `ItemKind::Ty` to `ItemKind::TyAlias`

The current name is not entirely clear without context and `TyAlias` is consistent with `ItemKind::TraitAlias`.
  • Loading branch information
bors committed Aug 4, 2019
2 parents f01b9f8 + fd819d0 commit d3f8a0b
Show file tree
Hide file tree
Showing 36 changed files with 90 additions and 89 deletions.
6 changes: 3 additions & 3 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) enum Target {
Mod,
ForeignMod,
GlobalAsm,
Ty,
TyAlias,
OpaqueTy,
Enum,
Struct,
Expand All @@ -50,7 +50,7 @@ impl Display for Target {
Target::Mod => "module",
Target::ForeignMod => "foreign module",
Target::GlobalAsm => "global asm",
Target::Ty => "type alias",
Target::TyAlias => "type alias",
Target::OpaqueTy => "opaque type",
Target::Enum => "enum",
Target::Struct => "struct",
Expand All @@ -75,7 +75,7 @@ impl Target {
hir::ItemKind::Mod(..) => Target::Mod,
hir::ItemKind::ForeignMod(..) => Target::ForeignMod,
hir::ItemKind::GlobalAsm(..) => Target::GlobalAsm,
hir::ItemKind::Ty(..) => Target::Ty,
hir::ItemKind::TyAlias(..) => Target::TyAlias,
hir::ItemKind::OpaqueTy(..) => Target::OpaqueTy,
hir::ItemKind::Enum(..) => Target::Enum,
hir::ItemKind::Struct(..) => Target::Struct,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
ItemKind::GlobalAsm(_) => {
visitor.visit_id(item.hir_id);
}
ItemKind::Ty(ref ty, ref generics) => {
ItemKind::TyAlias(ref ty, ref generics) => {
visitor.visit_id(item.hir_id);
visitor.visit_ty(ty);
visitor.visit_generics(generics)
Expand Down Expand Up @@ -926,7 +926,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
impl_item.span,
impl_item.hir_id);
}
ImplItemKind::Type(ref ty) => {
ImplItemKind::TyAlias(ref ty) => {
visitor.visit_id(impl_item.hir_id);
visitor.visit_ty(ty);
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ impl<'a> LoweringContext<'a> {
ItemKind::Struct(_, ref generics)
| ItemKind::Union(_, ref generics)
| ItemKind::Enum(_, ref generics)
| ItemKind::Ty(_, ref generics)
| ItemKind::TyAlias(_, ref generics)
| ItemKind::OpaqueTy(_, ref generics)
| ItemKind::Trait(_, _, ref generics, ..) => {
let def_id = self.lctx.resolver.definitions().local_def_id(item.id);
Expand Down Expand Up @@ -3440,7 +3440,7 @@ impl<'a> LoweringContext<'a> {
ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)),
ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)),
ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)),
ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty(
ItemKind::TyAlias(ref t, ref generics) => hir::ItemKind::TyAlias(
self.lower_ty(t, ImplTraitContext::disallowed()),
self.lower_generics(generics, ImplTraitContext::disallowed()),
),
Expand Down Expand Up @@ -3914,9 +3914,9 @@ impl<'a> LoweringContext<'a> {

(generics, hir::ImplItemKind::Method(sig, body_id))
}
ImplItemKind::Type(ref ty) => (
ImplItemKind::TyAlias(ref ty) => (
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
hir::ImplItemKind::Type(self.lower_ty(ty, ImplTraitContext::disallowed())),
hir::ImplItemKind::TyAlias(self.lower_ty(ty, ImplTraitContext::disallowed())),
),
ImplItemKind::OpaqueTy(ref bounds) => (
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
Expand Down Expand Up @@ -3950,7 +3950,7 @@ impl<'a> LoweringContext<'a> {
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
kind: match i.node {
ImplItemKind::Const(..) => hir::AssocItemKind::Const,
ImplItemKind::Type(..) => hir::AssocItemKind::Type,
ImplItemKind::TyAlias(..) => hir::AssocItemKind::Type,
ImplItemKind::OpaqueTy(..) => hir::AssocItemKind::OpaqueTy,
ImplItemKind::Method(ref sig, _) => hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
ItemKind::Mod(..) | ItemKind::Trait(..) | ItemKind::TraitAlias(..) |
ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) |
ItemKind::OpaqueTy(..) | ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) |
ItemKind::Ty(..) => DefPathData::TypeNs(i.ident.as_interned_str()),
ItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.as_interned_str()),
ItemKind::Fn(
ref decl,
ref header,
Expand Down Expand Up @@ -222,7 +222,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}
ImplItemKind::Method(..) | ImplItemKind::Const(..) =>
DefPathData::ValueNs(ii.ident.as_interned_str()),
ImplItemKind::Type(..) |
ImplItemKind::TyAlias(..) |
ImplItemKind::OpaqueTy(..) => {
DefPathData::TypeNs(ii.ident.as_interned_str())
},
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<'hir> Map<'hir> {
ItemKind::Fn(..) => DefKind::Fn,
ItemKind::Mod(..) => DefKind::Mod,
ItemKind::OpaqueTy(..) => DefKind::OpaqueTy,
ItemKind::Ty(..) => DefKind::TyAlias,
ItemKind::TyAlias(..) => DefKind::TyAlias,
ItemKind::Enum(..) => DefKind::Enum,
ItemKind::Struct(..) => DefKind::Struct,
ItemKind::Union(..) => DefKind::Union,
Expand Down Expand Up @@ -333,7 +333,7 @@ impl<'hir> Map<'hir> {
match item.node {
ImplItemKind::Const(..) => DefKind::AssocConst,
ImplItemKind::Method(..) => DefKind::Method,
ImplItemKind::Type(..) => DefKind::AssocTy,
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
}
}
Expand Down Expand Up @@ -576,7 +576,7 @@ impl<'hir> Map<'hir> {
Node::Item(ref item) => {
match item.node {
ItemKind::Fn(_, _, ref generics, _) |
ItemKind::Ty(_, ref generics) |
ItemKind::TyAlias(_, ref generics) |
ItemKind::Enum(_, ref generics) |
ItemKind::Struct(_, ref generics) |
ItemKind::Union(_, ref generics) |
Expand Down Expand Up @@ -1269,7 +1269,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
ItemKind::Mod(..) => "mod",
ItemKind::ForeignMod(..) => "foreign mod",
ItemKind::GlobalAsm(..) => "global asm",
ItemKind::Ty(..) => "ty",
ItemKind::TyAlias(..) => "ty",
ItemKind::OpaqueTy(..) => "opaque type",
ItemKind::Enum(..) => "enum",
ItemKind::Struct(..) => "struct",
Expand All @@ -1291,7 +1291,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
ImplItemKind::Method(..) => {
format!("method {} in {}{}", ii.ident, path_str(), id_str)
}
ImplItemKind::Type(_) => {
ImplItemKind::TyAlias(_) => {
format!("assoc type {} in {}{}", ii.ident, path_str(), id_str)
}
ImplItemKind::OpaqueTy(_) => {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ pub enum ImplItemKind {
/// A method implementation with the given signature and body.
Method(MethodSig, BodyId),
/// An associated type.
Type(P<Ty>),
TyAlias(P<Ty>),
/// An associated `type = impl Trait`.
OpaqueTy(GenericBounds),
}
Expand Down Expand Up @@ -2420,7 +2420,7 @@ pub enum ItemKind {
/// Module-level inline assembly (from global_asm!)
GlobalAsm(P<GlobalAsm>),
/// A type alias, e.g., `type Foo = Bar<u8>`
Ty(P<Ty>, Generics),
TyAlias(P<Ty>, Generics),
/// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;`
OpaqueTy(OpaqueTy),
/// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}`
Expand Down Expand Up @@ -2455,7 +2455,7 @@ impl ItemKind {
ItemKind::Mod(..) => "module",
ItemKind::ForeignMod(..) => "foreign module",
ItemKind::GlobalAsm(..) => "global asm",
ItemKind::Ty(..) => "type alias",
ItemKind::TyAlias(..) => "type alias",
ItemKind::OpaqueTy(..) => "opaque type",
ItemKind::Enum(..) => "enum",
ItemKind::Struct(..) => "struct",
Expand All @@ -2478,7 +2478,7 @@ impl ItemKind {
pub fn generics(&self) -> Option<&Generics> {
Some(match *self {
ItemKind::Fn(_, _, ref generics, _) |
ItemKind::Ty(_, ref generics) |
ItemKind::TyAlias(_, ref generics) |
ItemKind::OpaqueTy(OpaqueTy { ref generics, impl_trait_fn: None, .. }) |
ItemKind::Enum(_, ref generics) |
ItemKind::Struct(_, ref generics) |
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl<'a> State<'a> {
self.s.word(ga.asm.as_str().to_string());
self.end()
}
hir::ItemKind::Ty(ref ty, ref generics) => {
hir::ItemKind::TyAlias(ref ty, ref generics) => {
self.print_item_type(item, &generics, |state| {
state.word_space("=");
state.print_type(&ty);
Expand Down Expand Up @@ -908,7 +908,7 @@ impl<'a> State<'a> {
self.end(); // need to close a box
self.ann.nested(self, Nested::Body(body));
}
hir::ImplItemKind::Type(ref ty) => {
hir::ImplItemKind::TyAlias(ref ty) => {
self.print_associated_type(ii.ident, None, Some(ty));
}
hir::ImplItemKind::OpaqueTy(ref bounds) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'tcx> TyCtxt<'tcx> {
hir::ImplItemKind::Method(..) => "method body",
hir::ImplItemKind::Const(..)
| hir::ImplItemKind::OpaqueTy(..)
| hir::ImplItemKind::Type(..) => "associated item",
| hir::ImplItemKind::TyAlias(..) => "associated item",
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl DeadVisitor<'tcx> {
hir::ItemKind::Static(..)
| hir::ItemKind::Const(..)
| hir::ItemKind::Fn(..)
| hir::ItemKind::Ty(..)
| hir::ItemKind::TyAlias(..)
| hir::ItemKind::Enum(..)
| hir::ItemKind::Struct(..)
| hir::ItemKind::Union(..) => true,
Expand Down Expand Up @@ -640,7 +640,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
self.visit_nested_body(body_id)
}
hir::ImplItemKind::OpaqueTy(..) |
hir::ImplItemKind::Type(..) => {}
hir::ImplItemKind::TyAlias(..) => {}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
}
hir::ImplItemKind::OpaqueTy(..) |
hir::ImplItemKind::Type(_) => false,
hir::ImplItemKind::TyAlias(_) => false,
}
}
Some(_) => false,
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
hir::ItemKind::ExternCrate(_) |
hir::ItemKind::Use(..) |
hir::ItemKind::OpaqueTy(..) |
hir::ItemKind::Ty(..) |
hir::ItemKind::TyAlias(..) |
hir::ItemKind::Static(..) |
hir::ItemKind::Mod(..) |
hir::ItemKind::ForeignMod(..) |
Expand Down Expand Up @@ -302,7 +302,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
}
hir::ImplItemKind::OpaqueTy(..) |
hir::ImplItemKind::Type(_) => {}
hir::ImplItemKind::TyAlias(_) => {}
}
}
Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// items. Doing anything on this node is irrelevant, as we currently don't need
// it.
}
hir::ItemKind::Ty(_, ref generics)
hir::ItemKind::TyAlias(_, ref generics)
| hir::ItemKind::OpaqueTy(hir::OpaqueTy {
impl_trait_fn: None,
ref generics,
Expand Down Expand Up @@ -828,7 +828,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|this| intravisit::walk_impl_item(this, impl_item),
)
}
Type(ref ty) => {
TyAlias(ref ty) => {
let generics = &impl_item.generics;
let mut index = self.next_early_index();
let mut non_lifetime_count = 0;
Expand Down Expand Up @@ -1259,7 +1259,7 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifet
impl_trait_fn: None,
..
})
| hir::ItemKind::Ty(_, ref generics)
| hir::ItemKind::TyAlias(_, ref generics)
| hir::ItemKind::Trait(_, _, ref generics, ..) => {
let result = object_lifetime_defaults_for_item(tcx, generics);

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_incremental/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl DirtyCleanVisitor<'tcx> {
HirItem::GlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY),

// A type alias, e.g., `type Foo = Bar<u8>`
HirItem::Ty(..) => ("ItemTy", LABELS_HIR_ONLY),
HirItem::TyAlias(..) => ("ItemTy", LABELS_HIR_ONLY),

// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}`
HirItem::Enum(..) => ("ItemEnum", LABELS_ADT),
Expand Down Expand Up @@ -405,7 +405,7 @@ impl DirtyCleanVisitor<'tcx> {
match item.node {
ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
ImplItemKind::OpaqueTy(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
}
},
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
match it.node {
hir::ItemKind::Fn(..) |
hir::ItemKind::Ty(..) |
hir::ItemKind::TyAlias(..) |
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) => {
Expand Down Expand Up @@ -406,7 +406,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
}
"a trait"
}
hir::ItemKind::Ty(..) => "a type alias",
hir::ItemKind::TyAlias(..) => "a type alias",
hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) => {
// If the trait is private, add the impl items to `private_traits` so they don't get
// reported for missing docs.
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
let desc = match impl_item.node {
hir::ImplItemKind::Const(..) => "an associated constant",
hir::ImplItemKind::Method(..) => "a method",
hir::ImplItemKind::Type(_) => "an associated type",
hir::ImplItemKind::TyAlias(_) => "an associated type",
hir::ImplItemKind::OpaqueTy(_) => "an associated `impl Trait` type",
};
self.check_missing_docs_attrs(cx,
Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl TypeAliasBounds {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
let (ty, type_alias_generics) = match item.node {
hir::ItemKind::Ty(ref ty, ref generics) => (&*ty, generics),
hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics),
_ => return,
};
let mut suggested_changing_assoc_types = false;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl EarlyLintPass for NonCamelCaseTypes {
}

match it.node {
ast::ItemKind::Ty(..) |
ast::ItemKind::TyAlias(..) |
ast::ItemKind::Enum(..) |
ast::ItemKind::Struct(..) |
ast::ItemKind::Union(..) => self.check_case(cx, "type", &it.ident),
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ impl EncodeContext<'tcx> {
needs_inline || is_const_fn || always_encode_mir
},
hir::ImplItemKind::OpaqueTy(..) |
hir::ImplItemKind::Type(..) => false,
hir::ImplItemKind::TyAlias(..) => false,
};

Entry {
Expand Down Expand Up @@ -1094,7 +1094,7 @@ impl EncodeContext<'tcx> {
}
hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod,
hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm,
hir::ItemKind::Ty(..) => EntryKind::Type,
hir::ItemKind::TyAlias(..) => EntryKind::Type,
hir::ItemKind::OpaqueTy(..) => EntryKind::OpaqueTy,
hir::ItemKind::Enum(..) => EntryKind::Enum(get_repr_options(tcx, def_id)),
hir::ItemKind::Struct(ref struct_def, _) => {
Expand Down Expand Up @@ -1227,7 +1227,7 @@ impl EncodeContext<'tcx> {
hir::ItemKind::Static(..) |
hir::ItemKind::Const(..) |
hir::ItemKind::Fn(..) |
hir::ItemKind::Ty(..) |
hir::ItemKind::TyAlias(..) |
hir::ItemKind::OpaqueTy(..) |
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
Expand All @@ -1247,7 +1247,7 @@ impl EncodeContext<'tcx> {
hir::ItemKind::Static(..) |
hir::ItemKind::Const(..) |
hir::ItemKind::Fn(..) |
hir::ItemKind::Ty(..) |
hir::ItemKind::TyAlias(..) |
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) |
Expand All @@ -1261,7 +1261,7 @@ impl EncodeContext<'tcx> {
hir::ItemKind::Static(..) |
hir::ItemKind::Const(..) |
hir::ItemKind::Fn(..) |
hir::ItemKind::Ty(..) |
hir::ItemKind::TyAlias(..) |
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) |
Expand Down Expand Up @@ -1761,7 +1761,7 @@ impl EncodeContext<'tcx> {
hir::ItemKind::GlobalAsm(..) |
hir::ItemKind::ExternCrate(..) |
hir::ItemKind::Use(..) |
hir::ItemKind::Ty(..) |
hir::ItemKind::TyAlias(..) |
hir::ItemKind::OpaqueTy(..) |
hir::ItemKind::TraitAlias(..) => {
// no sub-item recording needed in these cases
Expand Down
Loading

0 comments on commit d3f8a0b

Please sign in to comment.