]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakis
authorJonathan Turner <jonathandturner@users.noreply.github.com>
Thu, 29 Sep 2016 03:21:52 +0000 (20:21 -0700)
committerGitHub <noreply@github.com>
Thu, 29 Sep 2016 03:21:52 +0000 (20:21 -0700)
Allow more non-inline modules in blocks

Currently, non-inline modules without a `#[path]` attribute are not allowed in blocks.
This PR allows non-inline modules that have an ancestor module with a `#[path]` attribute, provided there is not a nearer ancestor block.

For example,
```rust
fn main() {
    #[path = "..."] mod foo {
        mod bar; //< allowed by this PR
        fn f() {
            mod bar; //< still an error
        }
    }
}
```

Fixes #36772.
r? @nikomatsakis

1  2 
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/parse/parser.rs

Simple merge
index 36a33dcc5c570aa201effdf160513b5b2b9f0c03,bc56c54ea5241fcb90b5aa5e0190c20c638ecdfa..b1d828d0e3e4938446beda36e0fe2daacf0bf331
@@@ -731,15 -669,9 +735,16 @@@ impl<'a, 'b> Folder for InvocationColle
                      mem::replace(&mut self.cx.current_expansion.module, Rc::new(module));
                  let result = noop_fold_item(item, self);
                  self.cx.current_expansion.module = orig_module;
+                 self.cx.current_expansion.no_noninline_mod = orig_no_noninline_mod;
                  return result;
              }
 +            // Ensure that test functions are accessible from the test harness.
 +            ast::ItemKind::Fn(..) if self.cx.ecfg.should_test => {
 +                if item.attrs.iter().any(|attr| is_test_or_bench(attr)) {
 +                    item = item.map(|mut item| { item.vis = ast::Visibility::Public; item });
 +                }
 +                noop_fold_item(item, self)
 +            }
              _ => noop_fold_item(item, self),
          }
      }
Simple merge
Simple merge