Skip to content

Commit e69c2c7

Browse files
committed
Address comments
1 parent 468254b commit e69c2c7

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

src/librustc/hir/check_attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ fn is_c_like_enum(item: &hir::Item) -> bool {
388388
}
389389
}
390390

391-
pub fn check_mod_attrs<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
392-
tcx.hir().visit_module_item_likes(
391+
fn check_mod_attrs<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
392+
tcx.hir().visit_item_likes_in_module(
393393
module_def_id,
394394
&mut CheckAttrVisitor { tcx }.as_deep_visitor()
395395
);

src/librustc/hir/lowering.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,6 @@ impl<'a> LoweringContext<'a> {
362362
}
363363

364364
impl<'lcx, 'interner> Visitor<'lcx> for MiscCollector<'lcx, 'interner> {
365-
fn visit_mod(&mut self, m: &'lcx Mod, _s: Span, _attrs: &[Attribute], n: NodeId) {
366-
self.lctx.modules.insert(n, hir::ModuleItems {
367-
items: BTreeSet::new(),
368-
trait_items: BTreeSet::new(),
369-
impl_items: BTreeSet::new(),
370-
});
371-
visit::walk_mod(self, m);
372-
}
373-
374365
fn visit_item(&mut self, item: &'lcx Item) {
375366
self.lctx.allocate_hir_id_counter(item.id, item);
376367

@@ -430,6 +421,12 @@ impl<'a> LoweringContext<'a> {
430421

431422
impl<'lcx, 'interner> Visitor<'lcx> for ItemLowerer<'lcx, 'interner> {
432423
fn visit_mod(&mut self, m: &'lcx Mod, _s: Span, _attrs: &[Attribute], n: NodeId) {
424+
self.lctx.modules.insert(n, hir::ModuleItems {
425+
items: BTreeSet::new(),
426+
trait_items: BTreeSet::new(),
427+
impl_items: BTreeSet::new(),
428+
});
429+
433430
let old = self.lctx.current_module;
434431
self.lctx.current_module = n;
435432
visit::walk_mod(self, m);

src/librustc/hir/map/mod.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -507,32 +507,29 @@ impl<'hir> Map<'hir> {
507507
&self.forest.krate.attrs
508508
}
509509

510-
pub fn visit_module_item_likes<V>(&self, module: DefId, visitor: &mut V)
510+
pub fn visit_item_likes_in_module<V>(&self, module: DefId, visitor: &mut V)
511511
where V: ItemLikeVisitor<'hir>
512512
{
513513
let node_id = self.as_local_node_id(module).unwrap();
514514

515515
// Read the module so we'll be re-executed if new items
516516
// appear immediately under in the module. If some new item appears
517-
// in some nested item in the module, we'll be re-executed due to the reads
518-
// in the loops below
517+
// in some nested item in the module, we'll be re-executed due to reads
518+
// in the expect_* calls the loops below
519519
self.read(node_id);
520520

521521
let module = &self.forest.krate.modules[&node_id];
522522

523523
for id in &module.items {
524-
self.read(*id);
525-
visitor.visit_item(&self.forest.krate.items[id]);
524+
visitor.visit_item(self.expect_item(*id));
526525
}
527526

528527
for id in &module.trait_items {
529-
self.read(id.node_id);
530-
visitor.visit_trait_item(&self.forest.krate.trait_items[id]);
528+
visitor.visit_trait_item(self.expect_trait_item(id.node_id));
531529
}
532530

533531
for id in &module.impl_items {
534-
self.read(id.node_id);
535-
visitor.visit_impl_item(&self.forest.krate.impl_items[id]);
532+
visitor.visit_impl_item(self.expect_impl_item(id.node_id));
536533
}
537534
}
538535

src/librustc/middle/stability.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
464464

465465
/// Cross-references the feature names of unstable APIs with enabled
466466
/// features and possibly prints errors.
467-
pub fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
468-
tcx.hir().visit_module_item_likes(module_def_id, &mut Checker { tcx }.as_deep_visitor());
467+
fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
468+
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor());
469469
}
470470

471471
pub fn provide(providers: &mut Providers<'_>) {

src/librustc_passes/loops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
5252
}
5353
}
5454

55-
pub fn check_mod_loops<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
56-
tcx.hir().visit_module_item_likes(module_def_id, &mut CheckLoopVisitor {
55+
fn check_mod_loops<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
56+
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckLoopVisitor {
5757
sess: &tcx.sess,
5858
hir_map: &tcx.hir(),
5959
cx: Normal,

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), Err
708708
}
709709

710710
fn check_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
711-
tcx.hir().visit_module_item_likes(module_def_id, &mut CheckItemTypesVisitor { tcx });
711+
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx });
712712
}
713713

714714
pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), CompileIncomplete> {

src/librustc_typeck/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6262
}
6363

6464
fn collect_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
65-
tcx.hir().visit_module_item_likes(
65+
tcx.hir().visit_item_likes_in_module(
6666
module_def_id,
6767
&mut CollectItemTypesVisitor { tcx }.as_deep_visitor()
6868
);

0 commit comments

Comments
 (0)