]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #65324 - Centril:organize-syntax, r=petrochenkov
authorbors <bors@rust-lang.org>
Sun, 10 Nov 2019 12:18:53 +0000 (12:18 +0000)
committerbors <bors@rust-lang.org>
Sun, 10 Nov 2019 12:18:53 +0000 (12:18 +0000)
Split libsyntax apart

In this PR the general idea is to separate the AST, parser, and friends by a more data / logic structure (tho not fully realized!) by separating out the parser and macro expansion code from libsyntax. Specifically have now three crates instead of one (libsyntax):

- libsyntax:

   - concrete syntax tree (`syntax::ast`)

   - definition of tokens and token-streams (`syntax::{token, tokenstream}`) -- used by `syntax::ast`

   - visitors (`syntax::visit`, `syntax::mut_visit`)

   - shared definitions between `libsyntax_expand`

   - feature gating (`syntax::feature_gate`) -- we could possibly move this out to its own crater later.

   - attribute and meta item utilities, including used-marking (`syntax::attr`)

   - pretty printer (`syntax::print`) -- this should possibly be moved out later. For now I've reduced down the dependencies to a single essential one which could be broken via `ParseSess`. This entails that e.g. `Debug` impls for `Path` cannot reference the pretty printer.

   - definition of `ParseSess` (`syntax::sess`) -- this is used by `syntax::{attr, print, feature_gate}` and is a common definition used by the parser and other things like librustc.

   - the `syntax::source_map` -- this includes definitions used by `syntax::ast` and other things but could ostensibly be moved `syntax_pos` since that is more related to this module.

   - a smattering of misc utilities not sufficiently important to itemize -- some of these could be moved to where they are used (often a single place) but I wanted to limit the scope of this PR.

- librustc_parse:

   - parser (`rustc_parse::parser`) -- reading a file and such are defined in the crate root tho.

   - lexer (`rustc_parse::lexer`)

   - validation of meta grammar (post-expansion) in (`rustc_parse::validate_attr`)

- libsyntax_expand -- this defines the infra for macro expansion and conditional compilation but this is not libsyntax_ext; we might want to merge them later but currently libsyntax_expand is depended on by librustc_metadata which libsyntax_ext is not.

   - conditional compilation (`syntax_expand::config`) -- moved from `syntax::config` to here

   - the bulk of this crate is made up of the old `syntax::ext`

r? @estebank

1  2 
Cargo.lock
src/librustc/session/mod.rs
src/librustc_driver/Cargo.toml
src/librustc_driver/lib.rs
src/librustc_interface/passes.rs
src/librustc_interface/util.rs
src/librustc_metadata/rmeta/decoder/cstore_impl.rs

diff --combined Cargo.lock
index 8b157d2b3f4bc3ddb19cbb2fac3058a3ef3e5541,7e51f96cfb8cbe6abd377ed394f217675a72d591..4ccbe752eb0483f0d935eef923d59de9661287d4
@@@ -3504,9 -3504,9 +3504,10 @@@ dependencies = 
   "rustc_lint",
   "rustc_metadata",
   "rustc_mir",
+  "rustc_parse",
   "rustc_plugin",
   "rustc_plugin_impl",
 + "rustc_resolve",
   "rustc_save_analysis",
   "rustc_target",
   "serialize",
@@@ -3572,6 -3572,7 +3573,7 @@@ dependencies = 
   "rustc_lint",
   "rustc_metadata",
   "rustc_mir",
+  "rustc_parse",
   "rustc_passes",
   "rustc_plugin_impl",
   "rustc_privacy",
@@@ -3649,6 -3650,7 +3651,7 @@@ dependencies = 
   "rustc_data_structures",
   "rustc_errors",
   "rustc_index",
+  "rustc_parse",
   "rustc_target",
   "serialize",
   "smallvec 1.0.0",
@@@ -3692,6 -3694,21 +3695,21 @@@ dependencies = 
   "core",
  ]
  
+ [[package]]
+ name = "rustc_parse"
+ version = "0.0.0"
+ dependencies = [
+  "bitflags",
+  "log",
+  "rustc_data_structures",
+  "rustc_errors",
+  "rustc_lexer",
+  "rustc_target",
+  "smallvec 1.0.0",
+  "syntax",
+  "syntax_pos",
+ ]
  [[package]]
  name = "rustc_passes"
  version = "0.0.0"
@@@ -3701,6 -3718,7 +3719,7 @@@ dependencies = 
   "rustc_data_structures",
   "rustc_errors",
   "rustc_index",
+  "rustc_parse",
   "rustc_target",
   "syntax",
   "syntax_pos",
@@@ -3763,6 -3781,7 +3782,7 @@@ dependencies = 
   "rustc",
   "rustc_codegen_utils",
   "rustc_data_structures",
+  "rustc_parse",
   "serde_json",
   "syntax",
   "syntax_pos",
@@@ -4372,14 -4391,11 +4392,11 @@@ dependencies = 
  name = "syntax_expand"
  version = "0.0.0"
  dependencies = [
-  "bitflags",
-  "lazy_static 1.3.0",
   "log",
   "rustc_data_structures",
   "rustc_errors",
-  "rustc_index",
   "rustc_lexer",
-  "scoped-tls",
+  "rustc_parse",
   "serialize",
   "smallvec 1.0.0",
   "syntax",
@@@ -4394,6 -4410,7 +4411,7 @@@ dependencies = 
   "log",
   "rustc_data_structures",
   "rustc_errors",
+  "rustc_parse",
   "rustc_target",
   "smallvec 1.0.0",
   "syntax",
index bab7ab89ce751b29c0bd04a50de7625168c2e697,9d702e7d6bf14a5a2c52493f39e0fac291aa7885..92e8e92d02a74e4cb737b5ba96c1998343307c2e
@@@ -21,12 -21,13 +21,12 @@@ use errors::{DiagnosticBuilder, Diagnos
  use errors::emitter::{Emitter, EmitterWriter};
  use errors::emitter::HumanReadableErrorType;
  use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
 -use syntax::ast::{self, NodeId};
  use syntax::edition::Edition;
  use syntax::expand::allocator::AllocatorKind;
  use syntax::feature_gate::{self, AttributeType};
  use syntax::json::JsonEmitter;
  use syntax::source_map;
- use syntax::sess::ParseSess;
+ use syntax::sess::{ParseSess, ProcessCfgMod};
  use syntax::symbol::Symbol;
  use syntax_pos::{MultiSpan, Span};
  use crate::util::profiling::{SelfProfiler, SelfProfilerRef};
@@@ -37,7 -38,7 +37,7 @@@ use rustc_data_structures::jobserver
  use ::jobserver::Client;
  
  use std;
 -use std::cell::{self, Cell, RefCell};
 +use std::cell::{self, RefCell};
  use std::env;
  use std::fmt;
  use std::io::Write;
@@@ -126,6 -127,8 +126,6 @@@ pub struct Session 
      /// Data about code being compiled, gathered during compilation.
      pub code_stats: Lock<CodeStats>,
  
 -    next_node_id: OneThread<Cell<ast::NodeId>>,
 -
      /// If `-zfuel=crate=n` is specified, `Some(crate)`.
      optimization_fuel_crate: Option<String>,
  
@@@ -352,6 -355,21 +352,6 @@@ impl Session 
          self.diagnostic().span_note_without_error(sp, msg)
      }
  
 -    pub fn reserve_node_ids(&self, count: usize) -> ast::NodeId {
 -        let id = self.next_node_id.get();
 -
 -        match id.as_usize().checked_add(count) {
 -            Some(next) => {
 -                self.next_node_id.set(ast::NodeId::from_usize(next));
 -            }
 -            None => bug!("input too large; ran out of node-IDs!"),
 -        }
 -
 -        id
 -    }
 -    pub fn next_node_id(&self) -> NodeId {
 -        self.reserve_node_ids(1)
 -    }
      pub fn diagnostic(&self) -> &errors::Handler {
          &self.parse_sess.span_diagnostic
      }
@@@ -934,6 -952,7 +934,7 @@@ pub fn build_session
      sopts: config::Options,
      local_crate_source_file: Option<PathBuf>,
      registry: errors::registry::Registry,
+     process_cfg_mod: ProcessCfgMod,
  ) -> Session {
      let file_path_mapping = sopts.file_path_mapping();
  
          Lrc::new(source_map::SourceMap::new(file_path_mapping)),
          DiagnosticOutput::Default,
          Default::default(),
+         process_cfg_mod,
      )
  }
  
@@@ -1022,6 -1042,7 +1024,7 @@@ pub fn build_session_with_source_map
      source_map: Lrc<source_map::SourceMap>,
      diagnostics_output: DiagnosticOutput,
      lint_caps: FxHashMap<lint::LintId, lint::Level>,
+     process_cfg_mod: ProcessCfgMod,
  ) -> Session {
      // FIXME: This is not general enough to make the warning lint completely override
      // normal diagnostic warnings, since the warning lint can also be denied and changed
          },
      );
  
-     build_session_(sopts, local_crate_source_file, diagnostic_handler, source_map, lint_caps)
+     build_session_(
+         sopts,
+         local_crate_source_file,
+         diagnostic_handler,
+         source_map,
+         lint_caps,
+         process_cfg_mod,
+     )
  }
  
  fn build_session_(
      span_diagnostic: errors::Handler,
      source_map: Lrc<source_map::SourceMap>,
      driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
+     process_cfg_mod: ProcessCfgMod,
  ) -> Session {
      let self_profiler =
          if let SwitchWithOptPath::Enabled(ref d) = sopts.debugging_opts.self_profile {
      let parse_sess = ParseSess::with_span_handler(
          span_diagnostic,
          source_map,
+         process_cfg_mod,
      );
      let sysroot = match &sopts.maybe_sysroot {
          Some(sysroot) => sysroot.clone(),
          recursion_limit: Once::new(),
          type_length_limit: Once::new(),
          const_eval_stack_frame_limit: 100,
 -        next_node_id: OneThread::new(Cell::new(NodeId::from_u32(1))),
          allocator_kind: Once::new(),
          injected_panic_runtime: Once::new(),
          imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
index 0a803187d49a8d8f27c21d5ab996460f81c04fe7,19726d6aff24860799f94b15f8373b16962979be..f1565a2bd0a5f16d514e74bd8e4648d23af58bb2
@@@ -21,12 -21,12 +21,13 @@@ rustc_data_structures = { path = "../li
  errors = { path = "../librustc_errors", package = "rustc_errors" }
  rustc_metadata = { path = "../librustc_metadata" }
  rustc_mir = { path = "../librustc_mir" }
+ rustc_parse = { path = "../librustc_parse" }
  rustc_plugin = { path = "../librustc_plugin/deprecated" } # To get this in the sysroot
  rustc_plugin_impl = { path = "../librustc_plugin" }
  rustc_save_analysis = { path = "../librustc_save_analysis" }
  rustc_codegen_utils = { path = "../librustc_codegen_utils" }
  rustc_interface = { path = "../librustc_interface" }
  rustc_serialize = { path = "../libserialize", package = "serialize" }
 +rustc_resolve = { path = "../librustc_resolve" }
  syntax = { path = "../libsyntax" }
  syntax_pos = { path = "../libsyntax_pos" }
index 7973a804f1a460a372b3bbde3ff429c189b8b8a6,380cbed4b21f352619ee246e5d4f699d1a54ba50..f2da4ae71f56aa63f80dd536ae9df143c08d1d48
@@@ -25,6 -25,8 +25,6 @@@ extern crate lazy_static
  
  pub extern crate rustc_plugin_impl as plugin;
  
 -use pretty::{PpMode, UserIdentifiedItem};
 -
  //use rustc_resolve as resolve;
  use rustc_save_analysis as save;
  use rustc_save_analysis::DumpHandler;
@@@ -63,7 -65,6 +63,6 @@@ use std::time::Instant
  use syntax::ast;
  use syntax::source_map::FileLoader;
  use syntax::feature_gate::{GatedCfg, UnstableFeatures};
- use syntax::parse;
  use syntax::symbol::sym;
  use syntax_pos::{DUMMY_SP, FileName};
  
@@@ -283,29 -284,33 +282,29 @@@ pub fn run_compiler
              return sess.compile_status();
          }
  
 -        let pretty_info = parse_pretty(sess, &matches);
 -
          compiler.parse()?;
  
 -        if let Some((ppm, opt_uii)) = pretty_info {
 +        if let Some((ppm, opt_uii)) = &sess.opts.pretty {
              if ppm.needs_ast_map(&opt_uii) {
 -                pretty::visit_crate(sess, &mut compiler.parse()?.peek_mut(), ppm);
                  compiler.global_ctxt()?.peek_mut().enter(|tcx| {
                      let expanded_crate = compiler.expansion()?.take().0;
                      pretty::print_after_hir_lowering(
                          tcx,
                          compiler.input(),
                          &expanded_crate,
 -                        ppm,
 +                        *ppm,
                          opt_uii.clone(),
                          compiler.output_file().as_ref().map(|p| &**p),
                      );
                      Ok(())
                  })?;
              } else {
 -                let mut krate = compiler.parse()?.take();
 -                pretty::visit_crate(sess, &mut krate, ppm);
 +                let krate = compiler.parse()?.take();
                  pretty::print_after_parsing(
                      sess,
                      &compiler.input(),
                      &krate,
 -                    ppm,
 +                    *ppm,
                      compiler.output_file().as_ref().map(|p| &**p),
                  );
              }
@@@ -464,6 -469,28 +463,6 @@@ fn make_input(free_matches: &[String]) 
      }
  }
  
 -fn parse_pretty(sess: &Session,
 -                matches: &getopts::Matches)
 -                -> Option<(PpMode, Option<UserIdentifiedItem>)> {
 -    let pretty = if sess.opts.debugging_opts.unstable_options {
 -        matches.opt_default("pretty", "normal").map(|a| {
 -            // stable pretty-print variants only
 -            pretty::parse_pretty(sess, &a, false)
 -        })
 -    } else {
 -        None
 -    };
 -
 -    if pretty.is_none() {
 -        sess.opts.debugging_opts.unpretty.as_ref().map(|a| {
 -            // extended with unstable pretty-print variants
 -            pretty::parse_pretty(sess, &a, true)
 -        })
 -    } else {
 -        pretty
 -    }
 -}
 -
  // Whether to stop or continue compilation.
  #[derive(Copy, Clone, Debug, Eq, PartialEq)]
  pub enum Compilation {
@@@ -1016,6 -1043,12 +1015,6 @@@ pub fn handle_options(args: &[String]) 
      //   (unstable option being used on stable)
      nightly_options::check_nightly_options(&matches, &config::rustc_optgroups());
  
 -    // Late check to see if @file was used without unstable options enabled
 -    if crate::args::used_unstable_argsfile() && !nightly_options::is_unstable_enabled(&matches) {
 -        early_error(ErrorOutputType::default(),
 -            "@path is unstable - use -Z unstable-options to enable its use");
 -    }
 -
      if matches.opt_present("h") || matches.opt_present("help") {
          // Only show unstable options in --help if we accept unstable options.
          usage(matches.opt_present("verbose"), nightly_options::is_unstable_enabled(&matches));
  }
  
  fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<ast::Attribute>> {
-     match *input {
-         Input::File(ref ifile) => {
-             parse::parse_crate_attrs_from_file(ifile, &sess.parse_sess)
+     match input {
+         Input::File(ifile) => {
+             rustc_parse::parse_crate_attrs_from_file(ifile, &sess.parse_sess)
          }
-         Input::Str { ref name, ref input } => {
-             parse::parse_crate_attrs_from_source_str(name.clone(),
-                                                      input.clone(),
-                                                      &sess.parse_sess)
+         Input::Str { name, input } => {
+             rustc_parse::parse_crate_attrs_from_source_str(
+                 name.clone(),
+                 input.clone(),
+                 &sess.parse_sess,
+             )
          }
      }
  }
index 04a0b0e761961b9d1d730ab43fc2a7be4ac146c2,0e38de9a0ed17c94434209ca22d318654ba3e33d..453007c564246b8aee68be8d92c845c04f021bd6
@@@ -16,7 -16,6 +16,7 @@@ use rustc::traits
  use rustc::util::common::{time, ErrorReported};
  use rustc::session::Session;
  use rustc::session::config::{self, CrateType, Input, OutputFilenames, OutputType};
 +use rustc::session::config::{PpMode, PpSourceMode};
  use rustc::session::search_paths::PathKind;
  use rustc_codegen_ssa::back::link::emit_metadata;
  use rustc_codegen_utils::codegen_backend::CodegenBackend;
@@@ -27,6 -26,7 +27,7 @@@ use rustc_errors::PResult
  use rustc_incremental;
  use rustc_metadata::cstore;
  use rustc_mir as mir;
+ use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
  use rustc_passes::{self, ast_validation, hir_stats, layout_test};
  use rustc_plugin as plugin;
  use rustc_plugin::registry::Registry;
@@@ -38,7 -38,6 +39,6 @@@ use syntax::{self, ast, visit}
  use syntax::early_buffered_lints::BufferedEarlyLint;
  use syntax_expand::base::{NamedSyntaxExtension, ExtCtxt};
  use syntax::mut_visit::MutVisitor;
- use syntax::parse;
  use syntax::util::node_count::NodeCounter;
  use syntax::symbol::Symbol;
  use syntax_pos::FileName;
@@@ -61,12 -60,11 +61,11 @@@ pub fn parse<'a>(sess: &'a Session, inp
      let krate = time(sess, "parsing", || {
          let _prof_timer = sess.prof.generic_activity("parse_crate");
  
-         match *input {
-             Input::File(ref file) => parse::parse_crate_from_file(file, &sess.parse_sess),
-             Input::Str {
-                 ref input,
-                 ref name,
-             } => parse::parse_crate_from_source_str(name.clone(), input.clone(), &sess.parse_sess),
+         match input {
+             Input::File(file) => parse_crate_from_file(file, &sess.parse_sess),
+             Input::Str { input, name } => {
+                 parse_crate_from_source_str(name.clone(), input.clone(), &sess.parse_sess)
+             }
          }
      })?;
  
@@@ -182,7 -180,7 +181,7 @@@ pub fn register_plugins<'a>
          )
      });
  
-     let (krate, features) = syntax::config::features(
+     let (krate, features) = syntax_expand::config::features(
          krate,
          &sess.parse_sess,
          sess.edition(),
@@@ -395,12 -393,8 +394,12 @@@ fn configure_and_expand_inner<'a>
  
      // If we're actually rustdoc then there's no need to actually compile
      // anything, so switch everything to just looping
 -    if sess.opts.actually_rustdoc {
 -        util::ReplaceBodyWithLoop::new(sess).visit_crate(&mut krate);
 +    let mut should_loop = sess.opts.actually_rustdoc;
 +    if let Some((PpMode::PpmSource(PpSourceMode::PpmEveryBodyLoops), _)) = sess.opts.pretty {
 +        should_loop |= true;
 +    }
 +    if should_loop {
 +        util::ReplaceBodyWithLoop::new(&mut resolver).visit_crate(&mut krate);
      }
  
      let has_proc_macro_decls = time(sess, "AST validation", || {
@@@ -489,7 -483,7 +488,7 @@@ pub fn lower_to_hir
  ) -> Result<hir::map::Forest> {
      // Lower AST to HIR.
      let hir_forest = time(sess, "lowering AST -> HIR", || {
-         let nt_to_tokenstream = syntax::parse::nt_to_tokenstream;
+         let nt_to_tokenstream = rustc_parse::nt_to_tokenstream;
          let hir_crate = lower_crate(sess, &dep_graph, &krate, resolver, nt_to_tokenstream);
  
          if sess.opts.debugging_opts.hir_stats {
index 0c08f65d11d95f97f29fea02a534c0c17a85fea0,1cdb0ac87c51be633d091b4c9c392aee0c02eae6..115345955aea330824320de10f86a357ec8ffb71
@@@ -18,7 -18,7 +18,7 @@@ use rustc_mir
  use rustc_passes;
  use rustc_plugin;
  use rustc_privacy;
 -use rustc_resolve;
 +use rustc_resolve::{self, Resolver};
  use rustc_typeck;
  use std::env;
  use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
@@@ -36,6 -36,7 +36,7 @@@ use syntax::util::lev_distance::find_be
  use syntax::source_map::{FileLoader, RealFileLoader, SourceMap};
  use syntax::symbol::{Symbol, sym};
  use syntax::{self, ast, attr};
+ use syntax_expand::config::process_configure_mod;
  use syntax_pos::edition::Edition;
  #[cfg(not(parallel_compiler))]
  use std::{thread, panic};
@@@ -49,6 -50,7 +50,7 @@@ pub fn diagnostics_registry() -> Regist
      // FIXME: need to figure out a way to get these back in here
      // all_errors.extend_from_slice(get_codegen_backend(sess).diagnostics());
      all_errors.extend_from_slice(&rustc_metadata::error_codes::DIAGNOSTICS);
+     all_errors.extend_from_slice(&rustc_parse::error_codes::DIAGNOSTICS);
      all_errors.extend_from_slice(&rustc_passes::error_codes::DIAGNOSTICS);
      all_errors.extend_from_slice(&rustc_plugin::error_codes::DIAGNOSTICS);
      all_errors.extend_from_slice(&rustc_mir::error_codes::DIAGNOSTICS);
@@@ -103,6 -105,7 +105,7 @@@ pub fn create_session
          source_map.clone(),
          diagnostic_output,
          lint_caps,
+         process_configure_mod,
      );
  
      let codegen_backend = get_codegen_backend(&sess);
@@@ -715,18 -718,18 +718,18 @@@ pub fn build_output_filenames
  //    ambitious form of the closed RFC #1637. See also [#34511].
  //
  // [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
 -pub struct ReplaceBodyWithLoop<'a> {
 +pub struct ReplaceBodyWithLoop<'a, 'b> {
      within_static_or_const: bool,
      nested_blocks: Option<Vec<ast::Block>>,
 -    sess: &'a Session,
 +    resolver: &'a mut Resolver<'b>,
  }
  
 -impl<'a> ReplaceBodyWithLoop<'a> {
 -    pub fn new(sess: &'a Session) -> ReplaceBodyWithLoop<'a> {
 +impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
 +    pub fn new(resolver: &'a mut Resolver<'b>) -> ReplaceBodyWithLoop<'a, 'b> {
          ReplaceBodyWithLoop {
              within_static_or_const: false,
              nested_blocks: None,
 -            sess
 +            resolver,
          }
      }
  
      }
  
      fn is_sig_const(sig: &ast::FnSig) -> bool {
 -        sig.header.constness.node == ast::Constness::Const || Self::should_ignore_fn(&sig.decl)
 +        sig.header.constness.node == ast::Constness::Const ||
 +            ReplaceBodyWithLoop::should_ignore_fn(&sig.decl)
      }
  }
  
 -impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
 +impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
      fn visit_item_kind(&mut self, i: &mut ast::ItemKind) {
          let is_const = match i {
              ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => true,
      fn visit_block(&mut self, b: &mut P<ast::Block>) {
          fn stmt_to_block(rules: ast::BlockCheckMode,
                           s: Option<ast::Stmt>,
 -                         sess: &Session) -> ast::Block {
 +                         resolver: &mut Resolver<'_>) -> ast::Block {
              ast::Block {
                  stmts: s.into_iter().collect(),
                  rules,
 -                id: sess.next_node_id(),
 +                id: resolver.next_node_id(),
                  span: syntax_pos::DUMMY_SP,
              }
          }
  
 -        fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt {
 +        fn block_to_stmt(b: ast::Block, resolver: &mut Resolver<'_>) -> ast::Stmt {
              let expr = P(ast::Expr {
 -                id: sess.next_node_id(),
 +                id: resolver.next_node_id(),
                  kind: ast::ExprKind::Block(P(b), None),
                  span: syntax_pos::DUMMY_SP,
                  attrs: ThinVec::new(),
              });
  
              ast::Stmt {
 -                id: sess.next_node_id(),
 +                id: resolver.next_node_id(),
                  kind: ast::StmtKind::Expr(expr),
                  span: syntax_pos::DUMMY_SP,
              }
          }
  
 -        let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
 +        let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.resolver);
          let loop_expr = P(ast::Expr {
              kind: ast::ExprKind::Loop(P(empty_block), None),
 -            id: self.sess.next_node_id(),
 +            id: self.resolver.next_node_id(),
              span: syntax_pos::DUMMY_SP,
                  attrs: ThinVec::new(),
          });
  
          let loop_stmt = ast::Stmt {
 -            id: self.sess.next_node_id(),
 +            id: self.resolver.next_node_id(),
              span: syntax_pos::DUMMY_SP,
              kind: ast::StmtKind::Expr(loop_expr),
          };
                      // we put a Some in there earlier with that replace(), so this is valid
                      let new_blocks = self.nested_blocks.take().unwrap();
                      self.nested_blocks = old_blocks;
 -                    stmts.extend(new_blocks.into_iter().map(|b| block_to_stmt(b, &self.sess)));
 +                    stmts.extend(new_blocks.into_iter().map(|b| block_to_stmt(b, self.resolver)));
                  }
  
                  let mut new_block = ast::Block {
                          old_blocks.push(new_block);
                      }
  
 -                    stmt_to_block(b.rules, Some(loop_stmt), self.sess)
 +                    stmt_to_block(b.rules, Some(loop_stmt), &mut self.resolver)
                  } else {
                      //push `loop {}` onto the end of our fresh block and yield that
                      new_block.stmts.push(loop_stmt);
index 1118162bdeb021940ca6a3200ba312ace7e06640,19cfdeac57edb8f39d279b604625af83fb751f81..015866548cd3846d3c3e191b647fc7113ab50c83
@@@ -18,6 -18,8 +18,8 @@@ use rustc::hir::map::{DefKey, DefPath, 
  use rustc::hir::map::definitions::DefPathTable;
  use rustc::util::nodemap::DefIdMap;
  use rustc_data_structures::svh::Svh;
+ use rustc_parse::source_file_to_stream;
+ use rustc_parse::parser::emit_unclosed_delims;
  
  use smallvec::SmallVec;
  use std::any::Any;
@@@ -27,11 -29,10 +29,9 @@@ use std::sync::Arc
  use syntax::ast;
  use syntax::attr;
  use syntax::source_map;
- use syntax::parse::source_file_to_stream;
- use syntax::parse::parser::emit_unclosed_delims;
  use syntax::source_map::Spanned;
  use syntax::symbol::Symbol;
  use syntax_pos::{Span, FileName};
 -use rustc_index::bit_set::BitSet;
  
  macro_rules! provide {
      (<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
@@@ -121,7 -122,9 +121,7 @@@ provide! { <'tcx> tcx, def_id, other, c
      }
      optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
      promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
 -    mir_const_qualif => {
 -        (cdata.mir_const_qualif(def_id.index), tcx.arena.alloc(BitSet::new_empty(0)))
 -    }
 +    mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
      fn_sig => { cdata.fn_sig(def_id.index, tcx) }
      inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
      is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }