Remove unnecessary lifetime argument from arena macros.
Because it's always `'tcx`. In fact, some of them use a mixture of passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even work. This makes the code easier to read.
This commit is contained in:
parent
d914f17ca7
commit
552073701f
5 changed files with 66 additions and 66 deletions
|
@ -517,9 +517,9 @@ impl DroplessArena {
|
|||
}
|
||||
|
||||
#[rustc_macro_transparency = "semitransparent"]
|
||||
pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) {
|
||||
pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
|
||||
#[derive(Default)]
|
||||
pub struct Arena<$tcx> {
|
||||
pub struct Arena<'tcx> {
|
||||
pub dropless: $crate::DroplessArena,
|
||||
$($name: $crate::TypedArena<$ty>,)*
|
||||
}
|
||||
|
@ -547,9 +547,9 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) {
|
|||
|
||||
}
|
||||
$(
|
||||
impl<$tcx> ArenaAllocatable<$tcx, $ty> for $ty {
|
||||
impl<'tcx> ArenaAllocatable<'tcx, $ty> for $ty {
|
||||
#[inline]
|
||||
fn allocate_on<'a>(self, arena: &'a Arena<$tcx>) -> &'a mut Self {
|
||||
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
|
||||
if !::std::mem::needs_drop::<Self>() {
|
||||
arena.dropless.alloc(self)
|
||||
} else {
|
||||
|
@ -559,7 +559,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) {
|
|||
|
||||
#[inline]
|
||||
fn allocate_from_iter<'a>(
|
||||
arena: &'a Arena<$tcx>,
|
||||
arena: &'a Arena<'tcx>,
|
||||
iter: impl ::std::iter::IntoIterator<Item = Self>,
|
||||
) -> &'a mut [Self] {
|
||||
if !::std::mem::needs_drop::<Self>() {
|
||||
|
|
|
@ -84,7 +84,7 @@ mod item;
|
|||
mod pat;
|
||||
mod path;
|
||||
|
||||
rustc_hir::arena_types!(rustc_arena::declare_arena, 'tcx);
|
||||
rustc_hir::arena_types!(rustc_arena::declare_arena);
|
||||
|
||||
struct LoweringContext<'a, 'hir: 'a> {
|
||||
/// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
|
||||
|
|
|
@ -4,49 +4,49 @@
|
|||
/// where `T` is the type listed. These impls will appear in the implement_ty_decoder! macro.
|
||||
#[macro_export]
|
||||
macro_rules! arena_types {
|
||||
($macro:path, $tcx:lifetime) => (
|
||||
($macro:path) => (
|
||||
$macro!([
|
||||
// HIR types
|
||||
[] hir_krate: rustc_hir::Crate<$tcx>,
|
||||
[] arm: rustc_hir::Arm<$tcx>,
|
||||
[] asm_operand: (rustc_hir::InlineAsmOperand<$tcx>, Span),
|
||||
[] hir_krate: rustc_hir::Crate<'tcx>,
|
||||
[] arm: rustc_hir::Arm<'tcx>,
|
||||
[] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, Span),
|
||||
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
|
||||
[] attribute: rustc_ast::Attribute,
|
||||
[] block: rustc_hir::Block<$tcx>,
|
||||
[] bare_fn_ty: rustc_hir::BareFnTy<$tcx>,
|
||||
[] body: rustc_hir::Body<$tcx>,
|
||||
[] generic_arg: rustc_hir::GenericArg<$tcx>,
|
||||
[] generic_args: rustc_hir::GenericArgs<$tcx>,
|
||||
[] generic_bound: rustc_hir::GenericBound<$tcx>,
|
||||
[] generic_param: rustc_hir::GenericParam<$tcx>,
|
||||
[] expr: rustc_hir::Expr<$tcx>,
|
||||
[] expr_field: rustc_hir::ExprField<$tcx>,
|
||||
[] pat_field: rustc_hir::PatField<$tcx>,
|
||||
[] fn_decl: rustc_hir::FnDecl<$tcx>,
|
||||
[] foreign_item: rustc_hir::ForeignItem<$tcx>,
|
||||
[] block: rustc_hir::Block<'tcx>,
|
||||
[] bare_fn_ty: rustc_hir::BareFnTy<'tcx>,
|
||||
[] body: rustc_hir::Body<'tcx>,
|
||||
[] generic_arg: rustc_hir::GenericArg<'tcx>,
|
||||
[] generic_args: rustc_hir::GenericArgs<'tcx>,
|
||||
[] generic_bound: rustc_hir::GenericBound<'tcx>,
|
||||
[] generic_param: rustc_hir::GenericParam<'tcx>,
|
||||
[] expr: rustc_hir::Expr<'tcx>,
|
||||
[] expr_field: rustc_hir::ExprField<'tcx>,
|
||||
[] pat_field: rustc_hir::PatField<'tcx>,
|
||||
[] fn_decl: rustc_hir::FnDecl<'tcx>,
|
||||
[] foreign_item: rustc_hir::ForeignItem<'tcx>,
|
||||
[] foreign_item_ref: rustc_hir::ForeignItemRef,
|
||||
[] impl_item: rustc_hir::ImplItem<$tcx>,
|
||||
[] impl_item: rustc_hir::ImplItem<'tcx>,
|
||||
[] impl_item_ref: rustc_hir::ImplItemRef,
|
||||
[] item: rustc_hir::Item<$tcx>,
|
||||
[] inline_asm: rustc_hir::InlineAsm<$tcx>,
|
||||
[] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>,
|
||||
[] local: rustc_hir::Local<$tcx>,
|
||||
[] mod_: rustc_hir::Mod<$tcx>,
|
||||
[] owner_info: rustc_hir::OwnerInfo<$tcx>,
|
||||
[] param: rustc_hir::Param<$tcx>,
|
||||
[] pat: rustc_hir::Pat<$tcx>,
|
||||
[] path: rustc_hir::Path<$tcx>,
|
||||
[] path_segment: rustc_hir::PathSegment<$tcx>,
|
||||
[] poly_trait_ref: rustc_hir::PolyTraitRef<$tcx>,
|
||||
[] qpath: rustc_hir::QPath<$tcx>,
|
||||
[] stmt: rustc_hir::Stmt<$tcx>,
|
||||
[] field_def: rustc_hir::FieldDef<$tcx>,
|
||||
[] trait_item: rustc_hir::TraitItem<$tcx>,
|
||||
[] item: rustc_hir::Item<'tcx>,
|
||||
[] inline_asm: rustc_hir::InlineAsm<'tcx>,
|
||||
[] llvm_inline_asm: rustc_hir::LlvmInlineAsm<'tcx>,
|
||||
[] local: rustc_hir::Local<'tcx>,
|
||||
[] mod_: rustc_hir::Mod<'tcx>,
|
||||
[] owner_info: rustc_hir::OwnerInfo<'tcx>,
|
||||
[] param: rustc_hir::Param<'tcx>,
|
||||
[] pat: rustc_hir::Pat<'tcx>,
|
||||
[] path: rustc_hir::Path<'tcx>,
|
||||
[] path_segment: rustc_hir::PathSegment<'tcx>,
|
||||
[] poly_trait_ref: rustc_hir::PolyTraitRef<'tcx>,
|
||||
[] qpath: rustc_hir::QPath<'tcx>,
|
||||
[] stmt: rustc_hir::Stmt<'tcx>,
|
||||
[] field_def: rustc_hir::FieldDef<'tcx>,
|
||||
[] trait_item: rustc_hir::TraitItem<'tcx>,
|
||||
[] trait_item_ref: rustc_hir::TraitItemRef,
|
||||
[] ty: rustc_hir::Ty<$tcx>,
|
||||
[] type_binding: rustc_hir::TypeBinding<$tcx>,
|
||||
[] variant: rustc_hir::Variant<$tcx>,
|
||||
[] where_predicate: rustc_hir::WherePredicate<$tcx>,
|
||||
], $tcx);
|
||||
[] ty: rustc_hir::Ty<'tcx>,
|
||||
[] type_binding: rustc_hir::TypeBinding<'tcx>,
|
||||
[] variant: rustc_hir::Variant<'tcx>,
|
||||
[] where_predicate: rustc_hir::WherePredicate<'tcx>,
|
||||
]);
|
||||
)
|
||||
}
|
||||
|
|
|
@ -4,30 +4,30 @@
|
|||
/// listed. These impls will appear in the implement_ty_decoder! macro.
|
||||
#[macro_export]
|
||||
macro_rules! arena_types {
|
||||
($macro:path, $tcx:lifetime) => (
|
||||
($macro:path) => (
|
||||
$macro!([
|
||||
[] layout: rustc_target::abi::Layout,
|
||||
[] fn_abi: rustc_target::abi::call::FnAbi<$tcx, rustc_middle::ty::Ty<$tcx>>,
|
||||
[] fn_abi: rustc_target::abi::call::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
|
||||
// AdtDef are interned and compared by address
|
||||
[] adt_def: rustc_middle::ty::AdtDef,
|
||||
[] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<$tcx>>,
|
||||
[] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
|
||||
[decode] mir: rustc_middle::mir::Body<$tcx>,
|
||||
[] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<'tcx>>,
|
||||
[] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<'tcx>>,
|
||||
[decode] mir: rustc_middle::mir::Body<'tcx>,
|
||||
[] steal_promoted:
|
||||
rustc_data_structures::steal::Steal<
|
||||
rustc_index::vec::IndexVec<
|
||||
rustc_middle::mir::Promoted,
|
||||
rustc_middle::mir::Body<$tcx>
|
||||
rustc_middle::mir::Body<'tcx>
|
||||
>
|
||||
>,
|
||||
[decode] promoted:
|
||||
rustc_index::vec::IndexVec<
|
||||
rustc_middle::mir::Promoted,
|
||||
rustc_middle::mir::Body<$tcx>
|
||||
rustc_middle::mir::Body<'tcx>
|
||||
>,
|
||||
[decode] typeck_results: rustc_middle::ty::TypeckResults<$tcx>,
|
||||
[decode] typeck_results: rustc_middle::ty::TypeckResults<'tcx>,
|
||||
[decode] borrowck_result:
|
||||
rustc_middle::mir::BorrowCheckResult<$tcx>,
|
||||
rustc_middle::mir::BorrowCheckResult<'tcx>,
|
||||
[decode] unsafety_check_result: rustc_middle::mir::UnsafetyCheckResult,
|
||||
[decode] code_region: rustc_middle::mir::coverage::CodeRegion,
|
||||
[] const_allocs: rustc_middle::mir::interpret::Allocation,
|
||||
|
@ -78,14 +78,14 @@ macro_rules! arena_types {
|
|||
[] foreign_modules: Vec<rustc_session::cstore::ForeignModule>,
|
||||
[] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
|
||||
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
|
||||
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
|
||||
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
|
||||
[] attribute: rustc_ast::Attribute,
|
||||
[] name_set: rustc_data_structures::fx::FxHashSet<rustc_span::symbol::Symbol>,
|
||||
[] hir_id_set: rustc_hir::HirIdSet,
|
||||
|
||||
// Interned types
|
||||
[] tys: rustc_middle::ty::TyS<$tcx>,
|
||||
[] predicates: rustc_middle::ty::PredicateInner<$tcx>,
|
||||
[] tys: rustc_middle::ty::TyS<'tcx>,
|
||||
[] predicates: rustc_middle::ty::PredicateInner<'tcx>,
|
||||
|
||||
// Note that this deliberately duplicates items in the `rustc_hir::arena`,
|
||||
// since we need to allocate this type on both the `rustc_hir` arena
|
||||
|
@ -97,8 +97,8 @@ macro_rules! arena_types {
|
|||
[decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
|
||||
|
||||
[] dep_kind: rustc_middle::dep_graph::DepKindStruct,
|
||||
], $tcx);
|
||||
]);
|
||||
)
|
||||
}
|
||||
|
||||
arena_types!(rustc_arena::declare_arena, 'tcx);
|
||||
arena_types!(rustc_arena::declare_arena);
|
||||
|
|
|
@ -417,17 +417,17 @@ macro_rules! __impl_decoder_methods {
|
|||
macro_rules! impl_arena_allocatable_decoder {
|
||||
([]$args:tt) => {};
|
||||
([decode $(, $attrs:ident)*]
|
||||
[[$name:ident: $ty:ty], $tcx:lifetime]) => {
|
||||
impl<$tcx, D: TyDecoder<$tcx>> RefDecodable<$tcx, D> for $ty {
|
||||
[$name:ident: $ty:ty]) => {
|
||||
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty {
|
||||
#[inline]
|
||||
fn decode(decoder: &mut D) -> Result<&$tcx Self, D::Error> {
|
||||
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
|
||||
decode_arena_allocable(decoder)
|
||||
}
|
||||
}
|
||||
|
||||
impl<$tcx, D: TyDecoder<$tcx>> RefDecodable<$tcx, D> for [$ty] {
|
||||
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [$ty] {
|
||||
#[inline]
|
||||
fn decode(decoder: &mut D) -> Result<&$tcx Self, D::Error> {
|
||||
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
|
||||
decode_arena_allocable_slice(decoder)
|
||||
}
|
||||
}
|
||||
|
@ -438,15 +438,15 @@ macro_rules! impl_arena_allocatable_decoder {
|
|||
}
|
||||
|
||||
macro_rules! impl_arena_allocatable_decoders {
|
||||
([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => {
|
||||
([$($a:tt $name:ident: $ty:ty,)*]) => {
|
||||
$(
|
||||
impl_arena_allocatable_decoder!($a [[$name: $ty], $tcx]);
|
||||
impl_arena_allocatable_decoder!($a [$name: $ty]);
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
rustc_hir::arena_types!(impl_arena_allocatable_decoders, 'tcx);
|
||||
arena_types!(impl_arena_allocatable_decoders, 'tcx);
|
||||
rustc_hir::arena_types!(impl_arena_allocatable_decoders);
|
||||
arena_types!(impl_arena_allocatable_decoders);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! implement_ty_decoder {
|
||||
|
|
Loading…
Add table
Reference in a new issue