diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-29 09:28:50 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-29 09:35:56 +0000 |
| commit | db57e67452c00a18ac68845717c5c20e3db77888 (patch) | |
| tree | 229da4cd358e16875005cdf51083616c51a7843a /src/libsyntax | |
| parent | ea0dc9297283daff6486807f43e190b4eb561412 (diff) | |
| download | rust-db57e67452c00a18ac68845717c5c20e3db77888.tar.gz rust-db57e67452c00a18ac68845717c5c20e3db77888.zip | |
Support `cfg_attr` on `path` attributes
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/config.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 961763c6025..36a4568b693 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -33,7 +33,7 @@ impl<'a> StripUnconfigured<'a> { if self.in_cfg(node.attrs()) { Some(node) } else { None } } - fn process_cfg_attrs<T: HasAttrs>(&mut self, node: T) -> T { + pub fn process_cfg_attrs<T: HasAttrs>(&mut self, node: T) -> T { node.map_attrs(|attrs| { attrs.into_iter().filter_map(|attr| self.process_cfg_attr(attr)).collect() }) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 813d90103b8..db101e459db 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5301,15 +5301,22 @@ impl<'a> Parser<'a> { /// Parse a `mod <foo> { ... }` or `mod <foo>;` item fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a, ItemInfo> { + let outer_attrs = ::config::StripUnconfigured { + config: &self.cfg, + sess: self.sess, + should_test: false, // irrelevant + features: None, // don't perform gated feature checking + }.process_cfg_attrs(outer_attrs.to_owned()); + let id_span = self.span; let id = self.parse_ident()?; if self.check(&token::Semi) { self.bump(); // This mod is in an external file. Let's go get it! - let (m, attrs) = self.eval_src_mod(id, outer_attrs, id_span)?; + let (m, attrs) = self.eval_src_mod(id, &outer_attrs, id_span)?; Ok((id, m, Some(attrs))) } else { - self.push_mod_path(id, outer_attrs); + self.push_mod_path(id, &outer_attrs); self.expect(&token::OpenDelim(token::Brace))?; let mod_inner_lo = self.span.lo; let attrs = self.parse_inner_attributes()?; |
