Skip to content

Commit

Permalink
rustc_resolve: use continue instead of return to "exit" a loop it…
Browse files Browse the repository at this point in the history
…eration.
  • Loading branch information
eddyb committed Sep 15, 2018
1 parent 38c82a2 commit 653cd47
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/librustc_resolve/resolve_imports.rs
Expand Up @@ -746,7 +746,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
// Currently imports can't resolve in non-module scopes,
// we only have canaries in them for future-proofing.
if external_crate.is_none() && results.module_scope.is_none() {
return;
continue;
}

{
Expand All @@ -761,7 +761,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
let possible_resultions =
1 + all_results.filter(|&def| def != first).count();
if possible_resultions <= 1 {
return;
continue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/run-pass/uniform-paths/basic.rs
Expand Up @@ -37,7 +37,7 @@ fn main() {
{
// Test that having `std_io` in a module scope and a non-module
// scope is allowed, when both resolve to the same definition.
use std::io as std_io;
use ::std::io as std_io;
use std_io::stdout;
stdout();
}
Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs
@@ -0,0 +1,27 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// edition:2018

// Dummy import to introduce `uniform_paths` canaries.
use std;

// fn version() -> &'static str {""}

mod foo {
// Error wasn't reported, despite `version` being commented out above.
use crate::version; //~ ERROR unresolved import `crate::version`

fn bar() {
version();
}
}

fn main() {}
@@ -0,0 +1,9 @@
error[E0432]: unresolved import `crate::version`
--> $DIR/issue-54253.rs:20:9
|
LL | use crate::version; //~ ERROR unresolved import `crate::version`
| ^^^^^^^^^^^^^^ no `version` in the root

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
29 changes: 29 additions & 0 deletions src/test/ui/rust-2018/uniform-paths/issue-54253.rs
@@ -0,0 +1,29 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// edition:2018

#![feature(uniform_paths)]

// Dummy import to introduce `uniform_paths` canaries.
use std;

// fn version() -> &'static str {""}

mod foo {
// Error wasn't reported, despite `version` being commented out above.
use crate::version; //~ ERROR unresolved import `crate::version`

fn bar() {
version();
}
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/rust-2018/uniform-paths/issue-54253.stderr
@@ -0,0 +1,9 @@
error[E0432]: unresolved import `crate::version`
--> $DIR/issue-54253.rs:22:9
|
LL | use crate::version; //~ ERROR unresolved import `crate::version`
| ^^^^^^^^^^^^^^ no `version` in the root

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.

0 comments on commit 653cd47

Please sign in to comment.