]> git.lizzy.rs Git - rust.git/commitdiff
rustc_resolve: use `continue` instead of `return` to "exit" a loop iteration.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Sat, 15 Sep 2018 14:52:59 +0000 (17:52 +0300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Sat, 15 Sep 2018 19:48:10 +0000 (22:48 +0300)
src/librustc_resolve/resolve_imports.rs
src/test/ui/run-pass/uniform-paths/basic.rs
src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs [new file with mode: 0644]
src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr [new file with mode: 0644]
src/test/ui/rust-2018/uniform-paths/issue-54253.rs [new file with mode: 0644]
src/test/ui/rust-2018/uniform-paths/issue-54253.stderr [new file with mode: 0644]

index c86d430faceabb10337264a77d8beb9bccb5ddcd..dc4a76db6926654ad3af964ed30f5eec4befeba5 100644 (file)
@@ -746,7 +746,7 @@ struct UniformPathsCanaryResults<'a> {
             // 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;
             }
 
             {
@@ -761,7 +761,7 @@ struct UniformPathsCanaryResults<'a> {
                 let possible_resultions =
                     1 + all_results.filter(|&def| def != first).count();
                 if possible_resultions <= 1 {
-                    return;
+                    continue;
                 }
             }
 
index fbdac98d2582e9f3e87860e0c59617356c95ea49..7d997fe493a7bc01b53ccf4c4f2d48e0d6e9a974 100644 (file)
@@ -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();
     }
diff --git a/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs b/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs
new file mode 100644 (file)
index 0000000..1f19a05
--- /dev/null
@@ -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() {}
diff --git a/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr b/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr
new file mode 100644 (file)
index 0000000..6dcc451
--- /dev/null
@@ -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`.
diff --git a/src/test/ui/rust-2018/uniform-paths/issue-54253.rs b/src/test/ui/rust-2018/uniform-paths/issue-54253.rs
new file mode 100644 (file)
index 0000000..7ca5c9e
--- /dev/null
@@ -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() {}
diff --git a/src/test/ui/rust-2018/uniform-paths/issue-54253.stderr b/src/test/ui/rust-2018/uniform-paths/issue-54253.stderr
new file mode 100644 (file)
index 0000000..0016e21
--- /dev/null
@@ -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`.