ast: Stop using Mod
in Crate
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
This commit is contained in:
parent
d1462d8558
commit
eb65f15c78
23 changed files with 114 additions and 179 deletions
|
@ -89,7 +89,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
|
|||
noop_visit_crate(c, self);
|
||||
|
||||
// Create a main function to run our tests
|
||||
c.module.items.push(mk_main(&mut self.cx));
|
||||
c.items.push(mk_main(&mut self.cx));
|
||||
}
|
||||
|
||||
fn flat_map_item(&mut self, i: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
|
||||
|
@ -103,9 +103,13 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
|
|||
|
||||
// We don't want to recurse into anything other than mods, since
|
||||
// mods or tests inside of functions will break things
|
||||
if let ast::ItemKind::Mod(mut module) = item.kind {
|
||||
if let ast::ItemKind::Mod(..) = item.kind {
|
||||
let tests = mem::take(&mut self.tests);
|
||||
noop_visit_mod(&mut module, self);
|
||||
noop_visit_item_kind(&mut item.kind, self);
|
||||
let module = match item.kind {
|
||||
ast::ItemKind::Mod(module) => module,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let mut tests = mem::replace(&mut self.tests, tests);
|
||||
|
||||
if !tests.is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue