Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f13f980

Browse files
authoredNov 21, 2023
Rollup merge of rust-lang#118121 - nnethercote:rustc_hir, r=compiler-errors
`rustc_hir` cleanups Just some improvements I found while looking at this code. r? `@WaffleLapkin`
2 parents 90e4c2d + 72653c1 commit f13f980

File tree

7 files changed

+123
-468
lines changed

7 files changed

+123
-468
lines changed
 

‎compiler/rustc_hir/src/arena.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ macro_rules! arena_types {
55
($macro:path) => (
66
$macro!([
77
// HIR types
8-
[] hir_krate: rustc_hir::Crate<'tcx>,
98
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
109
[] attribute: rustc_ast::Attribute,
1110
[] owner_info: rustc_hir::OwnerInfo<'tcx>,

‎compiler/rustc_hir/src/def.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use std::array::IntoIter;
1313
use std::fmt::Debug;
1414

1515
/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
16-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
17-
#[derive(HashStable_Generic)]
16+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
1817
pub enum CtorOf {
1918
/// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct.
2019
Struct,
@@ -23,8 +22,7 @@ pub enum CtorOf {
2322
}
2423

2524
/// What kind of constructor something is.
26-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
27-
#[derive(HashStable_Generic)]
25+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
2826
pub enum CtorKind {
2927
/// Constructor function automatically created by a tuple struct/variant.
3028
Fn,
@@ -33,8 +31,7 @@ pub enum CtorKind {
3331
}
3432

3533
/// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`.
36-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
37-
#[derive(HashStable_Generic)]
34+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
3835
pub enum NonMacroAttrKind {
3936
/// Single-segment attribute defined by the language (`#[inline]`)
4037
Builtin(Symbol),
@@ -48,8 +45,7 @@ pub enum NonMacroAttrKind {
4845
}
4946

5047
/// What kind of definition something is; e.g., `mod` vs `struct`.
51-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
52-
#[derive(HashStable_Generic)]
48+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
5349
pub enum DefKind {
5450
// Type namespace
5551
Mod,
@@ -299,8 +295,7 @@ impl DefKind {
299295
/// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`]
300296
/// pointing to the definition of `str_to_string` in the current crate.
301297
//
302-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
303-
#[derive(HashStable_Generic)]
298+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
304299
pub enum Res<Id = hir::HirId> {
305300
/// Definition having a unique ID (`DefId`), corresponds to something defined in user code.
306301
///
@@ -591,6 +586,8 @@ impl NonMacroAttrKind {
591586
}
592587
}
593588

589+
// Currently trivial, but exists in case a new kind is added in the future whose name starts
590+
// with a vowel.
594591
pub fn article(self) -> &'static str {
595592
"a"
596593
}

‎compiler/rustc_hir/src/hir.rs

Lines changed: 112 additions & 435 deletions
Large diffs are not rendered by default.

‎compiler/rustc_hir/src/hir_id.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd,
33
use rustc_span::{def_id::DefPathHash, HashStableContext};
44
use std::fmt::{self, Debug};
55

6-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
7-
#[derive(Encodable, Decodable)]
6+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
87
pub struct OwnerId {
98
pub def_id: LocalDefId,
109
}
@@ -73,8 +72,7 @@ impl<CTX: HashStableContext> ToStableHashKey<CTX> for OwnerId {
7372
/// the `local_id` part of the `HirId` changing, which is a very useful property in
7473
/// incremental compilation where we have to persist things through changes to
7574
/// the code base.
76-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
77-
#[derive(Encodable, Decodable, HashStable_Generic)]
75+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
7876
#[rustc_pass_by_value]
7977
pub struct HirId {
8078
pub owner: OwnerId,

‎compiler/rustc_hir/src/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ language_item_table! {
233233
PanicFmt, sym::panic_fmt, panic_fmt, Target::Fn, GenericRequirement::None;
234234
ConstPanicFmt, sym::const_panic_fmt, const_panic_fmt, Target::Fn, GenericRequirement::None;
235235
PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, Target::Fn, GenericRequirement::Exact(0);
236-
PanicMisalignedPointerDereference, sym::panic_misaligned_pointer_dereference, panic_misaligned_pointer_dereference_fn, Target::Fn, GenericRequirement::Exact(0);
236+
PanicMisalignedPointerDereference, sym::panic_misaligned_pointer_dereference, panic_misaligned_pointer_dereference_fn, Target::Fn, GenericRequirement::Exact(0);
237237
PanicInfo, sym::panic_info, panic_info, Target::Struct, GenericRequirement::None;
238238
PanicLocation, sym::panic_location, panic_location, Target::Struct, GenericRequirement::None;
239239
PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None;

‎compiler/rustc_hir/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
#![feature(associated_type_defaults)]
66
#![feature(closure_track_caller)]
7-
#![feature(const_btree_len)]
87
#![feature(let_chains)]
98
#![feature(min_specialization)]
109
#![feature(never_type)]

‎compiler/rustc_middle/src/arena.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,12 @@ macro_rules! arena_types {
2727
rustc_middle::mir::Promoted,
2828
rustc_middle::mir::Body<'tcx>
2929
>,
30-
[decode] closure_debuginfo:
31-
rustc_index::IndexVec<
32-
rustc_target::abi::FieldIdx,
33-
rustc_span::symbol::Symbol,
34-
>,
3530
[decode] typeck_results: rustc_middle::ty::TypeckResults<'tcx>,
36-
[decode] borrowck_result:
37-
rustc_middle::mir::BorrowCheckResult<'tcx>,
31+
[decode] borrowck_result: rustc_middle::mir::BorrowCheckResult<'tcx>,
3832
[] resolver: rustc_data_structures::steal::Steal<(
3933
rustc_middle::ty::ResolverAstLowering,
4034
rustc_data_structures::sync::Lrc<rustc_ast::Crate>,
4135
)>,
42-
[] output_filenames: std::sync::Arc<rustc_session::config::OutputFilenames>,
4336
[] crate_for_resolver: rustc_data_structures::steal::Steal<(rustc_ast::Crate, rustc_ast::AttrVec)>,
4437
[] resolutions: rustc_middle::ty::ResolverGlobalCtxt,
4538
[decode] unsafety_check_result: rustc_middle::mir::UnsafetyCheckResult,
@@ -91,29 +84,23 @@ macro_rules! arena_types {
9184
rustc_middle::infer::canonical::Canonical<'tcx,
9285
rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Ty<'tcx>>
9386
>,
94-
[] all_traits: Vec<rustc_hir::def_id::DefId>,
9587
[] effective_visibilities: rustc_middle::middle::privacy::EffectiveVisibilities,
96-
[] foreign_module: rustc_session::cstore::ForeignModule,
97-
[] foreign_modules: Vec<rustc_session::cstore::ForeignModule>,
9888
[] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
9989
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
10090
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
10191
[decode] attribute: rustc_ast::Attribute,
10292
[] name_set: rustc_data_structures::unord::UnordSet<rustc_span::symbol::Symbol>,
10393
[] ordered_name_set: rustc_data_structures::fx::FxIndexSet<rustc_span::symbol::Symbol>,
104-
[] hir_id_set: rustc_hir::HirIdSet,
10594

10695
// Interned types
10796
[] tys: rustc_type_ir::WithCachedTypeInfo<rustc_middle::ty::TyKind<'tcx>>,
108-
[] predicates: rustc_type_ir::WithCachedTypeInfo<rustc_middle::ty::PredicateKind<'tcx>>,
10997
[] consts: rustc_middle::ty::ConstData<'tcx>,
11098

11199
// Note that this deliberately duplicates items in the `rustc_hir::arena`,
112100
// since we need to allocate this type on both the `rustc_hir` arena
113101
// (during lowering) and the `librustc_middle` arena (for decoding MIR)
114102
[decode] asm_template: rustc_ast::InlineAsmTemplatePiece,
115103
[decode] used_trait_imports: rustc_data_structures::unord::UnordSet<rustc_hir::def_id::LocalDefId>,
116-
[decode] registered_tools: rustc_middle::ty::RegisteredTools,
117104
[decode] is_late_bound_map: rustc_data_structures::fx::FxIndexSet<rustc_hir::ItemLocalId>,
118105
[decode] impl_source: rustc_middle::traits::ImplSource<'tcx, ()>,
119106

@@ -124,11 +111,9 @@ macro_rules! arena_types {
124111
rustc_hir::def_id::DefId,
125112
rustc_middle::ty::EarlyBinder<rustc_middle::ty::Ty<'tcx>>
126113
>,
127-
[] bit_set_u32: rustc_index::bit_set::BitSet<u32>,
128114
[] external_constraints: rustc_middle::traits::solve::ExternalConstraintsData<'tcx>,
129115
[] predefined_opaques_in_body: rustc_middle::traits::solve::PredefinedOpaquesData<'tcx>,
130116
[decode] doc_link_resolutions: rustc_hir::def::DocLinkResMap,
131-
[] closure_kind_origin: (rustc_span::Span, rustc_middle::hir::place::Place<'tcx>),
132117
[] stripped_cfg_items: rustc_ast::expand::StrippedCfgItem,
133118
[] mod_child: rustc_middle::metadata::ModChild,
134119
[] features: rustc_feature::Features,

0 commit comments

Comments
 (0)
This repository has been archived.