Skip to content

Commit 39c0fa8

Browse files
Move syntax_expand::config to rustc_parse::config
1 parent 618b01f commit 39c0fa8

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/libsyntax_expand/config.rs renamed to src/librustc_parse/config.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
use rustc_parse::validate_attr;
1+
//! Process the potential `cfg` attributes on a module.
2+
//! Also determine if the module should be included in this configuration.
3+
//!
4+
//! This module properly belongs in syntax_expand, but for now it's tied into
5+
//! parsing, so we leave it here to avoid complicated out-of-line dependencies.
6+
//!
7+
//! A principled solution to this wrong location would be to implement [#64197].
8+
//!
9+
//! [#64197]: https://github.com/rust-lang/rust/issues/64197
10+
11+
use crate::validate_attr;
212
use syntax::attr::HasAttrs;
313
use syntax::feature_gate::{
414
feature_err,
@@ -113,7 +123,7 @@ impl<'a> StripUnconfigured<'a> {
113123
return vec![];
114124
}
115125

116-
let res = rustc_parse::parse_in_attr(self.sess, &attr, |p| p.parse_cfg_attr());
126+
let res = crate::parse_in_attr(self.sess, &attr, |p| p.parse_cfg_attr());
117127
let (cfg_predicate, expanded_attrs) = match res {
118128
Ok(result) => result,
119129
Err(mut e) => {

src/librustc_parse/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub mod parser;
2525
use parser::{Parser, emit_unclosed_delims, make_unclosed_delims_error};
2626
pub mod lexer;
2727
pub mod validate_attr;
28+
#[macro_use]
29+
pub mod config;
2830

2931
#[derive(Clone)]
3032
pub struct Directory<'a> {

src/librustc_parse/parser/module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a> Parser<'a> {
4141
/// Parses a `mod <foo> { ... }` or `mod <foo>;` item.
4242
pub(super) fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a, ItemInfo> {
4343
// HACK(Centril): See documentation on `ParseSess::process_cfg_mod`.
44-
let (in_cfg, outer_attrs) = (self.sess.process_cfg_mod)(
44+
let (in_cfg, outer_attrs) = crate::config::process_configure_mod(
4545
self.sess,
4646
self.cfg_mods,
4747
outer_attrs,

src/libsyntax_expand/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::hygiene::{ExpnId, SyntaxContext, ExpnData, ExpnKind};
44
use crate::mbe::macro_rules::annotate_err_with_kind;
55
use crate::placeholders::{placeholder, PlaceholderExpander};
66
use crate::config::StripUnconfigured;
7-
use crate::configure;
7+
use rustc_parse::configure;
88

99
use rustc_parse::DirectoryOwnership;
1010
use rustc_parse::parser::Parser;

src/libsyntax_expand/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub use mbe::macro_rules::compile_declarative_macro;
3333
pub mod base;
3434
pub mod build;
3535
pub mod expand;
36-
#[macro_use] pub mod config;
36+
pub use rustc_parse::config;
3737
pub mod proc_macro;
3838

3939
crate mod mbe;

0 commit comments

Comments
 (0)