Skip to content

Commit 807e157

Browse files
committed
invoke const only on body-ids
1 parent 5c26509 commit 807e157

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/librustc_passes/consts.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
5353
use std::collections::hash_map::Entry;
5454
use std::cmp::Ordering;
5555

56+
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
57+
for &body_id in &tcx.hir.krate().body_ids {
58+
let visitor = &mut CheckCrateVisitor {
59+
tcx,
60+
tables: &ty::TypeckTables::empty(None),
61+
in_fn: false,
62+
in_static: false,
63+
promotable: false,
64+
mut_rvalue_borrows: NodeSet(),
65+
param_env: ty::ParamEnv::empty(Reveal::UserFacing),
66+
identity_substs: Substs::empty(),
67+
};
68+
visitor.visit_nested_body(body_id);
69+
}
70+
tcx.sess.abort_if_errors();
71+
}
72+
5673
struct CheckCrateVisitor<'a, 'tcx: 'a> {
5774
tcx: TyCtxt<'a, 'tcx, 'tcx>,
5875
in_fn: bool,
@@ -513,20 +530,6 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
513530
}
514531
}
515532

516-
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
517-
tcx.hir.krate().visit_all_item_likes(&mut CheckCrateVisitor {
518-
tcx,
519-
tables: &ty::TypeckTables::empty(None),
520-
in_fn: false,
521-
in_static: false,
522-
promotable: false,
523-
mut_rvalue_borrows: NodeSet(),
524-
param_env: ty::ParamEnv::empty(Reveal::UserFacing),
525-
identity_substs: Substs::empty(),
526-
}.as_deep_visitor());
527-
tcx.sess.abort_if_errors();
528-
}
529-
530533
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
531534
fn consume(&mut self,
532535
_consume_id: ast::NodeId,

0 commit comments

Comments
 (0)