-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn extern crate
and use
into first-class items.
#20179
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
} | ||
} | ||
visit::walk_view_item(self, i); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks seem to have gone away with no replacement, was that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're duplicated in the item checking path, though they use a slightly different error message.
Nice! I'll review the parser changes in more detail soon, but everything else looked pretty good to me (just one small nit). Some tests I'd like to see as well:
|
9562473
to
2b978f0
Compare
@alexcrichton r? this has had rustdoc fixed for a while - tests are still missing but @Kimundi has expressed interest in working on that while I deal with other things. |
Can you update the description to not close #18219? The changes there are quite extensive and look like they go beyond just the changes made here. |
I'm also pretty worried about allowing view items anywhere within blocks just yet. The RFC says that the original reason for the ordering restriction was due to the way shadowing was implemented (to make it more clear), but with shadowing now removed the semantics are clear not matter what order items are in. I'm not sure this is true for blocks though: let foo = 3;
use bar::foo;
println!("{}", foo); // what does this print? I think that lifting the restriction for items are fine, but due to our allowance of shadowing with local variables, I don't think we should lift the restriction in expressions. |
I also do not want to land this without any tests, new features like this really do need to be extensively tested so we don't have to hold up a release (for an otherwise backwards-compatible change) with another blocking issue while we fix a bug that may have been turned up with tests. |
I think I would handle such ordering restrictions in |
As far as I know, those ordering restrictions don't apply to items, as those are mutually recursive visible:
So, what a construct like |
Ah, this causes the weird "only irrefutable patterns allowed here" error (can we stop matching constants in irrefutable patterns already?): fn main() {
let foo = 5u;
const foo: uint = 42;
println!("{}", foo);
} And when that is not an issue, it seems that local bindings shadow items: fn main() {
let foo = || 5u;
fn foo() -> uint { 42 }
println!("{}", foo()); // prints 5
} |
This is partly why I would like to be conservative here and lift the restriction at a later date. I don't want to allow rearranging items hoping for changes to resolve to land soon, I would rather land the two at the same time. @Kimundi has a good point though that other items are already plagued by this unfortunate shadowing, so it may not be as dire as I think, but I'd prefer to stem the flow of awkward questions rather than pile more on. |
I guess the forward compatible thing would be to either artificially keep the order restriction in blocks, or to make local bindings with the same name as an item in the same flat scope a hard error. This is of course not the place to discuss those things, but I guess the only "sane" semantic for items in blocks in general is the current situation: items are visible everywhere in a scope, but locals, having the property of allowing forward-only shadowing of elements in the same scope, can shadow them. Otherwise you get weird inconsistent semantic between those two entities:
|
cb84d38
to
210cb5d
Compare
@alexcrichton now that alpha's over, I've rebased this branch and added that error you requested, in the last commit. r? |
4000a49
to
9574724
Compare
"compile time crate loading is \ | ||
experimental and possibly buggy"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may have snuck back in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, indeed, a few of these were merged automatically during the rebase.
Alright, this all looks great to me, thanks @eddyb! This is a pretty big change though so I would like to bring it up at the next weekly meeting just to make sure everyone's comfortable with pulling the trigger. |
@bors: retry |
⌛ Testing commit 2d17a33 with merge 4a0ed0d... |
💔 Test failed - auto-linux-64-nopt-t |
@bors: retry |
⌛ Testing commit 2d17a33 with merge 7f674df... |
💔 Test failed - auto-linux-32-nopt-t |
@bors: retry |
⌛ Testing commit 2d17a33 with merge 1499596... |
💔 Test failed - auto-linux-64-x-android-t |
@bors: retry |
⌛ Testing commit 2d17a33 with merge 4b417b8... |
💔 Test failed - auto-linux-32-opt |
@bors: retry |
Does this fix #18810 ? |
rust-lang/rust#20179 makes its use case much weaker.
rust-lang/rust#20179 makes its use case much weaker. r? @Manishearth <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6159) <!-- Reviewable:end -->
…om SimonSapin:no_mod_path); r=Manishearth rust-lang/rust#20179 makes its use case much weaker. r? @Manishearth Source-Repo: https://github.com/servo/servo Source-Revision: e04d9c32a98ff4673f413ed17f66e7466e2ff974
…om SimonSapin:no_mod_path); r=Manishearth rust-lang/rust#20179 makes its use case much weaker. r? Manishearth Source-Repo: https://github.com/servo/servo Source-Revision: e04d9c32a98ff4673f413ed17f66e7466e2ff974 UltraBlame original commit: 81933413281cee300e35174beae0d9bf87083c71
…om SimonSapin:no_mod_path); r=Manishearth rust-lang/rust#20179 makes its use case much weaker. r? Manishearth Source-Repo: https://github.com/servo/servo Source-Revision: e04d9c32a98ff4673f413ed17f66e7466e2ff974 UltraBlame original commit: 81933413281cee300e35174beae0d9bf87083c71
…om SimonSapin:no_mod_path); r=Manishearth rust-lang/rust#20179 makes its use case much weaker. r? Manishearth Source-Repo: https://github.com/servo/servo Source-Revision: e04d9c32a98ff4673f413ed17f66e7466e2ff974 UltraBlame original commit: 81933413281cee300e35174beae0d9bf87083c71
This implements an important part of RFC PR 385 (see #18219).