Skip to content

Commit a88d6b1

Browse files
committed
wip
1 parent e5bee3a commit a88d6b1

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ impl<'a> FnKind<'a> {
5757
}
5858
}
5959

60+
pub enum BodyHeader<'a> {
61+
Fn(FnKind<'a>, &'a FnDecl),
62+
Constant
63+
}
64+
6065
/// Each method of the Visitor trait is a hook to be potentially
6166
/// overridden. Each method's default implementation recursively visits
6267
/// the substructure of the input via the corresponding `walk` method;
@@ -145,6 +150,9 @@ pub trait Visitor<'v> : Sized {
145150
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Expr, s: Span, id: NodeId) {
146151
walk_fn(self, fk, fd, b, s, id)
147152
}
153+
fn visit_body(&mut self, _header: BodyHeader<'v>, body: &'v Expr, _s: Span, _id: NodeId) {
154+
self.visit_expr(body);
155+
}
148156
fn visit_trait_item(&mut self, ti: &'v TraitItem) {
149157
walk_trait_item(self, ti)
150158
}
@@ -651,12 +659,13 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
651659
function_kind: FnKind<'v>,
652660
function_declaration: &'v FnDecl,
653661
function_body: &'v Expr,
654-
_span: Span,
662+
span: Span,
655663
id: NodeId) {
656664
visitor.visit_id(id);
657-
walk_fn_decl(visitor, function_declaration);
658665
walk_fn_kind(visitor, function_kind);
659-
visitor.visit_expr(function_body)
666+
walk_fn_decl(visitor, function_declaration);
667+
visitor.visit_body(BodyHeader::Fn(function_kind, function_declaration),
668+
function_body, span, id);
660669
}
661670

662671
pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) {

src/librustc/ty/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19131913
self.tables.borrow()
19141914
}
19151915

1916+
pub fn item_tables(self, _def_id: DefId) -> Ref<'a, Tables<'gcx>> {
1917+
self.tables.borrow()
1918+
}
1919+
19161920
pub fn expr_span(self, id: NodeId) -> Span {
19171921
match self.map.find(id) {
19181922
Some(ast_map::NodeExpr(e)) => {

0 commit comments

Comments
 (0)