{syntax -> rustc_ast_passes}::node_count
This commit is contained in:
parent
6c0b779b7b
commit
50f0e2e9e6
4 changed files with 6 additions and 5 deletions
|
@ -1,9 +1,12 @@
|
||||||
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
|
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
|
||||||
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
|
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
|
||||||
//! by `rustc_ast_lowering`.
|
//! by `rustc_ast_lowering`.
|
||||||
|
//!
|
||||||
|
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
|
||||||
|
|
||||||
#![cfg_attr(bootstrap, feature(slice_patterns))]
|
#![cfg_attr(bootstrap, feature(slice_patterns))]
|
||||||
|
|
||||||
pub mod ast_validation;
|
pub mod ast_validation;
|
||||||
pub mod feature_gate;
|
pub mod feature_gate;
|
||||||
|
pub mod node_count;
|
||||||
pub mod show_span;
|
pub mod show_span;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Simply gives a rought count of the number of nodes in an AST.
|
// Simply gives a rought count of the number of nodes in an AST.
|
||||||
|
|
||||||
use crate::ast::*;
|
|
||||||
use crate::visit::*;
|
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
use syntax::ast::*;
|
||||||
|
use syntax::visit::*;
|
||||||
|
|
||||||
pub struct NodeCounter {
|
pub struct NodeCounter {
|
||||||
pub count: usize,
|
pub count: usize,
|
|
@ -40,7 +40,6 @@ use rustc_span::FileName;
|
||||||
use rustc_traits;
|
use rustc_traits;
|
||||||
use rustc_typeck as typeck;
|
use rustc_typeck as typeck;
|
||||||
use syntax::mut_visit::MutVisitor;
|
use syntax::mut_visit::MutVisitor;
|
||||||
use syntax::util::node_count::NodeCounter;
|
|
||||||
use syntax::{self, ast, visit};
|
use syntax::{self, ast, visit};
|
||||||
|
|
||||||
use rustc_serialize::json;
|
use rustc_serialize::json;
|
||||||
|
@ -83,7 +82,7 @@ pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn count_nodes(krate: &ast::Crate) -> usize {
|
fn count_nodes(krate: &ast::Crate) -> usize {
|
||||||
let mut counter = NodeCounter::new();
|
let mut counter = rustc_ast_passes::node_count::NodeCounter::new();
|
||||||
visit::walk_crate(&mut counter, krate);
|
visit::walk_crate(&mut counter, krate);
|
||||||
counter.count
|
counter.count
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,6 @@ pub mod util {
|
||||||
pub mod lev_distance;
|
pub mod lev_distance;
|
||||||
pub mod literal;
|
pub mod literal;
|
||||||
pub mod map_in_place;
|
pub mod map_in_place;
|
||||||
pub mod node_count;
|
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue