about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0577.md2
-rw-r--r--compiler/rustc_resolve/src/build_reduced_graph.rs2
-rw-r--r--tests/ui/resolve/unresolved-segments-visibility.rs11
-rw-r--r--tests/ui/resolve/unresolved-segments-visibility.stderr9
-rw-r--r--tests/ui/span/visibility-ty-params.rs2
-rw-r--r--tests/ui/span/visibility-ty-params.stderr6
-rw-r--r--tests/ui/use/use-self-type.stderr4
7 files changed, 28 insertions, 8 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0577.md b/compiler/rustc_error_codes/src/error_codes/E0577.md
index eba2d3b1417..383ca61f6c4 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0577.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0577.md
@@ -3,7 +3,7 @@ Something other than a module was found in visibility scope.
 Erroneous code example:
 
 ```compile_fail,E0577,edition2018
-pub struct Sea;
+pub enum Sea {}
 
 pub (in crate::Sea) struct Shark; // error!
 
diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs
index 2f432799022..80d6a47ff53 100644
--- a/compiler/rustc_resolve/src/build_reduced_graph.rs
+++ b/compiler/rustc_resolve/src/build_reduced_graph.rs
@@ -278,7 +278,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
                 };
                 match self.r.resolve_path(
                     &segments,
-                    Some(TypeNS),
+                    None,
                     parent_scope,
                     finalize.then(|| Finalize::new(id, path.span)),
                     None,
diff --git a/tests/ui/resolve/unresolved-segments-visibility.rs b/tests/ui/resolve/unresolved-segments-visibility.rs
new file mode 100644
index 00000000000..c26171f75d2
--- /dev/null
+++ b/tests/ui/resolve/unresolved-segments-visibility.rs
@@ -0,0 +1,11 @@
+// Check that we do not ICE due to unresolved segments in visibility path.
+#![crate_type = "lib"]
+
+extern crate alloc as b;
+
+mod foo {
+    mod bar {
+        pub(in b::string::String::newy) extern crate alloc as e;
+        //~^ ERROR failed to resolve: `String` is a struct, not a module [E0433]
+    }
+}
diff --git a/tests/ui/resolve/unresolved-segments-visibility.stderr b/tests/ui/resolve/unresolved-segments-visibility.stderr
new file mode 100644
index 00000000000..0a11549cdbf
--- /dev/null
+++ b/tests/ui/resolve/unresolved-segments-visibility.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: `String` is a struct, not a module
+  --> $DIR/unresolved-segments-visibility.rs:8:27
+   |
+LL |         pub(in b::string::String::newy) extern crate alloc as e;
+   |                           ^^^^^^ `String` is a struct, not a module
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/span/visibility-ty-params.rs b/tests/ui/span/visibility-ty-params.rs
index d77febe0aa2..11c2cf44cb4 100644
--- a/tests/ui/span/visibility-ty-params.rs
+++ b/tests/ui/span/visibility-ty-params.rs
@@ -4,7 +4,7 @@ macro_rules! m {
 
 struct S<T>(T);
 m!{ S<u8> } //~ ERROR unexpected generic arguments in path
-            //~| ERROR expected module, found struct `S`
+            //~| ERROR failed to resolve: `S` is a struct, not a module [E0433]
 
 mod m {
     m!{ m<> } //~ ERROR unexpected generic arguments in path
diff --git a/tests/ui/span/visibility-ty-params.stderr b/tests/ui/span/visibility-ty-params.stderr
index 067893fd22d..97d05c4644e 100644
--- a/tests/ui/span/visibility-ty-params.stderr
+++ b/tests/ui/span/visibility-ty-params.stderr
@@ -4,11 +4,11 @@ error: unexpected generic arguments in path
 LL | m!{ S<u8> }
    |      ^^^^
 
-error[E0577]: expected module, found struct `S`
+error[E0433]: failed to resolve: `S` is a struct, not a module
   --> $DIR/visibility-ty-params.rs:6:5
    |
 LL | m!{ S<u8> }
-   |     ^^^^^ not a module
+   |     ^ `S` is a struct, not a module
 
 error: unexpected generic arguments in path
   --> $DIR/visibility-ty-params.rs:10:10
@@ -18,4 +18,4 @@ LL |     m!{ m<> }
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0577`.
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/use/use-self-type.stderr b/tests/ui/use/use-self-type.stderr
index 3da04a851f6..498df34fe32 100644
--- a/tests/ui/use/use-self-type.stderr
+++ b/tests/ui/use/use-self-type.stderr
@@ -1,8 +1,8 @@
-error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
+error[E0433]: failed to resolve: `Self` cannot be used in imports
   --> $DIR/use-self-type.rs:7:16
    |
 LL |         pub(in Self::f) struct Z;
-   |                ^^^^ `Self` is only available in impls, traits, and type definitions
+   |                ^^^^ `Self` cannot be used in imports
 
 error[E0432]: unresolved import `Self`
   --> $DIR/use-self-type.rs:6:13