Skip to content

Commit 2faa262

Browse files
committed
Resolve visibility paths as modules not as types.
1 parent 7a5d2d0 commit 2faa262

6 files changed

+27
-7
lines changed

Diff for: compiler/rustc_resolve/src/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
278278
};
279279
match self.r.resolve_path(
280280
&segments,
281-
Some(TypeNS),
281+
None,
282282
parent_scope,
283283
finalize.then(|| Finalize::new(id, path.span)),
284284
None,

Diff for: tests/ui/resolve/unresolved-segments-visibility.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Check that we do not ICE due to unresolved segments in visibility path.
2+
#![crate_type = "lib"]
3+
4+
extern crate alloc as b;
5+
6+
mod foo {
7+
mod bar {
8+
pub(in b::string::String::newy) extern crate alloc as e;
9+
//~^ ERROR failed to resolve: `String` is a struct, not a module [E0433]
10+
}
11+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0433]: failed to resolve: `String` is a struct, not a module
2+
--> $DIR/unresolved-segments-visibility.rs:8:27
3+
|
4+
LL | pub(in b::string::String::newy) extern crate alloc as e;
5+
| ^^^^^^ `String` is a struct, not a module
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0433`.

Diff for: tests/ui/span/visibility-ty-params.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ macro_rules! m {
44

55
struct S<T>(T);
66
m!{ S<u8> } //~ ERROR unexpected generic arguments in path
7-
//~| ERROR expected module, found struct `S`
7+
//~| ERROR failed to resolve: `S` is a struct, not a module [E0433]
88

99
mod m {
1010
m!{ m<> } //~ ERROR unexpected generic arguments in path

Diff for: tests/ui/span/visibility-ty-params.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error: unexpected generic arguments in path
44
LL | m!{ S<u8> }
55
| ^^^^
66

7-
error[E0577]: expected module, found struct `S`
7+
error[E0433]: failed to resolve: `S` is a struct, not a module
88
--> $DIR/visibility-ty-params.rs:6:5
99
|
1010
LL | m!{ S<u8> }
11-
| ^^^^^ not a module
11+
| ^ `S` is a struct, not a module
1212

1313
error: unexpected generic arguments in path
1414
--> $DIR/visibility-ty-params.rs:10:10
@@ -18,4 +18,4 @@ LL | m!{ m<> }
1818

1919
error: aborting due to 3 previous errors
2020

21-
For more information about this error, try `rustc --explain E0577`.
21+
For more information about this error, try `rustc --explain E0433`.

Diff for: tests/ui/use/use-self-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
1+
error[E0433]: failed to resolve: `Self` cannot be used in imports
22
--> $DIR/use-self-type.rs:7:16
33
|
44
LL | pub(in Self::f) struct Z;
5-
| ^^^^ `Self` is only available in impls, traits, and type definitions
5+
| ^^^^ `Self` cannot be used in imports
66

77
error[E0432]: unresolved import `Self`
88
--> $DIR/use-self-type.rs:6:13

0 commit comments

Comments
 (0)