Skip to content

Commit 05a818b

Browse files
committed
---
yaml --- r: 172886 b: refs/heads/try c: 9574724 h: refs/heads/master v: v3
1 parent 97f2586 commit 05a818b

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 170c4399e614fe599c3d41306b3429ca8b3b68c6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: 4bec1841e801e7602a67d16c77879e502c0166d2
5+
refs/heads/try: 957472483d3a2f43c0e4f7c2056280a1022af93c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/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/try/src/librustc_resolve/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,6 +3503,26 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35033503
}
35043504
}
35053505

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

branches/try/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/try/src/test/run-pass/blind-item-local-shadow.rs renamed to branches/try/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)