Uh oh!
There was an error while loading. Please reload this page.
Resolve: stop requiring use and extern crate declarations to precede statements in blocks - #31144
Conversation
rust-highfive
commented
Jan 23, 2016
(rust_highfive has picked a reviewer for you, use r? to override) |
nagisa
commented
Jan 23, 2016
I personally think that lifting the restriction in question could only result in worse code. Perhaps we should downgrade it to a warning-by-default lint? |
jseyfried
commented
Jan 24, 2016
@nagisa If so, I think this example (for modules, also applies to enums) and this example (for structs) from the RFC motivate allowing If not, I think we should not permit any item to follow a statement (or at least make it a warning/lint). I would be OK with this, but I don't see any reason to only permit a certain class of item like we are doing now. |
alexcrichton
commented
Jan 24, 2016
r? @nrc cc @rust-lang/lang |
huonw
commented
Jan 24, 2016
I feel like this would allow something like fnfoo(){}fnbar(){foo();use qux::foo;foo();}which would presumably be calling |
jseyfried
commented
Jan 24, 2016
@huonw I agree that your example is problematic, but we currently allow fnfoo(){}fnbar(){foo();// Prints "foo!"fnfoo(){println!("foo!");}foo();// Prints "foo!"}which I think is problematic for exactly the same reason. |
huonw
commented
Jan 24, 2016
I don't think something confusing existing already is a good justification for adding more confusing things. :) Don't get me wrong though: uniformity is a good reason. |
petrochenkov
commented
Jan 24, 2016
+1 to this PR, item scoping in blocks may already be surprising and needs to be explained well, and random exceptions don't make things easier to explain. |
oli-obk
commented
Jan 24, 2016
clippy now has an |
nrc
commented
Jan 28, 2016
@bors: r+ |
bors
commented
Jan 28, 2016
📌 Commit f05bc16 has been approved by |
bors
commented
Jan 29, 2016
⌛ Testing commit f05bc16 with merge f030d1f... |
…r=nrc We no longer require `use` and `extern crate` items to precede other items in modules thanks to [RFC #385](rust-lang/rfcs#385), but we still require `use` and `extern crate` items to precede statements in blocks (other items can appear anywhere in a block). I think that this is a needless distinction between imports and other items that contradicts the intent of the RFC.
We no longer require
useandextern crateitems to precede other items in modules thanks to RFC #385, but we still requireuseandextern crateitems to precede statements in blocks (other items can appear anywhere in a block).I think that this is a needless distinction between imports and other items that contradicts the intent of the RFC.