1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Span debugger
12 //!
13 //! This module shows spans for all expressions in the crate
14 //! to help with compiler debugging.
15
16 use syntax::ast;
17 use syntax::visit;
18 use syntax::visit::Visitor;
19
20 use driver::session::Session;
21
22 struct ShowSpanVisitor<'a> {
23 sess: &'a Session
24 }
25
26 impl<'a> Visitor<()> for ShowSpanVisitor<'a> {
27 fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
28 self.sess.span_note(e.span, "expression");
29 visit::walk_expr(self, e, ());
30 }
31 }
32
33 pub fn run(sess: &Session, krate: &ast::Crate) {
34 let mut v = ShowSpanVisitor { sess: sess };
35 visit::walk_crate(&mut v, krate, ());
36 }