diff options
| author | bors <bors@rust-lang.org> | 2020-11-02 10:42:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-02 10:42:45 +0000 |
| commit | 4051473c8b5158984a5253d1b5faad6a94de7682 (patch) | |
| tree | a3dcca4b2e5d8b9a5b0a3d058010826b5901d30f /compiler/rustc_interface/src/passes.rs | |
| parent | 234099d1d12bef9d6e81a296222fbc272dc51d89 (diff) | |
| parent | 50d7716efb7cffb43a0ca77c723754ad2174e9cc (diff) | |
| download | rust-4051473c8b5158984a5253d1b5faad6a94de7682.tar.gz rust-4051473c8b5158984a5253d1b5faad6a94de7682.zip | |
Auto merge of #78661 - JohnTitor:rollup-er2isja, r=JohnTitor
Rollup of 5 pull requests Successful merges: - #78606 (Clarify handling of final line ending in str::lines()) - #78610 (Do not remove tokens before AST json serialization) - #78620 (Trivial fixes to bitwise operator documentation) - #78627 (Point out that total_cmp is no strict superset of partial comparison) - #78637 (Add fetch_update methods to AtomicBool and AtomicPtr) Failed merges: r? `@ghost`
Diffstat (limited to 'compiler/rustc_interface/src/passes.rs')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 90 |
1 files changed, 2 insertions, 88 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 072194e332a..548b6c03daa 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -2,9 +2,8 @@ use crate::interface::{Compiler, Result}; use crate::proc_macro_decls; use crate::util; -use rustc_ast::mut_visit::{self, MutVisitor}; -use rustc_ast::ptr::P; -use rustc_ast::{self as ast, token, visit}; +use rustc_ast::mut_visit::MutVisitor; +use rustc_ast::{self as ast, visit}; use rustc_codegen_ssa::back::link::emit_metadata; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::sync::{par_iter, Lrc, OnceCell, ParallelIterator, WorkerLocal}; @@ -37,7 +36,6 @@ use rustc_span::symbol::Symbol; use rustc_span::{FileName, RealFileName}; use rustc_trait_selection::traits; use rustc_typeck as typeck; -use smallvec::SmallVec; use tracing::{info, warn}; use rustc_serialize::json; @@ -52,82 +50,6 @@ use std::path::PathBuf; use std::rc::Rc; use std::{env, fs, iter, mem}; -/// Remove alls `LazyTokenStreams` from an AST struct -/// Normally, this is done during AST lowering. However, -/// printing the AST JSON requires us to serialize -/// the entire AST, and we don't want to serialize -/// a `LazyTokenStream`. -struct TokenStripper; -impl mut_visit::MutVisitor for TokenStripper { - fn flat_map_item(&mut self, mut i: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> { - i.tokens = None; - mut_visit::noop_flat_map_item(i, self) - } - fn flat_map_foreign_item( - &mut self, - mut i: P<ast::ForeignItem>, - ) -> SmallVec<[P<ast::ForeignItem>; 1]> { - i.tokens = None; - mut_visit::noop_flat_map_foreign_item(i, self) - } - fn flat_map_trait_item( - &mut self, - mut i: P<ast::AssocItem>, - ) -> SmallVec<[P<ast::AssocItem>; 1]> { - i.tokens = None; - mut_visit::noop_flat_map_assoc_item(i, self) - } - fn flat_map_impl_item(&mut self, mut i: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> { - i.tokens = None; - mut_visit::noop_flat_map_assoc_item(i, self) - } - fn visit_block(&mut self, b: &mut P<ast::Block>) { - b.tokens = None; - mut_visit::noop_visit_block(b, self); - } - fn flat_map_stmt(&mut self, mut stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { - stmt.tokens = None; - mut_visit::noop_flat_map_stmt(stmt, self) - } - fn visit_pat(&mut self, p: &mut P<ast::Pat>) { - p.tokens = None; - mut_visit::noop_visit_pat(p, self); - } - fn visit_ty(&mut self, ty: &mut P<ast::Ty>) { - ty.tokens = None; - mut_visit::noop_visit_ty(ty, self); - } - fn visit_attribute(&mut self, attr: &mut ast::Attribute) { - attr.tokens = None; - if let ast::AttrKind::Normal(ast::AttrItem { tokens, .. }) = &mut attr.kind { - *tokens = None; - } - mut_visit::noop_visit_attribute(attr, self); - } - - fn visit_interpolated(&mut self, nt: &mut token::Nonterminal) { - if let token::Nonterminal::NtMeta(meta) = nt { - meta.tokens = None; - } - // Handles all of the other cases - mut_visit::noop_visit_interpolated(nt, self); - } - - fn visit_path(&mut self, p: &mut ast::Path) { - p.tokens = None; - mut_visit::noop_visit_path(p, self); - } - fn visit_vis(&mut self, vis: &mut ast::Visibility) { - vis.tokens = None; - mut_visit::noop_visit_vis(vis, self); - } - fn visit_expr(&mut self, e: &mut P<ast::Expr>) { - e.tokens = None; - mut_visit::noop_visit_expr(e, self); - } - fn visit_mac(&mut self, _mac: &mut ast::MacCall) {} -} - pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> { let krate = sess.time("parse_crate", || match input { Input::File(file) => parse_crate_from_file(file, &sess.parse_sess), @@ -137,10 +59,6 @@ pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> { })?; if sess.opts.debugging_opts.ast_json_noexpand { - // Set any `token` fields to `None` before - // we display the AST. - let mut krate = krate.clone(); - TokenStripper.visit_crate(&mut krate); println!("{}", json::as_json(&krate)); } @@ -464,10 +382,6 @@ fn configure_and_expand_inner<'a>( } if sess.opts.debugging_opts.ast_json { - // Set any `token` fields to `None` before - // we display the AST. - let mut krate = krate.clone(); - TokenStripper.visit_crate(&mut krate); println!("{}", json::as_json(&krate)); } |
