diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-01-12 16:20:57 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-01-16 21:59:11 +0300 |
| commit | c84efe9b6ca05f64d8b925acc2724971d186f8f6 (patch) | |
| tree | 543a087417a5599014360c4b0d85da31ea37daf3 | |
| parent | 28c3f6eb409596be9c0c0a59dc1c26e216d9e57a (diff) | |
| download | rust-c84efe9b6ca05f64d8b925acc2724971d186f8f6.tar.gz rust-c84efe9b6ca05f64d8b925acc2724971d186f8f6.zip | |
resolve: Say "import" when reporting private imports
| -rw-r--r-- | src/librustc_resolve/diagnostics.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/extern/extern-crate-visibility.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/extern/extern-crate-visibility.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/import.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/imports/issue-55884-2.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/imports/issue-55884-2.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/imports/reexports.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/privacy/privacy2.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/disappearing-resolution.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/disappearing-resolution.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/shadowed/shadowed-use-visibility.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/shadowed/shadowed-use-visibility.stderr | 12 |
12 files changed, 39 insertions, 36 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 20c8f78b1cf..a433ae8ed67 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -921,6 +921,9 @@ impl<'a> Resolver<'a> { if is_constructor { descr += " constructor"; } + if binding.is_import() { + descr += " import"; + } let mut err = struct_span_err!(session, ident.span, E0603, "{} `{}` is private", descr, ident); diff --git a/src/test/ui/extern/extern-crate-visibility.rs b/src/test/ui/extern/extern-crate-visibility.rs index e0a5cd5e98f..cda1227cc8e 100644 --- a/src/test/ui/extern/extern-crate-visibility.rs +++ b/src/test/ui/extern/extern-crate-visibility.rs @@ -3,10 +3,10 @@ mod foo { } // Check that private crates can be used from outside their modules, albeit with warnings -use foo::core::cell; //~ ERROR crate `core` is private +use foo::core::cell; //~ ERROR crate import `core` is private fn f() { - foo::core::cell::Cell::new(0); //~ ERROR crate `core` is private + foo::core::cell::Cell::new(0); //~ ERROR crate import `core` is private use foo::*; mod core {} // Check that private crates are not glob imported diff --git a/src/test/ui/extern/extern-crate-visibility.stderr b/src/test/ui/extern/extern-crate-visibility.stderr index 6d38b4d8d66..d0c073d67a4 100644 --- a/src/test/ui/extern/extern-crate-visibility.stderr +++ b/src/test/ui/extern/extern-crate-visibility.stderr @@ -1,22 +1,22 @@ -error[E0603]: crate `core` is private +error[E0603]: crate import `core` is private --> $DIR/extern-crate-visibility.rs:6:10 | LL | use foo::core::cell; - | ^^^^ this crate is private + | ^^^^ this crate import is private | -note: the crate `core` is defined here +note: the crate import `core` is defined here --> $DIR/extern-crate-visibility.rs:2:5 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ -error[E0603]: crate `core` is private +error[E0603]: crate import `core` is private --> $DIR/extern-crate-visibility.rs:9:10 | LL | foo::core::cell::Cell::new(0); - | ^^^^ this crate is private + | ^^^^ this crate import is private | -note: the crate `core` is defined here +note: the crate import `core` is defined here --> $DIR/extern-crate-visibility.rs:2:5 | LL | extern crate core; diff --git a/src/test/ui/import.stderr b/src/test/ui/import.stderr index c66a4fa7151..5219ffacd15 100644 --- a/src/test/ui/import.stderr +++ b/src/test/ui/import.stderr @@ -13,13 +13,13 @@ error[E0432]: unresolved import `foo` LL | use foo; | ^^^ no `foo` in the root -error[E0603]: unresolved item `foo` is private +error[E0603]: unresolved item import `foo` is private --> $DIR/import.rs:15:10 | LL | zed::foo(); - | ^^^ this unresolved item is private + | ^^^ this unresolved item import is private | -note: the unresolved item `foo` is defined here +note: the unresolved item import `foo` is defined here --> $DIR/import.rs:10:9 | LL | use foo; diff --git a/src/test/ui/imports/issue-55884-2.rs b/src/test/ui/imports/issue-55884-2.rs index 1b4f652c9fc..75bb4206f97 100644 --- a/src/test/ui/imports/issue-55884-2.rs +++ b/src/test/ui/imports/issue-55884-2.rs @@ -9,6 +9,6 @@ mod parser { use ParseOptions; } -pub use parser::ParseOptions; //~ ERROR struct `ParseOptions` is private +pub use parser::ParseOptions; //~ ERROR struct import `ParseOptions` is private fn main() {} diff --git a/src/test/ui/imports/issue-55884-2.stderr b/src/test/ui/imports/issue-55884-2.stderr index 9e77283cd59..f16d2adb365 100644 --- a/src/test/ui/imports/issue-55884-2.stderr +++ b/src/test/ui/imports/issue-55884-2.stderr @@ -1,10 +1,10 @@ -error[E0603]: struct `ParseOptions` is private +error[E0603]: struct import `ParseOptions` is private --> $DIR/issue-55884-2.rs:12:17 | LL | pub use parser::ParseOptions; - | ^^^^^^^^^^^^ this struct is private + | ^^^^^^^^^^^^ this struct import is private | -note: the struct `ParseOptions` is defined here +note: the struct import `ParseOptions` is defined here --> $DIR/issue-55884-2.rs:9:9 | LL | use ParseOptions; diff --git a/src/test/ui/imports/reexports.stderr b/src/test/ui/imports/reexports.stderr index 67c12e0c8d3..b173884080f 100644 --- a/src/test/ui/imports/reexports.stderr +++ b/src/test/ui/imports/reexports.stderr @@ -10,25 +10,25 @@ note: consider marking `foo` as `pub` in the imported module LL | pub use super::foo; | ^^^^^^^^^^ -error[E0603]: module `foo` is private +error[E0603]: module import `foo` is private --> $DIR/reexports.rs:33:15 | LL | use b::a::foo::S; - | ^^^ this module is private + | ^^^ this module import is private | -note: the module `foo` is defined here +note: the module import `foo` is defined here --> $DIR/reexports.rs:21:17 | LL | pub use super::foo; // This is OK since the value `foo` is visible enough. | ^^^^^^^^^^ -error[E0603]: module `foo` is private +error[E0603]: module import `foo` is private --> $DIR/reexports.rs:34:15 | LL | use b::b::foo::S as T; - | ^^^ this module is private + | ^^^ this module import is private | -note: the module `foo` is defined here +note: the module import `foo` is defined here --> $DIR/reexports.rs:26:17 | LL | pub use super::*; // This is also OK since the value `foo` is visible enough. diff --git a/src/test/ui/privacy/privacy2.stderr b/src/test/ui/privacy/privacy2.stderr index d9f003ddae7..719dc27ccf4 100644 --- a/src/test/ui/privacy/privacy2.stderr +++ b/src/test/ui/privacy/privacy2.stderr @@ -4,13 +4,13 @@ error[E0432]: unresolved import `bar::foo` LL | use bar::foo; | ^^^^^^^^ no `foo` in `bar` -error[E0603]: function `foo` is private +error[E0603]: function import `foo` is private --> $DIR/privacy2.rs:23:20 | LL | use bar::glob::foo; - | ^^^ this function is private + | ^^^ this function import is private | -note: the function `foo` is defined here +note: the function import `foo` is defined here --> $DIR/privacy2.rs:10:13 | LL | use foo; diff --git a/src/test/ui/proc-macro/disappearing-resolution.rs b/src/test/ui/proc-macro/disappearing-resolution.rs index a01b8f302ca..50f04b1eae1 100644 --- a/src/test/ui/proc-macro/disappearing-resolution.rs +++ b/src/test/ui/proc-macro/disappearing-resolution.rs @@ -8,7 +8,7 @@ extern crate test_macros; mod m { use test_macros::Empty; } -use m::Empty; //~ ERROR derive macro `Empty` is private +use m::Empty; //~ ERROR derive macro import `Empty` is private // To resolve `empty_helper` we need to resolve `Empty`. // During initial resolution `use m::Empty` introduces no entries, so we proceed to `macro_use`, diff --git a/src/test/ui/proc-macro/disappearing-resolution.stderr b/src/test/ui/proc-macro/disappearing-resolution.stderr index d81ab5ebf9b..3beaedf61d7 100644 --- a/src/test/ui/proc-macro/disappearing-resolution.stderr +++ b/src/test/ui/proc-macro/disappearing-resolution.stderr @@ -4,13 +4,13 @@ error: cannot find attribute `empty_helper` in this scope LL | #[empty_helper] | ^^^^^^^^^^^^ -error[E0603]: derive macro `Empty` is private +error[E0603]: derive macro import `Empty` is private --> $DIR/disappearing-resolution.rs:11:8 | LL | use m::Empty; - | ^^^^^ this derive macro is private + | ^^^^^ this derive macro import is private | -note: the derive macro `Empty` is defined here +note: the derive macro import `Empty` is defined here --> $DIR/disappearing-resolution.rs:9:9 | LL | use test_macros::Empty; diff --git a/src/test/ui/shadowed/shadowed-use-visibility.rs b/src/test/ui/shadowed/shadowed-use-visibility.rs index 8185e82ee83..6b801972f41 100644 --- a/src/test/ui/shadowed/shadowed-use-visibility.rs +++ b/src/test/ui/shadowed/shadowed-use-visibility.rs @@ -6,11 +6,11 @@ mod foo { } mod bar { - use foo::bar::f as g; //~ ERROR module `bar` is private + use foo::bar::f as g; //~ ERROR module import `bar` is private use foo as f; pub use foo::*; } -use bar::f::f; //~ ERROR module `f` is private +use bar::f::f; //~ ERROR module import `f` is private fn main() {} diff --git a/src/test/ui/shadowed/shadowed-use-visibility.stderr b/src/test/ui/shadowed/shadowed-use-visibility.stderr index 77bf2abe345..cd8ec13794c 100644 --- a/src/test/ui/shadowed/shadowed-use-visibility.stderr +++ b/src/test/ui/shadowed/shadowed-use-visibility.stderr @@ -1,22 +1,22 @@ -error[E0603]: module `bar` is private +error[E0603]: module import `bar` is private --> $DIR/shadowed-use-visibility.rs:9:14 | LL | use foo::bar::f as g; - | ^^^ this module is private + | ^^^ this module import is private | -note: the module `bar` is defined here +note: the module import `bar` is defined here --> $DIR/shadowed-use-visibility.rs:4:9 | LL | use foo as bar; | ^^^^^^^^^^ -error[E0603]: module `f` is private +error[E0603]: module import `f` is private --> $DIR/shadowed-use-visibility.rs:15:10 | LL | use bar::f::f; - | ^ this module is private + | ^ this module import is private | -note: the module `f` is defined here +note: the module import `f` is defined here --> $DIR/shadowed-use-visibility.rs:11:9 | LL | use foo as f; |
