Skip to content

non-line mod without path attribute false positive #36772

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matklad opened this issue Sep 27, 2016 · 0 comments
Closed

non-line mod without path attribute false positive #36772

matklad opened this issue Sep 27, 2016 · 0 comments

Comments

@matklad
Copy link
Member

matklad commented Sep 27, 2016

This code

fn main() {
    #[path="foo"]
    mod foo {
        mod bar;
    }
}

Fails to compile because there is no path on the bar, however I think it should work because there is a path on the foo. That is, the following is valid and will look for foo/bar.rs:

fn main() {}

#[path="foo"]
mod foo {
    mod bar;
}

cc @jseyfried d21e908

sophiajt pushed a commit to sophiajt/rust that referenced this issue Sep 29, 2016
…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 rust-lang#36772.
r? @nikomatsakis
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant