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
) {

src/librustc_passes/hir_stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
128128
hir_visit::walk_item(self, i)
129129
}
130130

131-
fn visit_mod(&mut self, m: &'v hir::Mod, _s: Span, n: hir::HirId) {
131+
fn visit_mod(&mut self, m: &'v hir::Mod<'v>, _s: Span, n: hir::HirId) {
132132
self.record("Mod", Id::None, m);
133133
hir_visit::walk_mod(self, m, n)
134134
}

src/librustc_privacy/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl EmbargoVisitor<'tcx> {
510510
fn update_macro_reachable_mod(&mut self, reachable_mod: hir::HirId, defining_mod: DefId) {
511511
let module_def_id = self.tcx.hir().local_def_id(reachable_mod);
512512
let module = self.tcx.hir().get_module(module_def_id).0;
513-
for item_id in &module.item_ids {
513+
for item_id in module.item_ids {
514514
let hir_id = item_id.id;
515515
let item_def_id = self.tcx.hir().local_def_id(hir_id);
516516
if let Some(def_kind) = self.tcx.def_kind(item_def_id) {
@@ -849,7 +849,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
849849
self.prev_level = orig_level;
850850
}
851851

852-
fn visit_mod(&mut self, m: &'tcx hir::Mod, _sp: Span, id: hir::HirId) {
852+
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, _sp: Span, id: hir::HirId) {
853853
// This code is here instead of in visit_item so that the
854854
// crate module gets processed as well.
855855
if self.prev_level.is_some() {
@@ -992,7 +992,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
992992
NestedVisitorMap::All(&self.tcx.hir())
993993
}
994994

995-
fn visit_mod(&mut self, _m: &'tcx hir::Mod, _s: Span, _n: hir::HirId) {
995+
fn visit_mod(&mut self, _m: &'tcx hir::Mod<'tcx>, _s: Span, _n: hir::HirId) {
996996
// Don't visit nested modules, since we run a separate visitor walk
997997
// for each module in `privacy_access_levels`
998998
}
@@ -1132,7 +1132,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
11321132
NestedVisitorMap::All(&self.tcx.hir())
11331133
}
11341134

1135-
fn visit_mod(&mut self, _m: &'tcx hir::Mod, _s: Span, _n: hir::HirId) {
1135+
fn visit_mod(&mut self, _m: &'tcx hir::Mod<'tcx>, _s: Span, _n: hir::HirId) {
11361136
// Don't visit nested modules, since we run a separate visitor walk
11371137
// for each module in `privacy_access_levels`
11381138
}

src/librustc_typeck/check/method/suggest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ impl UsePlacementFinder<'tcx> {
10931093
impl hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> {
10941094
fn visit_mod(
10951095
&mut self,
1096-
module: &'tcx hir::Mod,
1096+
module: &'tcx hir::Mod<'tcx>,
10971097
_: Span,
10981098
hir_id: hir::HirId,
10991099
) {
@@ -1105,7 +1105,7 @@ impl hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> {
11051105
return;
11061106
}
11071107
// Find a `use` statement.
1108-
for item_id in &module.item_ids {
1108+
for item_id in module.item_ids {
11091109
let item = self.tcx.hir().expect_item(item_id.id);
11101110
match item.kind {
11111111
hir::ItemKind::Use(..) => {

src/librustdoc/visit_ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
215215

216216
fn visit_mod_contents(&mut self, span: Span, attrs: &'tcx [ast::Attribute],
217217
vis: &'tcx hir::Visibility, id: hir::HirId,
218-
m: &'tcx hir::Mod,
218+
m: &'tcx hir::Mod<'tcx>,
219219
name: Option<ast::Name>) -> Module<'tcx> {
220220
let mut om = Module::new(name, attrs, vis);
221221
om.where_outer = span;
@@ -224,7 +224,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
224224
// Keep track of if there were any private modules in the path.
225225
let orig_inside_public_path = self.inside_public_path;
226226
self.inside_public_path &= vis.node.is_pub();
227-
for i in &m.item_ids {
227+
for i in m.item_ids {
228228
let item = self.cx.tcx.hir().expect_item(i.id);
229229
self.visit_item(item, None, &mut om);
230230
}
@@ -322,7 +322,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
322322
let ret = match tcx.hir().get(res_hir_id) {
323323
Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => {
324324
let prev = mem::replace(&mut self.inlining, true);
325-
for i in &m.item_ids {
325+
for i in m.item_ids {
326326
let i = self.cx.tcx.hir().expect_item(i.id);
327327
self.visit_item(i, None, om);
328328
}

0 commit comments

Comments
 (0)