Reorder fields in hir::ItemKind variants.
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
This commit is contained in:
@@ -164,7 +164,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
fn visit_item(&mut self, i: &'hir Item<'hir>) {
|
||||
debug_assert_eq!(i.owner_id, self.owner);
|
||||
self.with_parent(i.hir_id(), |this| {
|
||||
if let ItemKind::Struct(_, struct_def, _) = &i.kind {
|
||||
if let ItemKind::Struct(_, _, struct_def) = &i.kind {
|
||||
// If this is a tuple or unit-like struct, register the constructor.
|
||||
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
|
||||
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));
|
||||
|
||||
@@ -180,7 +180,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let (ty, body_id) =
|
||||
self.lower_const_item(t, span, e.as_deref(), ImplTraitPosition::StaticTy);
|
||||
self.lower_define_opaque(hir_id, define_opaque);
|
||||
hir::ItemKind::Static(ident, ty, *m, body_id)
|
||||
hir::ItemKind::Static(*m, ident, ty, body_id)
|
||||
}
|
||||
ItemKind::Const(box ast::ConstItem {
|
||||
ident,
|
||||
@@ -200,7 +200,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
},
|
||||
);
|
||||
self.lower_define_opaque(hir_id, &define_opaque);
|
||||
hir::ItemKind::Const(ident, ty, generics, body_id)
|
||||
hir::ItemKind::Const(ident, generics, ty, body_id)
|
||||
}
|
||||
ItemKind::Fn(box Fn {
|
||||
sig: FnSig { decl, header, span: fn_sig_span },
|
||||
@@ -304,7 +304,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
),
|
||||
},
|
||||
);
|
||||
hir::ItemKind::TyAlias(ident, ty, generics)
|
||||
hir::ItemKind::TyAlias(ident, generics, ty)
|
||||
}
|
||||
ItemKind::Enum(ident, generics, enum_definition) => {
|
||||
let ident = self.lower_ident(*ident);
|
||||
@@ -318,7 +318,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
)
|
||||
},
|
||||
);
|
||||
hir::ItemKind::Enum(ident, hir::EnumDef { variants }, generics)
|
||||
hir::ItemKind::Enum(ident, generics, hir::EnumDef { variants })
|
||||
}
|
||||
ItemKind::Struct(ident, generics, struct_def) => {
|
||||
let ident = self.lower_ident(*ident);
|
||||
@@ -328,7 +328,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
||||
|this| this.lower_variant_data(hir_id, struct_def),
|
||||
);
|
||||
hir::ItemKind::Struct(ident, struct_def, generics)
|
||||
hir::ItemKind::Struct(ident, generics, struct_def)
|
||||
}
|
||||
ItemKind::Union(ident, generics, vdata) => {
|
||||
let ident = self.lower_ident(*ident);
|
||||
@@ -338,7 +338,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
||||
|this| this.lower_variant_data(hir_id, vdata),
|
||||
);
|
||||
hir::ItemKind::Union(ident, vdata, generics)
|
||||
hir::ItemKind::Union(ident, generics, vdata)
|
||||
}
|
||||
ItemKind::Impl(box Impl {
|
||||
safety,
|
||||
|
||||
@@ -4106,11 +4106,11 @@ impl<'hir> Item<'hir> {
|
||||
|
||||
expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
|
||||
|
||||
expect_static, (Ident, &'hir Ty<'hir>, Mutability, BodyId),
|
||||
ItemKind::Static(ident, ty, mutbl, body), (*ident, ty, *mutbl, *body);
|
||||
expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
|
||||
ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
|
||||
|
||||
expect_const, (Ident, &'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
|
||||
ItemKind::Const(ident, ty, generics, body), (*ident, ty, generics, *body);
|
||||
expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, BodyId),
|
||||
ItemKind::Const(ident, generics, ty, body), (*ident, generics, ty, *body);
|
||||
|
||||
expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
|
||||
ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
|
||||
@@ -4125,17 +4125,17 @@ impl<'hir> Item<'hir> {
|
||||
|
||||
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
|
||||
|
||||
expect_ty_alias, (Ident, &'hir Ty<'hir>, &'hir Generics<'hir>),
|
||||
ItemKind::TyAlias(ident, ty, generics), (*ident, ty, generics);
|
||||
expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
|
||||
ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
|
||||
|
||||
expect_enum, (Ident, &EnumDef<'hir>, &'hir Generics<'hir>),
|
||||
ItemKind::Enum(ident, def, generics), (*ident, def, generics);
|
||||
expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
|
||||
ItemKind::Enum(ident, generics, def), (*ident, generics, def);
|
||||
|
||||
expect_struct, (Ident, &VariantData<'hir>, &'hir Generics<'hir>),
|
||||
ItemKind::Struct(ident, data, generics), (*ident, data, generics);
|
||||
expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
|
||||
ItemKind::Struct(ident, generics, data), (*ident, generics, data);
|
||||
|
||||
expect_union, (Ident, &VariantData<'hir>, &'hir Generics<'hir>),
|
||||
ItemKind::Union(ident, data, generics), (*ident, data, generics);
|
||||
expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
|
||||
ItemKind::Union(ident, generics, data), (*ident, generics, data);
|
||||
|
||||
expect_trait,
|
||||
(
|
||||
@@ -4278,9 +4278,9 @@ pub enum ItemKind<'hir> {
|
||||
Use(&'hir UsePath<'hir>, UseKind),
|
||||
|
||||
/// A `static` item.
|
||||
Static(Ident, &'hir Ty<'hir>, Mutability, BodyId),
|
||||
Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
|
||||
/// A `const` item.
|
||||
Const(Ident, &'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
|
||||
Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, BodyId),
|
||||
/// A function declaration.
|
||||
Fn {
|
||||
ident: Ident,
|
||||
@@ -4309,13 +4309,13 @@ pub enum ItemKind<'hir> {
|
||||
fake_body: BodyId,
|
||||
},
|
||||
/// A type alias, e.g., `type Foo = Bar<u8>`.
|
||||
TyAlias(Ident, &'hir Ty<'hir>, &'hir Generics<'hir>),
|
||||
TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
|
||||
/// An enum definition, e.g., `enum Foo<A, B> { C<A>, D<B> }`.
|
||||
Enum(Ident, EnumDef<'hir>, &'hir Generics<'hir>),
|
||||
Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
|
||||
/// A struct definition, e.g., `struct Foo<A> {x: A}`.
|
||||
Struct(Ident, VariantData<'hir>, &'hir Generics<'hir>),
|
||||
Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
|
||||
/// A union definition, e.g., `union Foo<A, B> {x: A, y: B}`.
|
||||
Union(Ident, VariantData<'hir>, &'hir Generics<'hir>),
|
||||
Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
|
||||
/// A trait definition.
|
||||
Trait(IsAuto, Safety, Ident, &'hir Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemRef]),
|
||||
/// A trait alias.
|
||||
@@ -4352,7 +4352,7 @@ impl ItemKind<'_> {
|
||||
match *self {
|
||||
ItemKind::ExternCrate(_, ident)
|
||||
| ItemKind::Use(_, UseKind::Single(ident))
|
||||
| ItemKind::Static(ident, ..)
|
||||
| ItemKind::Static(_, ident, ..)
|
||||
| ItemKind::Const(ident, ..)
|
||||
| ItemKind::Fn { ident, .. }
|
||||
| ItemKind::Macro(ident, ..)
|
||||
@@ -4374,11 +4374,11 @@ impl ItemKind<'_> {
|
||||
pub fn generics(&self) -> Option<&Generics<'_>> {
|
||||
Some(match self {
|
||||
ItemKind::Fn { generics, .. }
|
||||
| ItemKind::TyAlias(_, _, generics)
|
||||
| ItemKind::Const(_, _, generics, _)
|
||||
| ItemKind::Enum(_, _, generics)
|
||||
| ItemKind::Struct(_, _, generics)
|
||||
| ItemKind::Union(_, _, generics)
|
||||
| ItemKind::TyAlias(_, generics, _)
|
||||
| ItemKind::Const(_, generics, _, _)
|
||||
| ItemKind::Enum(_, generics, _)
|
||||
| ItemKind::Struct(_, generics, _)
|
||||
| ItemKind::Union(_, generics, _)
|
||||
| ItemKind::Trait(_, _, _, generics, _, _)
|
||||
| ItemKind::TraitAlias(_, generics, _)
|
||||
| ItemKind::Impl(Impl { generics, .. }) => generics,
|
||||
@@ -4802,9 +4802,9 @@ impl<'hir> Node<'hir> {
|
||||
pub fn ty(self) -> Option<&'hir Ty<'hir>> {
|
||||
match self {
|
||||
Node::Item(it) => match it.kind {
|
||||
ItemKind::TyAlias(_, ty, _)
|
||||
| ItemKind::Static(_, ty, _, _)
|
||||
| ItemKind::Const(_, ty, _, _) => Some(ty),
|
||||
ItemKind::TyAlias(_, _, ty)
|
||||
| ItemKind::Static(_, _, ty, _)
|
||||
| ItemKind::Const(_, _, ty, _) => Some(ty),
|
||||
ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
|
||||
_ => None,
|
||||
},
|
||||
@@ -4824,7 +4824,7 @@ impl<'hir> Node<'hir> {
|
||||
|
||||
pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
|
||||
match self {
|
||||
Node::Item(Item { kind: ItemKind::TyAlias(_, ty, _), .. }) => Some(ty),
|
||||
Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,15 +545,15 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
||||
UseKind::Glob | UseKind::ListStem => {}
|
||||
}
|
||||
}
|
||||
ItemKind::Static(ident, ref typ, _, body) => {
|
||||
ItemKind::Static(_, ident, ref typ, body) => {
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
try_visit!(visitor.visit_ty_unambig(typ));
|
||||
try_visit!(visitor.visit_nested_body(body));
|
||||
}
|
||||
ItemKind::Const(ident, ref typ, ref generics, body) => {
|
||||
ItemKind::Const(ident, ref generics, ref typ, body) => {
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
try_visit!(visitor.visit_ty_unambig(typ));
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_ty_unambig(typ));
|
||||
try_visit!(visitor.visit_nested_body(body));
|
||||
}
|
||||
ItemKind::Fn { ident, sig, generics, body: body_id, .. } => {
|
||||
@@ -583,12 +583,12 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
||||
// typeck results set correctly.
|
||||
try_visit!(visitor.visit_nested_body(fake_body));
|
||||
}
|
||||
ItemKind::TyAlias(ident, ref ty, ref generics) => {
|
||||
ItemKind::TyAlias(ident, ref generics, ref ty) => {
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
try_visit!(visitor.visit_ty_unambig(ty));
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_ty_unambig(ty));
|
||||
}
|
||||
ItemKind::Enum(ident, ref enum_definition, ref generics) => {
|
||||
ItemKind::Enum(ident, ref generics, ref enum_definition) => {
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_enum_def(enum_definition));
|
||||
@@ -609,8 +609,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
||||
try_visit!(visitor.visit_ty_unambig(self_ty));
|
||||
walk_list!(visitor, visit_impl_item_ref, *items);
|
||||
}
|
||||
ItemKind::Struct(ident, ref struct_definition, ref generics)
|
||||
| ItemKind::Union(ident, ref struct_definition, ref generics) => {
|
||||
ItemKind::Struct(ident, ref generics, ref struct_definition)
|
||||
| ItemKind::Union(ident, ref generics, ref struct_definition) => {
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_variant_data(struct_definition));
|
||||
|
||||
@@ -297,32 +297,30 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
||||
hir::ItemKind::Fn { ident, sig, .. } => {
|
||||
check_item_fn(tcx, def_id, ident, item.span, sig.decl)
|
||||
}
|
||||
hir::ItemKind::Static(_, ty, ..) => {
|
||||
hir::ItemKind::Static(_, _, ty, _) => {
|
||||
check_static_item(tcx, def_id, ty.span, UnsizedHandling::Forbid)
|
||||
}
|
||||
hir::ItemKind::Const(_, ty, ..) => check_const_item(tcx, def_id, ty.span, item.span),
|
||||
hir::ItemKind::Struct(_, _, hir_generics) => {
|
||||
hir::ItemKind::Const(_, _, ty, _) => check_const_item(tcx, def_id, ty.span, item.span),
|
||||
hir::ItemKind::Struct(_, generics, _) => {
|
||||
let res = check_type_defn(tcx, item, false);
|
||||
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||
check_variances_for_type_defn(tcx, item, generics);
|
||||
res
|
||||
}
|
||||
hir::ItemKind::Union(_, _, hir_generics) => {
|
||||
hir::ItemKind::Union(_, generics, _) => {
|
||||
let res = check_type_defn(tcx, item, true);
|
||||
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||
check_variances_for_type_defn(tcx, item, generics);
|
||||
res
|
||||
}
|
||||
hir::ItemKind::Enum(_, _, hir_generics) => {
|
||||
hir::ItemKind::Enum(_, generics, _) => {
|
||||
let res = check_type_defn(tcx, item, true);
|
||||
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||
check_variances_for_type_defn(tcx, item, generics);
|
||||
res
|
||||
}
|
||||
hir::ItemKind::Trait(..) => check_trait(tcx, item),
|
||||
hir::ItemKind::TraitAlias(..) => check_trait(tcx, item),
|
||||
// `ForeignItem`s are handled separately.
|
||||
hir::ItemKind::ForeignMod { .. } => Ok(()),
|
||||
hir::ItemKind::TyAlias(_, hir_ty, hir_generics)
|
||||
if tcx.type_alias_is_lazy(item.owner_id) =>
|
||||
{
|
||||
hir::ItemKind::TyAlias(_, generics, hir_ty) if tcx.type_alias_is_lazy(item.owner_id) => {
|
||||
let res = enter_wf_checking_ctxt(tcx, item.span, def_id, |wfcx| {
|
||||
let ty = tcx.type_of(def_id).instantiate_identity();
|
||||
let item_ty =
|
||||
@@ -335,7 +333,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
||||
check_where_clauses(wfcx, item.span, def_id);
|
||||
Ok(())
|
||||
});
|
||||
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||
check_variances_for_type_defn(tcx, item, generics);
|
||||
res
|
||||
}
|
||||
_ => Ok(()),
|
||||
|
||||
@@ -248,13 +248,13 @@ fn reject_placeholder_type_signatures_in_item<'tcx>(
|
||||
item: &'tcx hir::Item<'tcx>,
|
||||
) {
|
||||
let (generics, suggest) = match &item.kind {
|
||||
hir::ItemKind::Union(_, _, generics)
|
||||
| hir::ItemKind::Enum(_, _, generics)
|
||||
hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::TraitAlias(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::Impl(hir::Impl { generics, .. })
|
||||
| hir::ItemKind::Struct(_, _, generics) => (generics, true),
|
||||
hir::ItemKind::TyAlias(_, _, generics) => (generics, false),
|
||||
| hir::ItemKind::Struct(_, generics, _) => (generics, true),
|
||||
hir::ItemKind::TyAlias(_, generics, _) => (generics, false),
|
||||
// `static`, `fn` and `const` are handled elsewhere to suggest appropriate type.
|
||||
_ => return,
|
||||
};
|
||||
@@ -470,9 +470,9 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
||||
.tcx
|
||||
.hir_expect_item(self.tcx.hir_get_parent_item(self.hir_id()).def_id);
|
||||
match &item.kind {
|
||||
hir::ItemKind::Enum(_, _, generics)
|
||||
| hir::ItemKind::Struct(_, _, generics)
|
||||
| hir::ItemKind::Union(_, _, generics) => {
|
||||
hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _) => {
|
||||
let lt_name = get_new_lifetime_name(self.tcx, poly_trait_ref, generics);
|
||||
let (lt_sp, sugg) = match generics.params {
|
||||
[] => (generics.span, format!("<{lt_name}>")),
|
||||
@@ -740,7 +740,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
||||
tcx.at(it.span).explicit_super_predicates_of(def_id);
|
||||
tcx.ensure_ok().predicates_of(def_id);
|
||||
}
|
||||
hir::ItemKind::Struct(_, struct_def, _) | hir::ItemKind::Union(_, struct_def, _) => {
|
||||
hir::ItemKind::Struct(_, _, struct_def) | hir::ItemKind::Union(_, _, struct_def) => {
|
||||
tcx.ensure_ok().generics_of(def_id);
|
||||
tcx.ensure_ok().type_of(def_id);
|
||||
tcx.ensure_ok().predicates_of(def_id);
|
||||
@@ -762,7 +762,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
||||
tcx.ensure_ok().predicates_of(def_id);
|
||||
}
|
||||
|
||||
hir::ItemKind::Static(_, ty, ..) | hir::ItemKind::Const(_, ty, ..) => {
|
||||
hir::ItemKind::Static(_, _, ty, _) | hir::ItemKind::Const(_, _, ty, _) => {
|
||||
tcx.ensure_ok().generics_of(def_id);
|
||||
tcx.ensure_ok().type_of(def_id);
|
||||
tcx.ensure_ok().predicates_of(def_id);
|
||||
@@ -1093,7 +1093,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
|
||||
|
||||
let repr = tcx.repr_options_of_def(def_id);
|
||||
let (kind, variants) = match &item.kind {
|
||||
ItemKind::Enum(_, def, _) => {
|
||||
ItemKind::Enum(_, _, def) => {
|
||||
let mut distance_from_explicit = 0;
|
||||
let variants = def
|
||||
.variants
|
||||
@@ -1121,7 +1121,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
|
||||
|
||||
(AdtKind::Enum, variants)
|
||||
}
|
||||
ItemKind::Struct(ident, def, _) | ItemKind::Union(ident, def, _) => {
|
||||
ItemKind::Struct(ident, _, def) | ItemKind::Union(ident, _, def) => {
|
||||
let adt_kind = match item.kind {
|
||||
ItemKind::Struct(..) => AdtKind::Struct,
|
||||
_ => AdtKind::Union,
|
||||
|
||||
@@ -634,11 +634,11 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||
// These sorts of items have no lifetime parameters at all.
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
hir::ItemKind::TyAlias(_, _, generics)
|
||||
| hir::ItemKind::Const(_, _, generics, _)
|
||||
| hir::ItemKind::Enum(_, _, generics)
|
||||
| hir::ItemKind::Struct(_, _, generics)
|
||||
| hir::ItemKind::Union(_, _, generics)
|
||||
hir::ItemKind::TyAlias(_, generics, _)
|
||||
| hir::ItemKind::Const(_, generics, _, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::TraitAlias(_, generics, ..)
|
||||
| hir::ItemKind::Impl(&hir::Impl { generics, .. }) => {
|
||||
|
||||
@@ -206,7 +206,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
|
||||
},
|
||||
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::Static(ident, ty, .., body_id) => {
|
||||
ItemKind::Static(_, ident, ty, body_id) => {
|
||||
if ty.is_suggestable_infer_ty() {
|
||||
infer_placeholder_type(
|
||||
icx.lowerer(),
|
||||
@@ -220,7 +220,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
|
||||
icx.lower_ty(ty)
|
||||
}
|
||||
}
|
||||
ItemKind::Const(ident, ty, _, body_id) => {
|
||||
ItemKind::Const(ident, _, ty, body_id) => {
|
||||
if ty.is_suggestable_infer_ty() {
|
||||
infer_placeholder_type(
|
||||
icx.lowerer(),
|
||||
@@ -234,7 +234,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
|
||||
icx.lower_ty(ty)
|
||||
}
|
||||
}
|
||||
ItemKind::TyAlias(_, self_ty, _) => icx.lower_ty(self_ty),
|
||||
ItemKind::TyAlias(_, _, self_ty) => icx.lower_ty(self_ty),
|
||||
ItemKind::Impl(hir::Impl { self_ty, .. }) => match self_ty.find_self_aliases() {
|
||||
spans if spans.len() > 0 => {
|
||||
let guar = tcx
|
||||
@@ -532,5 +532,5 @@ pub(crate) fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) ->
|
||||
}
|
||||
}
|
||||
}
|
||||
HasTait.visit_ty_unambig(tcx.hir_expect_item(def_id).expect_ty_alias().1).is_break()
|
||||
HasTait.visit_ty_unambig(tcx.hir_expect_item(def_id).expect_ty_alias().2).is_break()
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
|
||||
let generics = match tcx.hir_node_by_def_id(parent_item) {
|
||||
hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Struct(_, variant, generics),
|
||||
kind: hir::ItemKind::Struct(_, generics, variant),
|
||||
..
|
||||
}) => {
|
||||
if !variant.fields().iter().any(|field| field.hir_id == parent_hir_id) {
|
||||
@@ -149,7 +149,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
}
|
||||
generics
|
||||
}
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Enum(_, def, generics), .. }) => {
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Enum(_, generics, def), .. }) => {
|
||||
if !def
|
||||
.variants
|
||||
.iter()
|
||||
@@ -269,7 +269,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
hir::Node::Field(field) => {
|
||||
// Enums can't have unsized fields, fields can only have an unsized tail field.
|
||||
if let hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Struct(_, variant, _), ..
|
||||
kind: hir::ItemKind::Struct(_, _, variant), ..
|
||||
}) = tcx.parent_hir_node(field.hir_id)
|
||||
&& variant
|
||||
.fields()
|
||||
|
||||
@@ -145,9 +145,9 @@ fn diagnostic_hir_wf_check<'tcx>(
|
||||
ref item => bug!("Unexpected TraitItem {:?}", item),
|
||||
},
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::TyAlias(_, ty, _)
|
||||
| hir::ItemKind::Static(_, ty, _, _)
|
||||
| hir::ItemKind::Const(_, ty, _, _) => vec![ty],
|
||||
hir::ItemKind::TyAlias(_, _, ty)
|
||||
| hir::ItemKind::Static(_, _, ty, _)
|
||||
| hir::ItemKind::Const(_, _, ty, _) => vec![ty],
|
||||
hir::ItemKind::Impl(impl_) => match &impl_.of_trait {
|
||||
Some(t) => t
|
||||
.path
|
||||
|
||||
@@ -593,7 +593,7 @@ impl<'a> State<'a> {
|
||||
self.end(ib);
|
||||
self.end(cb);
|
||||
}
|
||||
hir::ItemKind::Static(ident, ty, m, expr) => {
|
||||
hir::ItemKind::Static(m, ident, ty, expr) => {
|
||||
let (cb, ib) = self.head("static");
|
||||
if m.is_mut() {
|
||||
self.word_space("mut");
|
||||
@@ -609,7 +609,7 @@ impl<'a> State<'a> {
|
||||
self.word(";");
|
||||
self.end(cb);
|
||||
}
|
||||
hir::ItemKind::Const(ident, ty, generics, expr) => {
|
||||
hir::ItemKind::Const(ident, generics, ty, expr) => {
|
||||
let (cb, ib) = self.head("const");
|
||||
self.print_ident(ident);
|
||||
self.print_generic_params(generics.params);
|
||||
@@ -660,7 +660,7 @@ impl<'a> State<'a> {
|
||||
self.end(cb);
|
||||
self.end(ib);
|
||||
}
|
||||
hir::ItemKind::TyAlias(ident, ty, generics) => {
|
||||
hir::ItemKind::TyAlias(ident, generics, ty) => {
|
||||
let (cb, ib) = self.head("type");
|
||||
self.print_ident(ident);
|
||||
self.print_generic_params(generics.params);
|
||||
@@ -673,16 +673,16 @@ impl<'a> State<'a> {
|
||||
self.word(";");
|
||||
self.end(cb);
|
||||
}
|
||||
hir::ItemKind::Enum(ident, ref enum_definition, params) => {
|
||||
self.print_enum_def(enum_definition, params, ident.name, item.span);
|
||||
hir::ItemKind::Enum(ident, generics, ref enum_def) => {
|
||||
self.print_enum_def(ident.name, generics, enum_def, item.span);
|
||||
}
|
||||
hir::ItemKind::Struct(ident, ref struct_def, generics) => {
|
||||
hir::ItemKind::Struct(ident, generics, ref struct_def) => {
|
||||
let (cb, ib) = self.head("struct");
|
||||
self.print_struct(struct_def, generics, ident.name, item.span, true, cb, ib);
|
||||
self.print_struct(ident.name, generics, struct_def, item.span, true, cb, ib);
|
||||
}
|
||||
hir::ItemKind::Union(ident, ref struct_def, generics) => {
|
||||
hir::ItemKind::Union(ident, generics, ref struct_def) => {
|
||||
let (cb, ib) = self.head("union");
|
||||
self.print_struct(struct_def, generics, ident.name, item.span, true, cb, ib);
|
||||
self.print_struct(ident.name, generics, struct_def, item.span, true, cb, ib);
|
||||
}
|
||||
hir::ItemKind::Impl(&hir::Impl {
|
||||
constness,
|
||||
@@ -791,9 +791,9 @@ impl<'a> State<'a> {
|
||||
|
||||
fn print_enum_def(
|
||||
&mut self,
|
||||
enum_definition: &hir::EnumDef<'_>,
|
||||
generics: &hir::Generics<'_>,
|
||||
name: Symbol,
|
||||
generics: &hir::Generics<'_>,
|
||||
enum_def: &hir::EnumDef<'_>,
|
||||
span: rustc_span::Span,
|
||||
) {
|
||||
let (cb, ib) = self.head("enum");
|
||||
@@ -801,7 +801,7 @@ impl<'a> State<'a> {
|
||||
self.print_generic_params(generics.params);
|
||||
self.print_where_clause(generics);
|
||||
self.space();
|
||||
self.print_variants(enum_definition.variants, span, cb, ib);
|
||||
self.print_variants(enum_def.variants, span, cb, ib);
|
||||
}
|
||||
|
||||
fn print_variants(
|
||||
@@ -834,9 +834,9 @@ impl<'a> State<'a> {
|
||||
|
||||
fn print_struct(
|
||||
&mut self,
|
||||
struct_def: &hir::VariantData<'_>,
|
||||
generics: &hir::Generics<'_>,
|
||||
name: Symbol,
|
||||
generics: &hir::Generics<'_>,
|
||||
struct_def: &hir::VariantData<'_>,
|
||||
span: rustc_span::Span,
|
||||
print_finalizer: bool,
|
||||
cb: BoxMarker,
|
||||
@@ -886,7 +886,7 @@ impl<'a> State<'a> {
|
||||
pub fn print_variant(&mut self, v: &hir::Variant<'_>) {
|
||||
let (cb, ib) = self.head("");
|
||||
let generics = hir::Generics::empty();
|
||||
self.print_struct(&v.data, generics, v.ident.name, v.span, false, cb, ib);
|
||||
self.print_struct(v.ident.name, generics, &v.data, v.span, false, cb, ib);
|
||||
if let Some(ref d) = v.disr_expr {
|
||||
self.space();
|
||||
self.word_space("=");
|
||||
|
||||
@@ -722,8 +722,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
)) => {
|
||||
if let Some(hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Static(ident, ty, ..)
|
||||
| hir::ItemKind::Const(ident, ty, ..),
|
||||
hir::ItemKind::Static(_, ident, ty, _)
|
||||
| hir::ItemKind::Const(ident, _, ty, _),
|
||||
..
|
||||
})) = self.tcx.hir_get_if_local(*def_id)
|
||||
{
|
||||
|
||||
@@ -545,22 +545,22 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
|
||||
return;
|
||||
}
|
||||
let (def, ty) = match item.kind {
|
||||
hir::ItemKind::Struct(_, _, ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
hir::ItemKind::Struct(_, generics, _) => {
|
||||
if !generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(item.owner_id);
|
||||
(def, Ty::new_adt(cx.tcx, def, ty::List::empty()))
|
||||
}
|
||||
hir::ItemKind::Union(_, _, ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
hir::ItemKind::Union(_, generics, _) => {
|
||||
if !generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(item.owner_id);
|
||||
(def, Ty::new_adt(cx.tcx, def, ty::List::empty()))
|
||||
}
|
||||
hir::ItemKind::Enum(_, _, ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
hir::ItemKind::Enum(_, generics, _) => {
|
||||
if !generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(item.owner_id);
|
||||
@@ -1422,7 +1422,7 @@ impl TypeAliasBounds {
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
let hir::ItemKind::TyAlias(_, hir_ty, generics) = item.kind else { return };
|
||||
let hir::ItemKind::TyAlias(_, generics, hir_ty) = item.kind else { return };
|
||||
|
||||
// There must not be a where clause.
|
||||
if generics.predicates.is_empty() {
|
||||
@@ -2125,9 +2125,9 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
|
||||
|
||||
let def_id = item.owner_id.def_id;
|
||||
if let hir::ItemKind::Struct(_, _, hir_generics)
|
||||
| hir::ItemKind::Enum(_, _, hir_generics)
|
||||
| hir::ItemKind::Union(_, _, hir_generics) = item.kind
|
||||
if let hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _) = item.kind
|
||||
{
|
||||
let inferred_outlives = cx.tcx.inferred_outlives_of(def_id);
|
||||
if inferred_outlives.is_empty() {
|
||||
@@ -2135,7 +2135,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
}
|
||||
|
||||
let ty_generics = cx.tcx.generics_of(def_id);
|
||||
let num_where_predicates = hir_generics
|
||||
let num_where_predicates = generics
|
||||
.predicates
|
||||
.iter()
|
||||
.filter(|predicate| predicate.kind.in_where_clause())
|
||||
@@ -2145,7 +2145,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
let mut lint_spans = Vec::new();
|
||||
let mut where_lint_spans = Vec::new();
|
||||
let mut dropped_where_predicate_count = 0;
|
||||
for (i, where_predicate) in hir_generics.predicates.iter().enumerate() {
|
||||
for (i, where_predicate) in generics.predicates.iter().enumerate() {
|
||||
let (relevant_lifetimes, bounds, predicate_span, in_where_clause) =
|
||||
match where_predicate.kind {
|
||||
hir::WherePredicateKind::RegionPredicate(predicate) => {
|
||||
@@ -2228,7 +2228,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
} else if i + 1 < num_where_predicates {
|
||||
// If all the bounds on a predicate were inferable and there are
|
||||
// further predicates, we want to eat the trailing comma.
|
||||
let next_predicate_span = hir_generics.predicates[i + 1].span;
|
||||
let next_predicate_span = generics.predicates[i + 1].span;
|
||||
if next_predicate_span.from_expansion() {
|
||||
where_lint_spans.push(predicate_span);
|
||||
} else {
|
||||
@@ -2237,7 +2237,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
}
|
||||
} else {
|
||||
// Eat the optional trailing comma after the last predicate.
|
||||
let where_span = hir_generics.where_clause_span;
|
||||
let where_span = generics.where_clause_span;
|
||||
if where_span.from_expansion() {
|
||||
where_lint_spans.push(predicate_span);
|
||||
} else {
|
||||
@@ -2255,18 +2255,18 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
|
||||
// If all predicates in where clause are inferable, drop the entire clause
|
||||
// (including the `where`)
|
||||
if hir_generics.has_where_clause_predicates
|
||||
if generics.has_where_clause_predicates
|
||||
&& dropped_where_predicate_count == num_where_predicates
|
||||
{
|
||||
let where_span = hir_generics.where_clause_span;
|
||||
let where_span = generics.where_clause_span;
|
||||
// Extend the where clause back to the closing `>` of the
|
||||
// generics, except for tuple struct, which have the `where`
|
||||
// after the fields of the struct.
|
||||
let full_where_span =
|
||||
if let hir::ItemKind::Struct(_, hir::VariantData::Tuple(..), _) = item.kind {
|
||||
if let hir::ItemKind::Struct(_, _, hir::VariantData::Tuple(..)) = item.kind {
|
||||
where_span
|
||||
} else {
|
||||
hir_generics.span.shrink_to_hi().to(where_span)
|
||||
generics.span.shrink_to_hi().to(where_span)
|
||||
};
|
||||
|
||||
// Due to macro expansions, the `full_where_span` might not actually contain all
|
||||
|
||||
@@ -95,8 +95,8 @@ impl<'tcx> LateLintPass<'tcx> for DefaultCouldBeDerived {
|
||||
kind:
|
||||
hir::ItemKind::Struct(
|
||||
_,
|
||||
hir::VariantData::Struct { fields, recovered: _ },
|
||||
_generics,
|
||||
hir::VariantData::Struct { fields, recovered: _ },
|
||||
),
|
||||
..
|
||||
})) => fields.iter().map(|f| (f.ident.name, f)).collect::<FxHashMap<_, _>>(),
|
||||
|
||||
@@ -183,7 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
|
||||
&& parent_opt_item_name != Some(kw::Underscore)
|
||||
&& let Some(parent) = parent.as_local()
|
||||
&& let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent)
|
||||
&& let ItemKind::Const(ident, ty, _, _) = item.kind
|
||||
&& let ItemKind::Const(ident, _, ty, _) = item.kind
|
||||
&& let TyKind::Tup(&[]) = ty.kind
|
||||
{
|
||||
Some(ident.span)
|
||||
|
||||
@@ -513,7 +513,7 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
let attrs = cx.tcx.hir_attrs(it.hir_id());
|
||||
match it.kind {
|
||||
hir::ItemKind::Static(ident, ..)
|
||||
hir::ItemKind::Static(_, ident, ..)
|
||||
if !ast::attr::contains_name(attrs, sym::no_mangle) =>
|
||||
{
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "static variable", &ident);
|
||||
|
||||
@@ -1710,7 +1710,7 @@ impl ImproperCTypesDefinitions {
|
||||
&& cx.tcx.sess.target.os == "aix"
|
||||
&& !adt_def.all_fields().next().is_none()
|
||||
{
|
||||
let struct_variant_data = item.expect_struct().1;
|
||||
let struct_variant_data = item.expect_struct().2;
|
||||
for field_def in struct_variant_data.fields().iter().skip(1) {
|
||||
// Struct fields (after the first field) are checked for the
|
||||
// power alignment rule, as fields after the first are likely
|
||||
@@ -1735,9 +1735,9 @@ impl ImproperCTypesDefinitions {
|
||||
impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDefinitions {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
match item.kind {
|
||||
hir::ItemKind::Static(_, ty, ..)
|
||||
| hir::ItemKind::Const(_, ty, ..)
|
||||
| hir::ItemKind::TyAlias(_, ty, ..) => {
|
||||
hir::ItemKind::Static(_, _, ty, _)
|
||||
| hir::ItemKind::Const(_, _, ty, _)
|
||||
| hir::ItemKind::TyAlias(_, _, ty) => {
|
||||
self.check_ty_maybe_containing_foreign_fnptr(
|
||||
cx,
|
||||
ty,
|
||||
@@ -1804,7 +1804,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
if let hir::ItemKind::Enum(_, ref enum_definition, _) = it.kind {
|
||||
if let hir::ItemKind::Enum(_, _, ref enum_definition) = it.kind {
|
||||
let t = cx.tcx.type_of(it.owner_id).instantiate_identity();
|
||||
let ty = cx.tcx.erase_regions(t);
|
||||
let Ok(layout) = cx.layout_of(ty) else { return };
|
||||
|
||||
@@ -920,7 +920,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}) => until_within(*outer_span, generics.where_clause_span),
|
||||
// Constants and Statics.
|
||||
Node::Item(Item {
|
||||
kind: ItemKind::Const(_, ty, ..) | ItemKind::Static(_, ty, ..),
|
||||
kind: ItemKind::Const(_, _, ty, _) | ItemKind::Static(_, _, ty, _),
|
||||
span: outer_span,
|
||||
..
|
||||
})
|
||||
|
||||
@@ -558,7 +558,7 @@ fn construct_const<'a, 'tcx>(
|
||||
// Figure out what primary body this item has.
|
||||
let (span, const_ty_span) = match tcx.hir_node(hir_id) {
|
||||
Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Static(_, ty, _, _) | hir::ItemKind::Const(_, ty, _, _),
|
||||
kind: hir::ItemKind::Static(_, _, ty, _) | hir::ItemKind::Const(_, _, ty, _),
|
||||
span,
|
||||
..
|
||||
})
|
||||
|
||||
@@ -802,7 +802,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
match target {
|
||||
Target::Struct => {
|
||||
if let Some(ItemLike::Item(hir::Item {
|
||||
kind: hir::ItemKind::Struct(_, hir::VariantData::Struct { fields, .. }, _),
|
||||
kind: hir::ItemKind::Struct(_, _, hir::VariantData::Struct { fields, .. }),
|
||||
..
|
||||
})) = item
|
||||
&& !fields.is_empty()
|
||||
@@ -1130,12 +1130,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
return;
|
||||
};
|
||||
match item.kind {
|
||||
ItemKind::Enum(_, _, generics) | ItemKind::Struct(_, _, generics)
|
||||
ItemKind::Enum(_, generics, _) | ItemKind::Struct(_, generics, _)
|
||||
if generics.params.len() != 0 => {}
|
||||
ItemKind::Trait(_, _, _, generics, _, items)
|
||||
if generics.params.len() != 0
|
||||
|| items.iter().any(|item| matches!(item.kind, AssocItemKind::Type)) => {}
|
||||
ItemKind::TyAlias(_, _, generics) if generics.params.len() != 0 => {}
|
||||
ItemKind::TyAlias(_, generics, _) if generics.params.len() != 0 => {}
|
||||
_ => {
|
||||
self.dcx().emit_err(errors::DocSearchUnboxInvalid { span: meta.span() });
|
||||
}
|
||||
@@ -2792,7 +2792,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn is_c_like_enum(item: &Item<'_>) -> bool {
|
||||
if let ItemKind::Enum(_, ref def, _) = item.kind {
|
||||
if let ItemKind::Enum(_, _, ref def) = item.kind {
|
||||
for variant in def.variants {
|
||||
match variant.data {
|
||||
hir::VariantData::Unit(..) => { /* continue */ }
|
||||
|
||||
@@ -749,7 +749,7 @@ fn check_item<'tcx>(
|
||||
match tcx.def_kind(id.owner_id) {
|
||||
DefKind::Enum => {
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Enum(_, ref enum_def, _) = item.kind {
|
||||
if let hir::ItemKind::Enum(_, _, ref enum_def) = item.kind {
|
||||
if let Some(comes_from_allow) = allow_dead_code {
|
||||
worklist.extend(
|
||||
enum_def.variants.iter().map(|variant| (variant.def_id, comes_from_allow)),
|
||||
@@ -804,7 +804,7 @@ fn check_item<'tcx>(
|
||||
}
|
||||
DefKind::Struct => {
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Struct(_, ref variant_data, _) = item.kind
|
||||
if let hir::ItemKind::Struct(_, _, ref variant_data) = item.kind
|
||||
&& let Some(ctor_def_id) = variant_data.ctor_def_id()
|
||||
{
|
||||
struct_constructors.insert(ctor_def_id, item.owner_id.def_id);
|
||||
@@ -1061,7 +1061,7 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
let tuple_fields = if let Some(parent_id) = parent_item
|
||||
&& let node = tcx.hir_node_by_def_id(parent_id)
|
||||
&& let hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Struct(_, hir::VariantData::Tuple(fields, _, _), _),
|
||||
kind: hir::ItemKind::Struct(_, _, hir::VariantData::Tuple(fields, _, _)),
|
||||
..
|
||||
}) = node
|
||||
{
|
||||
|
||||
@@ -430,7 +430,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
kind = AnnotationKind::DeprecationProhibited;
|
||||
const_stab_inherit = InheritConstStability::Yes;
|
||||
}
|
||||
hir::ItemKind::Struct(_, ref sd, _) => {
|
||||
hir::ItemKind::Struct(_, _, ref sd) => {
|
||||
if let Some(ctor_def_id) = sd.ctor_def_id() {
|
||||
self.annotate(
|
||||
ctor_def_id,
|
||||
|
||||
@@ -599,8 +599,8 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
||||
DefKind::Struct | DefKind::Union => {
|
||||
// While structs and unions have type privacy, their fields do not.
|
||||
let item = self.tcx.hir_expect_item(def_id);
|
||||
if let hir::ItemKind::Struct(_, ref struct_def, _)
|
||||
| hir::ItemKind::Union(_, ref struct_def, _) = item.kind
|
||||
if let hir::ItemKind::Struct(_, _, ref struct_def)
|
||||
| hir::ItemKind::Union(_, _, ref struct_def) = item.kind
|
||||
{
|
||||
for field in struct_def.fields() {
|
||||
let field_vis = self.tcx.local_visibility(field.def_id);
|
||||
@@ -725,7 +725,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Enum(_, ref def, _) => {
|
||||
hir::ItemKind::Enum(_, _, ref def) => {
|
||||
if let Some(item_ev) = item_ev {
|
||||
self.reach(item.owner_id.def_id, item_ev).generics().predicates();
|
||||
}
|
||||
@@ -763,8 +763,8 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(_, ref struct_def, _)
|
||||
| hir::ItemKind::Union(_, ref struct_def, _) => {
|
||||
hir::ItemKind::Struct(_, _, ref struct_def)
|
||||
| hir::ItemKind::Union(_, _, ref struct_def) => {
|
||||
if let Some(item_ev) = item_ev {
|
||||
self.reach(item.owner_id.def_id, item_ev).generics().predicates();
|
||||
for field in struct_def.fields() {
|
||||
@@ -868,7 +868,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TestReachabilityVisitor<'a, 'tcx> {
|
||||
self.effective_visibility_diagnostic(item.owner_id.def_id);
|
||||
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(_, ref def, _) => {
|
||||
hir::ItemKind::Enum(_, _, ref def) => {
|
||||
for variant in def.variants.iter() {
|
||||
self.effective_visibility_diagnostic(variant.def_id);
|
||||
if let Some(ctor_def_id) = variant.data.ctor_def_id() {
|
||||
@@ -879,7 +879,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TestReachabilityVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(_, ref def, _) | hir::ItemKind::Union(_, ref def, _) => {
|
||||
hir::ItemKind::Struct(_, _, ref def) | hir::ItemKind::Union(_, _, ref def) => {
|
||||
if let Some(ctor_def_id) = def.ctor_def_id() {
|
||||
self.effective_visibility_diagnostic(ctor_def_id);
|
||||
}
|
||||
@@ -1651,7 +1651,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
||||
}
|
||||
DefKind::Enum => {
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Enum(_, ref def, _) = item.kind {
|
||||
if let hir::ItemKind::Enum(_, _, ref def) = item.kind {
|
||||
self.check_unnameable(item.owner_id.def_id, effective_vis);
|
||||
|
||||
self.check(item.owner_id.def_id, item_visibility, effective_vis)
|
||||
@@ -1689,8 +1689,8 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
||||
// Subitems of structs and unions have their own publicity.
|
||||
DefKind::Struct | DefKind::Union => {
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Struct(_, ref struct_def, _)
|
||||
| hir::ItemKind::Union(_, ref struct_def, _) = item.kind
|
||||
if let hir::ItemKind::Struct(_, _, ref struct_def)
|
||||
| hir::ItemKind::Union(_, _, ref struct_def) = item.kind
|
||||
{
|
||||
self.check_unnameable(item.owner_id.def_id, effective_vis);
|
||||
self.check(item.owner_id.def_id, item_visibility, effective_vis)
|
||||
|
||||
@@ -2026,7 +2026,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
}
|
||||
LetVisitor { span }.visit_body(body).break_value()
|
||||
}
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(_, ty, _, _), .. }) => {
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(_, _, ty, _), .. }) => {
|
||||
Some(&ty.peel_refs().kind)
|
||||
}
|
||||
_ => None,
|
||||
|
||||
@@ -351,14 +351,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
|
||||
hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Struct(_, _, generics)
|
||||
| hir::ItemKind::Enum(_, _, generics)
|
||||
| hir::ItemKind::Union(_, _, generics)
|
||||
hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::Impl(hir::Impl { generics, .. })
|
||||
| hir::ItemKind::Fn { generics, .. }
|
||||
| hir::ItemKind::TyAlias(_, _, generics)
|
||||
| hir::ItemKind::Const(_, _, generics, _)
|
||||
| hir::ItemKind::TyAlias(_, generics, _)
|
||||
| hir::ItemKind::Const(_, generics, _, _)
|
||||
| hir::ItemKind::TraitAlias(_, generics, _),
|
||||
..
|
||||
})
|
||||
@@ -411,14 +411,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
|
||||
hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Struct(_, _, generics)
|
||||
| hir::ItemKind::Enum(_, _, generics)
|
||||
| hir::ItemKind::Union(_, _, generics)
|
||||
hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::Impl(hir::Impl { generics, .. })
|
||||
| hir::ItemKind::Fn { generics, .. }
|
||||
| hir::ItemKind::TyAlias(_, _, generics)
|
||||
| hir::ItemKind::Const(_, _, generics, _)
|
||||
| hir::ItemKind::TyAlias(_, generics, _)
|
||||
| hir::ItemKind::Const(_, generics, _, _)
|
||||
| hir::ItemKind::TraitAlias(_, generics, _),
|
||||
..
|
||||
}) if !param_ty => {
|
||||
|
||||
@@ -1750,7 +1750,7 @@ fn maybe_expand_private_type_alias<'tcx>(
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
let hir::ItemKind::TyAlias(_, ty, generics) = alias else { return None };
|
||||
let hir::ItemKind::TyAlias(_, generics, ty) = alias else { return None };
|
||||
|
||||
let final_seg = &path.segments.last().expect("segments were empty");
|
||||
let mut args = DefIdMap::default();
|
||||
@@ -2804,21 +2804,21 @@ fn clean_maybe_renamed_item<'tcx>(
|
||||
let mut name = get_name(cx, item, renamed).unwrap();
|
||||
|
||||
let kind = match item.kind {
|
||||
ItemKind::Static(_, ty, mutability, body_id) => StaticItem(Static {
|
||||
ItemKind::Static(mutability, _, ty, body_id) => StaticItem(Static {
|
||||
type_: Box::new(clean_ty(ty, cx)),
|
||||
mutability,
|
||||
expr: Some(body_id),
|
||||
}),
|
||||
ItemKind::Const(_, ty, generics, body_id) => ConstantItem(Box::new(Constant {
|
||||
ItemKind::Const(_, generics, ty, body_id) => ConstantItem(Box::new(Constant {
|
||||
generics: clean_generics(generics, cx),
|
||||
type_: clean_ty(ty, cx),
|
||||
kind: ConstantKind::Local { body: body_id, def_id },
|
||||
})),
|
||||
ItemKind::TyAlias(_, hir_ty, generics) => {
|
||||
ItemKind::TyAlias(_, generics, ty) => {
|
||||
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
|
||||
let rustdoc_ty = clean_ty(hir_ty, cx);
|
||||
let rustdoc_ty = clean_ty(ty, cx);
|
||||
let type_ =
|
||||
clean_middle_ty(ty::Binder::dummy(lower_ty(cx.tcx, hir_ty)), cx, None, None);
|
||||
clean_middle_ty(ty::Binder::dummy(lower_ty(cx.tcx, ty)), cx, None, None);
|
||||
let generics = clean_generics(generics, cx);
|
||||
if let Some(count) = cx.current_type_aliases.get_mut(&def_id) {
|
||||
*count -= 1;
|
||||
@@ -2847,7 +2847,7 @@ fn clean_maybe_renamed_item<'tcx>(
|
||||
));
|
||||
return ret;
|
||||
}
|
||||
ItemKind::Enum(_, def, generics) => EnumItem(Enum {
|
||||
ItemKind::Enum(_, generics, def) => EnumItem(Enum {
|
||||
variants: def.variants.iter().map(|v| clean_variant(v, cx)).collect(),
|
||||
generics: clean_generics(generics, cx),
|
||||
}),
|
||||
@@ -2855,11 +2855,11 @@ fn clean_maybe_renamed_item<'tcx>(
|
||||
generics: clean_generics(generics, cx),
|
||||
bounds: bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
|
||||
}),
|
||||
ItemKind::Union(_, variant_data, generics) => UnionItem(Union {
|
||||
ItemKind::Union(_, generics, variant_data) => UnionItem(Union {
|
||||
generics: clean_generics(generics, cx),
|
||||
fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),
|
||||
}),
|
||||
ItemKind::Struct(_, variant_data, generics) => StructItem(Struct {
|
||||
ItemKind::Struct(_, generics, variant_data) => StructItem(Struct {
|
||||
ctor_kind: variant_data.ctor_kind(),
|
||||
generics: clean_generics(generics, cx),
|
||||
fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),
|
||||
|
||||
@@ -241,7 +241,7 @@ impl DocVisitor<'_> for CoverageCalculator<'_, '_> {
|
||||
data: hir::VariantData::Tuple(_, _, _),
|
||||
..
|
||||
}) | hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Struct(_, hir::VariantData::Tuple(_, _, _), _),
|
||||
kind: hir::ItemKind::Struct(_, _, hir::VariantData::Tuple(_, _, _)),
|
||||
..
|
||||
})
|
||||
)
|
||||
|
||||
@@ -272,7 +272,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
|
||||
return;
|
||||
}
|
||||
match &item.kind {
|
||||
ItemKind::Enum(_, enum_def, _generics) if self.enable_ordering_for_enum => {
|
||||
ItemKind::Enum(_, _generics, enum_def) if self.enable_ordering_for_enum => {
|
||||
let mut cur_v: Option<&Variant<'_>> = None;
|
||||
for variant in enum_def.variants {
|
||||
if variant.span.in_external_macro(cx.sess().source_map()) {
|
||||
@@ -288,7 +288,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
|
||||
cur_v = Some(variant);
|
||||
}
|
||||
},
|
||||
ItemKind::Struct(_, VariantData::Struct { fields, .. }, _generics) if self.enable_ordering_for_struct => {
|
||||
ItemKind::Struct(_, _generics, VariantData::Struct { fields, .. }) if self.enable_ordering_for_struct => {
|
||||
let mut cur_f: Option<&FieldDef<'_>> = None;
|
||||
for field in *fields {
|
||||
if field.span.in_external_macro(cx.sess().source_map()) {
|
||||
|
||||
@@ -92,7 +92,7 @@ impl_lint_pass!(EmptyWithBrackets => [EMPTY_STRUCTS_WITH_BRACKETS, EMPTY_ENUM_VA
|
||||
|
||||
impl LateLintPass<'_> for EmptyWithBrackets {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
|
||||
if let ItemKind::Struct(ident, var_data, _) = &item.kind
|
||||
if let ItemKind::Struct(ident, _, var_data) = &item.kind
|
||||
&& !item.span.from_expansion()
|
||||
&& has_brackets(var_data)
|
||||
&& let span_after_ident = item.span.with_lo(ident.span.hi())
|
||||
|
||||
@@ -38,7 +38,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
|
||||
if cx.tcx.data_layout.pointer_size.bits() != 64 {
|
||||
return;
|
||||
}
|
||||
if let ItemKind::Enum(_, def, _) = &item.kind {
|
||||
if let ItemKind::Enum(_, _, def) = &item.kind {
|
||||
for var in def.variants {
|
||||
if let Some(anon_const) = &var.disr_expr {
|
||||
let def_id = cx.tcx.hir_body_owner_def_id(anon_const.body);
|
||||
|
||||
@@ -127,7 +127,7 @@ fn check_fn_decl(cx: &LateContext<'_>, decl: &FnDecl<'_>, sp: Span, max: u64) {
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
if let ItemKind::Struct(_, variant_data, _) = &item.kind
|
||||
if let ItemKind::Struct(_, _, variant_data) = &item.kind
|
||||
&& variant_data.fields().len() as u64 > self.max_struct_bools
|
||||
&& has_n_bools(
|
||||
variant_data.fields().iter().map(|field| field.ty),
|
||||
|
||||
@@ -76,7 +76,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
|
||||
"exported enums should not be exhaustive",
|
||||
[].as_slice(),
|
||||
),
|
||||
ItemKind::Struct(_, v, ..) => (
|
||||
ItemKind::Struct(_, _, v) => (
|
||||
EXHAUSTIVE_STRUCTS,
|
||||
"exported structs should not be exhaustive",
|
||||
v.fields(),
|
||||
|
||||
@@ -103,7 +103,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty
|
||||
.did()
|
||||
.as_local()
|
||||
&& let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(local_def_id)
|
||||
&& let hir::ItemKind::Enum(_, ref def, _) = item.kind
|
||||
&& let hir::ItemKind::Enum(_, _, ref def) = item.kind
|
||||
{
|
||||
let variants_size = AdtVariantInfo::new(cx, *adt, subst);
|
||||
if let Some((first_variant, variants)) = variants_size.split_first()
|
||||
|
||||
@@ -535,10 +535,10 @@ impl LateLintPass<'_> for ItemNameRepetitions {
|
||||
|
||||
if span_is_local(item.span) {
|
||||
match item.kind {
|
||||
ItemKind::Enum(_, def, _) => {
|
||||
ItemKind::Enum(_, _, def) => {
|
||||
self.check_variants(cx, item, &def);
|
||||
},
|
||||
ItemKind::Struct(_, VariantData::Struct { fields, .. }, _) => {
|
||||
ItemKind::Struct(_, _, VariantData::Struct { fields, .. }) => {
|
||||
self.check_fields(cx, item, fields);
|
||||
},
|
||||
_ => (),
|
||||
|
||||
@@ -48,7 +48,7 @@ impl_lint_pass!(LargeConstArrays => [LARGE_CONST_ARRAYS]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
if let ItemKind::Const(ident, _, generics, _) = &item.kind
|
||||
if let ItemKind::Const(ident, generics, _, _) = &item.kind
|
||||
// Since static items may not have generics, skip generic const items.
|
||||
// FIXME(generic_const_items): I don't think checking `generics.hwcp` suffices as it
|
||||
// doesn't account for empty where-clauses that only consist of keyword `where` IINM.
|
||||
|
||||
@@ -73,7 +73,7 @@ impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &Item<'tcx>) {
|
||||
if let ItemKind::Enum(ident, ref def, _) = item.kind
|
||||
if let ItemKind::Enum(ident, _, ref def) = item.kind
|
||||
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
|
||||
&& let ty::Adt(adt, subst) = ty.kind()
|
||||
&& adt.variants().len() > 1
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
|
||||
}
|
||||
|
||||
match item.kind {
|
||||
ItemKind::Enum(_, def, _) if def.variants.len() > 1 => {
|
||||
ItemKind::Enum(_, _, def) if def.variants.len() > 1 => {
|
||||
let iter = def.variants.iter().filter_map(|v| {
|
||||
(matches!(v.data, VariantData::Unit(_, _)) && is_doc_hidden(cx.tcx.hir_attrs(v.hir_id)))
|
||||
.then_some((v.def_id, v.span))
|
||||
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
|
||||
self.potential_enums.push((item.owner_id.def_id, id, item.span, span));
|
||||
}
|
||||
},
|
||||
ItemKind::Struct(_, variant_data, _) => {
|
||||
ItemKind::Struct(_, _, variant_data) => {
|
||||
let fields = variant_data.fields();
|
||||
let private_fields = fields
|
||||
.iter()
|
||||
|
||||
@@ -225,7 +225,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug {
|
||||
&& let typeck_results = cx.tcx.typeck_body(*body_id)
|
||||
&& should_lint(cx, typeck_results, block)
|
||||
// we intentionally only lint structs, see lint description
|
||||
&& let ItemKind::Struct(_, data, _) = &self_item.kind
|
||||
&& let ItemKind::Struct(_, _, data) = &self_item.kind
|
||||
{
|
||||
check_struct(cx, typeck_results, block, self_ty, item, data);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ struct LazyInfo {
|
||||
impl LazyInfo {
|
||||
fn from_item(cx: &LateContext<'_>, item: &Item<'_>) -> Option<Self> {
|
||||
// Check if item is a `once_cell:sync::Lazy` static.
|
||||
if let ItemKind::Static(_, ty, _, body_id) = item.kind
|
||||
if let ItemKind::Static(_, _, ty, body_id) = item.kind
|
||||
&& let Some(path_def_id) = path_def_id(cx, ty)
|
||||
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind
|
||||
&& paths::ONCE_CELL_SYNC_LAZY.matches(cx, path_def_id)
|
||||
|
||||
@@ -58,7 +58,7 @@ impl PubUnderscoreFields {
|
||||
impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
// This lint only pertains to structs.
|
||||
let ItemKind::Struct(_, variant_data, _) = &item.kind else {
|
||||
let ItemKind::Struct(_, _, variant_data) = &item.kind else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for TrailingEmptyArray {
|
||||
}
|
||||
|
||||
fn is_struct_with_trailing_zero_sized_array<'tcx>(cx: &LateContext<'tcx>, item: &Item<'tcx>) -> bool {
|
||||
if let ItemKind::Struct(_, data, _) = &item.kind
|
||||
if let ItemKind::Struct(_, _, data) = &item.kind
|
||||
&& let Some(last_field) = data.fields().last()
|
||||
&& let field_ty = cx.tcx.normalize_erasing_regions(
|
||||
cx.typing_env(),
|
||||
|
||||
@@ -447,7 +447,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
|
||||
let is_exported = cx.effective_visibilities.is_exported(item.owner_id.def_id);
|
||||
|
||||
match item.kind {
|
||||
ItemKind::Static(_, ty, _, _) | ItemKind::Const(_, ty, _, _) => self.check_ty(
|
||||
ItemKind::Static(_, _, ty, _) | ItemKind::Const(_, _, ty, _) => self.check_ty(
|
||||
cx,
|
||||
ty,
|
||||
CheckTyContext {
|
||||
|
||||
@@ -134,7 +134,7 @@ impl LateLintPass<'_> for UpperCaseAcronyms {
|
||||
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, ident, ..) => {
|
||||
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
|
||||
},
|
||||
ItemKind::Enum(ident, ref enumdef, _) => {
|
||||
ItemKind::Enum(ident, _, ref enumdef) => {
|
||||
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
|
||||
// check enum variants separately because again we only want to lint on private enums and
|
||||
// the fn check_variant does not know about the vis of the enum of its variants
|
||||
|
||||
@@ -249,7 +249,7 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
|
||||
ItemKind::ForeignMod { .. } => (Pat::Str("extern"), Pat::Str("}")),
|
||||
ItemKind::TyAlias(..) => (Pat::Str("type"), Pat::Str(";")),
|
||||
ItemKind::Enum(..) => (Pat::Str("enum"), Pat::Str("}")),
|
||||
ItemKind::Struct(_, VariantData::Struct { .. }, _) => (Pat::Str("struct"), Pat::Str("}")),
|
||||
ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")),
|
||||
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
|
||||
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
|
||||
ItemKind::Trait(_, Safety::Unsafe, ..)
|
||||
|
||||
@@ -2362,7 +2362,7 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalModDefId, f: impl FnOnce(&
|
||||
for id in tcx.hir_module_free_items(module) {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Const)
|
||||
&& let item = tcx.hir_item(id)
|
||||
&& let ItemKind::Const(ident, ty, _generics, _body) = item.kind
|
||||
&& let ItemKind::Const(ident, _generics, ty, _body) = item.kind
|
||||
&& let TyKind::Path(QPath::Resolved(_, path)) = ty.kind
|
||||
// We could also check for the type name `test::TestDescAndFn`
|
||||
&& let Res::Def(DefKind::Struct, _) = path.res
|
||||
|
||||
Reference in New Issue
Block a user