+ use std::mem::replace;
+ let result;
+ if let ast::ItemKind::Mod(ast::Mod { inner, .. }) = item.node {
+ if item.span.contains(inner) {
+ self.push_mod_path(item.ident, &item.attrs);
+ result = expand_item(item, self);
+ self.pop_mod_path();
+ } else {
+ let filename = if inner != codemap::DUMMY_SP {
+ Some(self.cx.parse_sess.codemap().span_to_filename(inner))
+ } else { None };
+ let orig_filename = replace(&mut self.cx.filename, filename);
+ let orig_mod_path_stack = replace(&mut self.cx.mod_path_stack, Vec::new());
+ result = expand_item(item, self);
+ self.cx.filename = orig_filename;
+ self.cx.mod_path_stack = orig_mod_path_stack;
+ }
+ } else {
+ result = expand_item(item, self);
+ }
+ result