Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakis
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
This commit is contained in:
commit
f1ea5cc273
5 changed files with 40 additions and 18 deletions
|
|
@ -17,4 +17,15 @@ mod mod_dir_simple {
|
|||
|
||||
pub fn main() {
|
||||
assert_eq!(mod_dir_simple::syrup::foo(), 10);
|
||||
|
||||
#[path = "auxiliary"]
|
||||
mod foo {
|
||||
mod two_macros;
|
||||
}
|
||||
|
||||
#[path = "auxiliary"]
|
||||
mod bar {
|
||||
macro_rules! m { () => { mod two_macros; } }
|
||||
m!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue