Skip to content

Commit 7f4131e

Browse files
committed
---
yaml --- r: 182572 b: refs/heads/beta c: 2d17a33 h: refs/heads/master v: v3
1 parent 214d95c commit 7f4131e

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 5e07f5a792329674f6849c1da688e36499983532
34+
refs/heads/beta: 2d17a33878f1af0aa500a4e1ff6aa5c8689ab249
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: eb836bf767aa1d8d4cba488a9091cde3c0ab4b2f

branches/beta/src/librustc/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ register_diagnostics! {
5252
E0140,
5353
E0152,
5454
E0153,
55+
E0154,
5556
E0157,
5657
E0158,
5758
E0161,

branches/beta/src/librustc_resolve/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,6 +3509,26 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35093509
}
35103510
}
35113511

3512+
// Check for imports appearing after non-item statements.
3513+
let mut found_non_item = false;
3514+
for statement in block.stmts.iter() {
3515+
if let ast::StmtDecl(ref declaration, _) = statement.node {
3516+
if let ast::DeclItem(ref i) = declaration.node {
3517+
match i.node {
3518+
ItemExternCrate(_) | ItemUse(_) if found_non_item => {
3519+
span_err!(self.session, i.span, E0154,
3520+
"imports are not allowed after non-item statements");
3521+
}
3522+
_ => {}
3523+
}
3524+
} else {
3525+
found_non_item = true
3526+
}
3527+
} else {
3528+
found_non_item = true;
3529+
}
3530+
}
3531+
35123532
// Descend into the block.
35133533
visit::walk_block(self, block);
35143534

branches/beta/src/test/compile-fail/blind-item-block-middle.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ fn main() {
1414
let bar = 5;
1515
//~^ ERROR declaration of `bar` shadows an enum variant or unit-like struct in scope
1616
use foo::bar;
17+
//~^ ERROR imports are not allowed after non-item statements
1718
}

branches/beta/src/test/run-pass/blind-item-local-shadow.rs renamed to branches/beta/src/test/compile-fail/blind-item-local-shadow.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
mod bar {
12-
pub fn foo() -> uint { 42 }
12+
pub fn foo() -> bool { true }
1313
}
1414

1515
fn main() {
16-
let foo = |&:| 5u;
16+
let foo = |&:| false;
1717
use bar::foo;
18-
assert_eq!(foo(), 5u);
18+
//~^ ERROR imports are not allowed after non-item statements
19+
assert_eq!(foo(), false);
1920
}

0 commit comments

Comments
 (0)