Skip to content

Commit f05bc16

Browse files
committed
Resolve: stop requiring that use declarations precede statements in blocks
1 parent 54475e9 commit f05bc16

File tree

3 files changed

+0
-25
lines changed

3 files changed

+0
-25
lines changed

src/librustc_resolve/lib.rs

-23
Original file line numberDiff line numberDiff line change
@@ -2508,29 +2508,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
25082508
}
25092509
}
25102510

2511-
// Check for imports appearing after non-item statements.
2512-
let mut found_non_item = false;
2513-
for statement in &block.stmts {
2514-
if let hir::StmtDecl(ref declaration, _) = statement.node {
2515-
if let hir::DeclItem(i) = declaration.node {
2516-
let i = self.ast_map.expect_item(i.id);
2517-
match i.node {
2518-
ItemExternCrate(_) | ItemUse(_) if found_non_item => {
2519-
span_err!(self.session,
2520-
i.span,
2521-
E0154,
2522-
"imports are not allowed after non-item statements");
2523-
}
2524-
_ => {}
2525-
}
2526-
} else {
2527-
found_non_item = true
2528-
}
2529-
} else {
2530-
found_non_item = true;
2531-
}
2532-
}
2533-
25342511
// Descend into the block.
25352512
intravisit::walk_block(self, block);
25362513

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

-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ 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
1817
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ mod bar {
1515
fn main() {
1616
let foo = || false;
1717
use bar::foo;
18-
//~^ ERROR imports are not allowed after non-item statements
1918
assert_eq!(foo(), false);
2019
}

0 commit comments

Comments
 (0)