Skip to content

Commit 653cd47

Browse files
committed
rustc_resolve: use continue instead of return to "exit" a loop iteration.
1 parent 38c82a2 commit 653cd47

File tree

6 files changed

+77
-3
lines changed

6 files changed

+77
-3
lines changed

src/librustc_resolve/resolve_imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
746746
// Currently imports can't resolve in non-module scopes,
747747
// we only have canaries in them for future-proofing.
748748
if external_crate.is_none() && results.module_scope.is_none() {
749-
return;
749+
continue;
750750
}
751751

752752
{
@@ -761,7 +761,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
761761
let possible_resultions =
762762
1 + all_results.filter(|&def| def != first).count();
763763
if possible_resultions <= 1 {
764-
return;
764+
continue;
765765
}
766766
}
767767

src/test/ui/run-pass/uniform-paths/basic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
{
3838
// Test that having `std_io` in a module scope and a non-module
3939
// scope is allowed, when both resolve to the same definition.
40-
use std::io as std_io;
40+
use ::std::io as std_io;
4141
use std_io::stdout;
4242
stdout();
4343
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// edition:2018
12+
13+
// Dummy import to introduce `uniform_paths` canaries.
14+
use std;
15+
16+
// fn version() -> &'static str {""}
17+
18+
mod foo {
19+
// Error wasn't reported, despite `version` being commented out above.
20+
use crate::version; //~ ERROR unresolved import `crate::version`
21+
22+
fn bar() {
23+
version();
24+
}
25+
}
26+
27+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0432]: unresolved import `crate::version`
2+
--> $DIR/issue-54253.rs:20:9
3+
|
4+
LL | use crate::version; //~ ERROR unresolved import `crate::version`
5+
| ^^^^^^^^^^^^^^ no `version` in the root
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0432`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// edition:2018
12+
13+
#![feature(uniform_paths)]
14+
15+
// Dummy import to introduce `uniform_paths` canaries.
16+
use std;
17+
18+
// fn version() -> &'static str {""}
19+
20+
mod foo {
21+
// Error wasn't reported, despite `version` being commented out above.
22+
use crate::version; //~ ERROR unresolved import `crate::version`
23+
24+
fn bar() {
25+
version();
26+
}
27+
}
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0432]: unresolved import `crate::version`
2+
--> $DIR/issue-54253.rs:22:9
3+
|
4+
LL | use crate::version; //~ ERROR unresolved import `crate::version`
5+
| ^^^^^^^^^^^^^^ no `version` in the root
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)