]> git.lizzy.rs Git - rust.git/blob - src/librustc/front/show_span.rs
Doc says to avoid mixing allocator instead of forbiding it
[rust.git] / src / librustc / front / show_span.rs
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, 'v> Visitor<'v> 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     fn visit_mac(&mut self, macro: &ast::Mac) {
33         visit::walk_mac(self, macro);
34     }
35 }
36
37 pub fn run(sess: &Session, krate: &ast::Crate) {
38     let mut v = ShowSpanVisitor { sess: sess };
39     visit::walk_crate(&mut v, krate);
40 }