Skip to content

Commit 42c03e4

Browse files
committed
Use Arena inside hir::Mod.
1 parent e252612 commit 42c03e4

File tree

14 files changed

+29
-29
lines changed

14 files changed

+29
-29
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub trait Visitor<'v>: Sized {
247247
fn visit_ident(&mut self, ident: Ident) {
248248
walk_ident(self, ident)
249249
}
250-
fn visit_mod(&mut self, m: &'v Mod, _s: Span, n: HirId) {
250+
fn visit_mod(&mut self, m: &'v Mod<'v>, _s: Span, n: HirId) {
251251
walk_mod(self, m, n)
252252
}
253253
fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>) {
@@ -394,9 +394,9 @@ pub fn walk_macro_def<'v, V: Visitor<'v>>(visitor: &mut V, macro_def: &'v MacroD
394394
walk_list!(visitor, visit_attribute, macro_def.attrs);
395395
}
396396

397-
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod, mod_hir_id: HirId) {
397+
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>, mod_hir_id: HirId) {
398398
visitor.visit_id(mod_hir_id);
399-
for &item_id in &module.item_ids {
399+
for &item_id in module.item_ids {
400400
visitor.visit_nested_item(item_id);
401401
}
402402
}

src/librustc/hir/lowering/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ impl LoweringContext<'_, 'hir> {
161161
res
162162
}
163163

164-
pub(super) fn lower_mod(&mut self, m: &Mod) -> hir::Mod {
164+
pub(super) fn lower_mod(&mut self, m: &Mod) -> hir::Mod<'hir> {
165165
hir::Mod {
166166
inner: m.inner,
167-
item_ids: m.items.iter().flat_map(|x| self.lower_item_id(x)).collect(),
167+
item_ids: self.arena.alloc_from_iter(m.items.iter().flat_map(|x| self.lower_item_id(x))),
168168
}
169169
}
170170

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl<'hir> Map<'hir> {
580580
&self.forest.krate.attrs
581581
}
582582

583-
pub fn get_module(&self, module: DefId) -> (&'hir Mod, Span, HirId) {
583+
pub fn get_module(&self, module: DefId) -> (&'hir Mod<'hir>, Span, HirId) {
584584
let hir_id = self.as_local_hir_id(module).unwrap();
585585
self.read(hir_id);
586586
match self.find_entry(hir_id).unwrap().node {

src/librustc/hir/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ pub struct ModuleItems {
743743
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
744744
#[derive(RustcEncodable, RustcDecodable, Debug)]
745745
pub struct Crate<'hir> {
746-
pub module: Mod,
746+
pub module: Mod<'hir>,
747747
pub attrs: &'hir [Attribute],
748748
pub span: Span,
749749
pub exported_macros: &'hir [MacroDef<'hir>],
@@ -2243,12 +2243,12 @@ impl FunctionRetTy {
22432243
}
22442244

22452245
#[derive(RustcEncodable, RustcDecodable, Debug)]
2246-
pub struct Mod {
2246+
pub struct Mod<'hir> {
22472247
/// A span from the first token past `{` to the last token until `}`.
22482248
/// For `mod foo;`, the inner span ranges from the first token
22492249
/// to the last token in the external file.
22502250
pub inner: Span,
2251-
pub item_ids: HirVec<ItemId>,
2251+
pub item_ids: &'hir [ItemId],
22522252
}
22532253

22542254
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
@@ -2489,7 +2489,7 @@ pub enum ItemKind<'hir> {
24892489
/// A function declaration.
24902490
Fn(FnSig, Generics, BodyId),
24912491
/// A module.
2492-
Mod(Mod),
2492+
Mod(Mod<'hir>),
24932493
/// An external module, e.g. `extern { .. }`.
24942494
ForeignMod(ForeignMod<'hir>),
24952495
/// Module-level inline assembly (from `global_asm!`).

src/librustc/hir/print.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ impl<'a> State<'a> {
259259
self.commasep_cmnt(b, exprs, |s, e| s.print_expr(&e), |e| e.span)
260260
}
261261

262-
pub fn print_mod(&mut self, _mod: &hir::Mod, attrs: &[ast::Attribute]) {
262+
pub fn print_mod(&mut self, _mod: &hir::Mod<'_>, attrs: &[ast::Attribute]) {
263263
self.print_inner_attributes(attrs);
264-
for &item_id in &_mod.item_ids {
264+
for &item_id in _mod.item_ids {
265265
self.ann.nested(self, Nested::Item(item_id));
266266
}
267267
}

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind {
218218
}
219219
}
220220

221-
impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
221+
impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod<'_> {
222222
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
223223
let hir::Mod {
224224
inner: ref inner_span,

src/librustc/lint/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> {
883883
self.context.param_env = old_param_env;
884884
}
885885

886-
fn process_mod(&mut self, m: &'tcx hir::Mod, s: Span, n: hir::HirId) {
886+
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
887887
lint_callback!(self, check_mod, m, s, n);
888888
hir_visit::walk_mod(self, m, n);
889889
lint_callback!(self, check_mod_post, m, s, n);
@@ -1027,7 +1027,7 @@ for LateContextAndPass<'a, 'tcx, T> {
10271027
lint_callback!(self, check_name, sp, name);
10281028
}
10291029

1030-
fn visit_mod(&mut self, m: &'tcx hir::Mod, s: Span, n: hir::HirId) {
1030+
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
10311031
if !self.context.only_module {
10321032
self.process_mod(m, s, n);
10331033
}

src/librustc/lint/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ macro_rules! late_lint_methods {
9292
fn check_name(a: Span, b: ast::Name);
9393
fn check_crate(a: &$hir hir::Crate<$hir>);
9494
fn check_crate_post(a: &$hir hir::Crate<$hir>);
95-
fn check_mod(a: &$hir hir::Mod, b: Span, c: hir::HirId);
96-
fn check_mod_post(a: &$hir hir::Mod, b: Span, c: hir::HirId);
95+
fn check_mod(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
96+
fn check_mod_post(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
9797
fn check_foreign_item(a: &$hir hir::ForeignItem<$hir>);
9898
fn check_foreign_item_post(a: &$hir hir::ForeignItem<$hir>);
9999
fn check_item(a: &$hir hir::Item<$hir>);

src/librustc_lint/nonstandard_style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl NonSnakeCase {
246246
}
247247

248248
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
249-
fn check_mod(&mut self, cx: &LateContext<'_, '_>, _: &'tcx hir::Mod, _: Span, id: hir::HirId) {
249+
fn check_mod(&mut self, cx: &LateContext<'_, '_>, _: &'tcx hir::Mod<'tcx>, _: Span, id: hir::HirId) {
250250
if id != hir::CRATE_HIR_ID {
251251
return;
252252
}

src/librustc_metadata/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl EncodeContext<'tcx> {
682682
fn encode_info_for_mod(
683683
&mut self,
684684
id: hir::HirId,
685-
md: &hir::Mod,
685+
md: &hir::Mod<'_>,
686686
attrs: &[ast::Attribute],
687687
vis: &hir::Visibility,
688688
) {

0 commit comments

Comments
 (0)