From 39c0fa847e74e59f96dc6b01d912252f8cdb72eb Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 19 Nov 2019 21:35:11 -0500 Subject: [PATCH] Move syntax_expand::config to rustc_parse::config --- src/{libsyntax_expand => librustc_parse}/config.rs | 14 ++++++++++++-- src/librustc_parse/lib.rs | 2 ++ src/librustc_parse/parser/module.rs | 2 +- src/libsyntax_expand/expand.rs | 2 +- src/libsyntax_expand/lib.rs | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) rename src/{libsyntax_expand => librustc_parse}/config.rs (96%) diff --git a/src/libsyntax_expand/config.rs b/src/librustc_parse/config.rs similarity index 96% rename from src/libsyntax_expand/config.rs rename to src/librustc_parse/config.rs index 7b927fb55f9..7ce555ed57a 100644 --- a/src/libsyntax_expand/config.rs +++ b/src/librustc_parse/config.rs @@ -1,4 +1,14 @@ -use rustc_parse::validate_attr; +//! Process the potential `cfg` attributes on a module. +//! Also determine if the module should be included in this configuration. +//! +//! This module properly belongs in syntax_expand, but for now it's tied into +//! parsing, so we leave it here to avoid complicated out-of-line dependencies. +//! +//! A principled solution to this wrong location would be to implement [#64197]. +//! +//! [#64197]: https://github.com/rust-lang/rust/issues/64197 + +use crate::validate_attr; use syntax::attr::HasAttrs; use syntax::feature_gate::{ feature_err, @@ -113,7 +123,7 @@ fn process_cfg_attr(&mut self, attr: ast::Attribute) -> Vec { return vec![]; } - let res = rustc_parse::parse_in_attr(self.sess, &attr, |p| p.parse_cfg_attr()); + let res = crate::parse_in_attr(self.sess, &attr, |p| p.parse_cfg_attr()); let (cfg_predicate, expanded_attrs) = match res { Ok(result) => result, Err(mut e) => { diff --git a/src/librustc_parse/lib.rs b/src/librustc_parse/lib.rs index 3a983404220..1215c7a199a 100644 --- a/src/librustc_parse/lib.rs +++ b/src/librustc_parse/lib.rs @@ -25,6 +25,8 @@ use parser::{Parser, emit_unclosed_delims, make_unclosed_delims_error}; pub mod lexer; pub mod validate_attr; +#[macro_use] +pub mod config; #[derive(Clone)] pub struct Directory<'a> { diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs index 3110f15e80b..1621c9ffc02 100644 --- a/src/librustc_parse/parser/module.rs +++ b/src/librustc_parse/parser/module.rs @@ -41,7 +41,7 @@ pub fn parse_crate_mod(&mut self) -> PResult<'a, Crate> { /// Parses a `mod { ... }` or `mod ;` item. pub(super) fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a, ItemInfo> { // HACK(Centril): See documentation on `ParseSess::process_cfg_mod`. - let (in_cfg, outer_attrs) = (self.sess.process_cfg_mod)( + let (in_cfg, outer_attrs) = crate::config::process_configure_mod( self.sess, self.cfg_mods, outer_attrs, diff --git a/src/libsyntax_expand/expand.rs b/src/libsyntax_expand/expand.rs index 06aa5deb6e0..2532bbc0fe2 100644 --- a/src/libsyntax_expand/expand.rs +++ b/src/libsyntax_expand/expand.rs @@ -4,7 +4,7 @@ use crate::mbe::macro_rules::annotate_err_with_kind; use crate::placeholders::{placeholder, PlaceholderExpander}; use crate::config::StripUnconfigured; -use crate::configure; +use rustc_parse::configure; use rustc_parse::DirectoryOwnership; use rustc_parse::parser::Parser; diff --git a/src/libsyntax_expand/lib.rs b/src/libsyntax_expand/lib.rs index 46d59dd249c..0aa34af7a76 100644 --- a/src/libsyntax_expand/lib.rs +++ b/src/libsyntax_expand/lib.rs @@ -33,7 +33,7 @@ macro_rules! panictry { pub mod base; pub mod build; pub mod expand; -#[macro_use] pub mod config; +pub use rustc_parse::config; pub mod proc_macro; crate mod mbe; -- 2.44.0