Allow more non-inline modules in blocks#36789
Merged
bors merged 2 commits intorust-lang:masterfrom Sep 29, 2016
Merged
Conversation
Contributor
Author
23c2976 to
414c52b
Compare
nikomatsakis
approved these changes
Sep 28, 2016
Contributor
nikomatsakis
left a comment
There was a problem hiding this comment.
r=me with a comment on the field
src/libsyntax/ext/base.rs
Outdated
Contributor
There was a problem hiding this comment.
I think this field could use a comment. The meaning of its name is not immediately obvious on its own, I'd say...
414c52b to
174f093
Compare
Contributor
Author
|
@bors r=nikomatsakis |
Collaborator
|
📌 Commit 174f093 has been approved by |
sophiajt
pushed a commit
to sophiajt/rust
that referenced
this pull request
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
bors
added a commit
that referenced
this pull request
Nov 22, 2016
parser: simplify directory ownership semantics This PR simplifies the semantics of "directory ownership". After this PR, - a non-inline module without a `#[path]` attribute (e.g. `mod foo;`) is allowed iff its parent module/block (whichever is nearer) is a directory owner, - an non-inline module is a directory owner iff its corresponding file is named `mod.rs` (c.f. [comment](#32401 (comment))), - a block is never a directory owner (c.f. #31534), and - an inline module is a directory owner iff either - its parent module/block is a directory owner (again, c.f. #31534), or - it has a `#[path]` attribute (c.f. #36789). These semantics differ from today's in three orthogonal ways: - `#[path = "foo.rs"] mod foo;` is no longer a directory owner. This is a [breaking-change]. - #36789 is generalized to apply to modules that are not directory owners in addition to blocks. - A macro-expanded non-inline module is only allowed where an ordinary non-inline module would be allowed. Today, we incorrectly allow macro-expanded non-inline modules in modules that are not directory owners (but not in blocks). This is a [breaking-change]. Fixes #32401. r? @nikomatsakis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
Fixes #36772.
r? @nikomatsakis