resolve: Say "import" when reporting private imports
This commit is contained in:
parent
28c3f6eb40
commit
c84efe9b6c
12 changed files with 39 additions and 36 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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`,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue