Skip to content

Commit a68334a

Browse files
committed
resolve: Say "import" when reporting private imports
1 parent 4d596e8 commit a68334a

12 files changed

+39
-36
lines changed

src/librustc_resolve/diagnostics.rs

+3
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,9 @@ impl<'a> Resolver<'a> {
921921
if is_constructor {
922922
descr += " constructor";
923923
}
924+
if binding.is_import() {
925+
descr += " import";
926+
}
924927

925928
let mut err =
926929
struct_span_err!(session, ident.span, E0603, "{} `{}` is private", descr, ident);

src/test/ui/extern/extern-crate-visibility.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ mod foo {
33
}
44

55
// Check that private crates can be used from outside their modules, albeit with warnings
6-
use foo::core::cell; //~ ERROR crate `core` is private
6+
use foo::core::cell; //~ ERROR crate import `core` is private
77

88
fn f() {
9-
foo::core::cell::Cell::new(0); //~ ERROR crate `core` is private
9+
foo::core::cell::Cell::new(0); //~ ERROR crate import `core` is private
1010

1111
use foo::*;
1212
mod core {} // Check that private crates are not glob imported

src/test/ui/extern/extern-crate-visibility.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
error[E0603]: crate `core` is private
1+
error[E0603]: crate import `core` is private
22
--> $DIR/extern-crate-visibility.rs:6:10
33
|
44
LL | use foo::core::cell;
5-
| ^^^^ this crate is private
5+
| ^^^^ this crate import is private
66
|
7-
note: the crate `core` is defined here
7+
note: the crate import `core` is defined here
88
--> $DIR/extern-crate-visibility.rs:2:5
99
|
1010
LL | extern crate core;
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
error[E0603]: crate `core` is private
13+
error[E0603]: crate import `core` is private
1414
--> $DIR/extern-crate-visibility.rs:9:10
1515
|
1616
LL | foo::core::cell::Cell::new(0);
17-
| ^^^^ this crate is private
17+
| ^^^^ this crate import is private
1818
|
19-
note: the crate `core` is defined here
19+
note: the crate import `core` is defined here
2020
--> $DIR/extern-crate-visibility.rs:2:5
2121
|
2222
LL | extern crate core;

src/test/ui/import.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ error[E0432]: unresolved import `foo`
1313
LL | use foo;
1414
| ^^^ no `foo` in the root
1515

16-
error[E0603]: unresolved item `foo` is private
16+
error[E0603]: unresolved item import `foo` is private
1717
--> $DIR/import.rs:15:10
1818
|
1919
LL | zed::foo();
20-
| ^^^ this unresolved item is private
20+
| ^^^ this unresolved item import is private
2121
|
22-
note: the unresolved item `foo` is defined here
22+
note: the unresolved item import `foo` is defined here
2323
--> $DIR/import.rs:10:9
2424
|
2525
LL | use foo;

src/test/ui/imports/issue-55884-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ mod parser {
99
use ParseOptions;
1010
}
1111

12-
pub use parser::ParseOptions; //~ ERROR struct `ParseOptions` is private
12+
pub use parser::ParseOptions; //~ ERROR struct import `ParseOptions` is private
1313

1414
fn main() {}

src/test/ui/imports/issue-55884-2.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0603]: struct `ParseOptions` is private
1+
error[E0603]: struct import `ParseOptions` is private
22
--> $DIR/issue-55884-2.rs:12:17
33
|
44
LL | pub use parser::ParseOptions;
5-
| ^^^^^^^^^^^^ this struct is private
5+
| ^^^^^^^^^^^^ this struct import is private
66
|
7-
note: the struct `ParseOptions` is defined here
7+
note: the struct import `ParseOptions` is defined here
88
--> $DIR/issue-55884-2.rs:9:9
99
|
1010
LL | use ParseOptions;

src/test/ui/imports/reexports.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ note: consider marking `foo` as `pub` in the imported module
1010
LL | pub use super::foo;
1111
| ^^^^^^^^^^
1212

13-
error[E0603]: module `foo` is private
13+
error[E0603]: module import `foo` is private
1414
--> $DIR/reexports.rs:33:15
1515
|
1616
LL | use b::a::foo::S;
17-
| ^^^ this module is private
17+
| ^^^ this module import is private
1818
|
19-
note: the module `foo` is defined here
19+
note: the module import `foo` is defined here
2020
--> $DIR/reexports.rs:21:17
2121
|
2222
LL | pub use super::foo; // This is OK since the value `foo` is visible enough.
2323
| ^^^^^^^^^^
2424

25-
error[E0603]: module `foo` is private
25+
error[E0603]: module import `foo` is private
2626
--> $DIR/reexports.rs:34:15
2727
|
2828
LL | use b::b::foo::S as T;
29-
| ^^^ this module is private
29+
| ^^^ this module import is private
3030
|
31-
note: the module `foo` is defined here
31+
note: the module import `foo` is defined here
3232
--> $DIR/reexports.rs:26:17
3333
|
3434
LL | pub use super::*; // This is also OK since the value `foo` is visible enough.

src/test/ui/privacy/privacy2.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ error[E0432]: unresolved import `bar::foo`
44
LL | use bar::foo;
55
| ^^^^^^^^ no `foo` in `bar`
66

7-
error[E0603]: function `foo` is private
7+
error[E0603]: function import `foo` is private
88
--> $DIR/privacy2.rs:23:20
99
|
1010
LL | use bar::glob::foo;
11-
| ^^^ this function is private
11+
| ^^^ this function import is private
1212
|
13-
note: the function `foo` is defined here
13+
note: the function import `foo` is defined here
1414
--> $DIR/privacy2.rs:10:13
1515
|
1616
LL | use foo;

src/test/ui/proc-macro/disappearing-resolution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate test_macros;
88
mod m {
99
use test_macros::Empty;
1010
}
11-
use m::Empty; //~ ERROR derive macro `Empty` is private
11+
use m::Empty; //~ ERROR derive macro import `Empty` is private
1212

1313
// To resolve `empty_helper` we need to resolve `Empty`.
1414
// During initial resolution `use m::Empty` introduces no entries, so we proceed to `macro_use`,

src/test/ui/proc-macro/disappearing-resolution.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ error: cannot find attribute `empty_helper` in this scope
44
LL | #[empty_helper]
55
| ^^^^^^^^^^^^
66

7-
error[E0603]: derive macro `Empty` is private
7+
error[E0603]: derive macro import `Empty` is private
88
--> $DIR/disappearing-resolution.rs:11:8
99
|
1010
LL | use m::Empty;
11-
| ^^^^^ this derive macro is private
11+
| ^^^^^ this derive macro import is private
1212
|
13-
note: the derive macro `Empty` is defined here
13+
note: the derive macro import `Empty` is defined here
1414
--> $DIR/disappearing-resolution.rs:9:9
1515
|
1616
LL | use test_macros::Empty;

src/test/ui/shadowed/shadowed-use-visibility.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ mod foo {
66
}
77

88
mod bar {
9-
use foo::bar::f as g; //~ ERROR module `bar` is private
9+
use foo::bar::f as g; //~ ERROR module import `bar` is private
1010

1111
use foo as f;
1212
pub use foo::*;
1313
}
1414

15-
use bar::f::f; //~ ERROR module `f` is private
15+
use bar::f::f; //~ ERROR module import `f` is private
1616
fn main() {}

src/test/ui/shadowed/shadowed-use-visibility.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
error[E0603]: module `bar` is private
1+
error[E0603]: module import `bar` is private
22
--> $DIR/shadowed-use-visibility.rs:9:14
33
|
44
LL | use foo::bar::f as g;
5-
| ^^^ this module is private
5+
| ^^^ this module import is private
66
|
7-
note: the module `bar` is defined here
7+
note: the module import `bar` is defined here
88
--> $DIR/shadowed-use-visibility.rs:4:9
99
|
1010
LL | use foo as bar;
1111
| ^^^^^^^^^^
1212

13-
error[E0603]: module `f` is private
13+
error[E0603]: module import `f` is private
1414
--> $DIR/shadowed-use-visibility.rs:15:10
1515
|
1616
LL | use bar::f::f;
17-
| ^ this module is private
17+
| ^ this module import is private
1818
|
19-
note: the module `f` is defined here
19+
note: the module import `f` is defined here
2020
--> $DIR/shadowed-use-visibility.rs:11:9
2121
|
2222
LL | use foo as f;

0 commit comments

Comments
 (0)