mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
7dffd24da5
Suggest publicly accessible paths for items in private mod: When encountering a path in non-import situations that are not reachable due to privacy constraints, search for any public re-exports that the user could use instead. Track whether an import suggestion is offering a re-export. When encountering a path with private segments, mention if the item at the final path segment is not publicly accessible at all. Add item visibility metadata to privacy errors from imports: On unreachable imports, record the item that was being imported in order to suggest publicly available re-exports or to be explicit that the item is not available publicly from any path. In order to allow this, we add a mode to `resolve_path` that will not add new privacy errors, nor return early if it encounters one. This way we can get the `Res` corresponding to the final item in the import, which is used in the privacy error machinery.
400 lines
11 KiB
Plaintext
400 lines
11 KiB
Plaintext
error[E0423]: expected value, found enum `n::Z`
|
|
--> $DIR/privacy-enum-ctor.rs:23:9
|
|
|
|
|
LL | n::Z;
|
|
| ^^^^
|
|
|
|
|
note: the enum is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | / pub(in m) enum Z {
|
|
LL | | Fn(u8),
|
|
LL | | Struct {
|
|
LL | | s: u8,
|
|
LL | | },
|
|
LL | | Unit,
|
|
LL | | }
|
|
| |_________^
|
|
help: you might have meant to use the following enum variant
|
|
|
|
|
LL | m::Z::Unit;
|
|
| ~~~~~~~~~~
|
|
help: alternatively, the following enum variant is available
|
|
|
|
|
LL | (m::Z::Fn(/* fields */));
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
error[E0423]: expected value, found enum `Z`
|
|
--> $DIR/privacy-enum-ctor.rs:25:9
|
|
|
|
|
LL | Z;
|
|
| ^
|
|
|
|
|
note: the enum is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | / pub(in m) enum Z {
|
|
LL | | Fn(u8),
|
|
LL | | Struct {
|
|
LL | | s: u8,
|
|
LL | | },
|
|
LL | | Unit,
|
|
LL | | }
|
|
| |_________^
|
|
help: you might have meant to use the following enum variant
|
|
|
|
|
LL | m::Z::Unit;
|
|
| ~~~~~~~~~~
|
|
help: alternatively, the following enum variant is available
|
|
|
|
|
LL | (m::Z::Fn(/* fields */));
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
error[E0423]: expected value, found enum `m::E`
|
|
--> $DIR/privacy-enum-ctor.rs:41:16
|
|
|
|
|
LL | fn f() {
|
|
| ------ similarly named function `f` defined here
|
|
...
|
|
LL | let _: E = m::E;
|
|
| ^^^^
|
|
|
|
|
note: the enum is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:2:5
|
|
|
|
|
LL | / pub enum E {
|
|
LL | | Fn(u8),
|
|
LL | | Struct {
|
|
LL | | s: u8,
|
|
LL | | },
|
|
LL | | Unit,
|
|
LL | | }
|
|
| |_____^
|
|
help: you might have meant to use the following enum variant
|
|
|
|
|
LL | let _: E = E::Unit;
|
|
| ~~~~~~~
|
|
help: alternatively, the following enum variant is available
|
|
|
|
|
LL | let _: E = (E::Fn(/* fields */));
|
|
| ~~~~~~~~~~~~~~~~~~~~~
|
|
help: a function with a similar name exists
|
|
|
|
|
LL | let _: E = m::f;
|
|
| ~
|
|
help: consider importing one of these items instead
|
|
|
|
|
LL + use std::f32::consts::E;
|
|
|
|
|
LL + use std::f64::consts::E;
|
|
|
|
|
help: if you import `E`, refer to it directly
|
|
|
|
|
LL - let _: E = m::E;
|
|
LL + let _: E = E;
|
|
|
|
|
|
|
error[E0423]: expected value, found enum `E`
|
|
--> $DIR/privacy-enum-ctor.rs:49:16
|
|
|
|
|
LL | let _: E = E;
|
|
| ^
|
|
|
|
|
note: the enum is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:2:5
|
|
|
|
|
LL | / pub enum E {
|
|
LL | | Fn(u8),
|
|
LL | | Struct {
|
|
LL | | s: u8,
|
|
LL | | },
|
|
LL | | Unit,
|
|
LL | | }
|
|
| |_____^
|
|
help: you might have meant to use the following enum variant
|
|
|
|
|
LL | let _: E = E::Unit;
|
|
| ~~~~~~~
|
|
help: alternatively, the following enum variant is available
|
|
|
|
|
LL | let _: E = (E::Fn(/* fields */));
|
|
| ~~~~~~~~~~~~~~~~~~~~~
|
|
help: consider importing one of these items instead
|
|
|
|
|
LL + use std::f32::consts::E;
|
|
|
|
|
LL + use std::f64::consts::E;
|
|
|
|
|
|
|
error[E0412]: cannot find type `Z` in this scope
|
|
--> $DIR/privacy-enum-ctor.rs:57:12
|
|
|
|
|
LL | pub enum E {
|
|
| ---------- similarly named enum `E` defined here
|
|
...
|
|
LL | let _: Z = m::n::Z;
|
|
| ^ help: an enum with a similar name exists: `E`
|
|
|
|
|
note: enum `m::Z` exists but is inaccessible
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^ not accessible
|
|
|
|
error[E0423]: expected value, found enum `m::n::Z`
|
|
--> $DIR/privacy-enum-ctor.rs:57:16
|
|
|
|
|
LL | let _: Z = m::n::Z;
|
|
| ^^^^^^^
|
|
|
|
|
note: the enum is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | / pub(in m) enum Z {
|
|
LL | | Fn(u8),
|
|
LL | | Struct {
|
|
LL | | s: u8,
|
|
LL | | },
|
|
LL | | Unit,
|
|
LL | | }
|
|
| |_________^
|
|
help: you might have meant to use the following enum variant
|
|
|
|
|
LL | let _: Z = m::Z::Unit;
|
|
| ~~~~~~~~~~
|
|
help: alternatively, the following enum variant is available
|
|
|
|
|
LL | let _: Z = (m::Z::Fn(/* fields */));
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
error[E0412]: cannot find type `Z` in this scope
|
|
--> $DIR/privacy-enum-ctor.rs:61:12
|
|
|
|
|
LL | pub enum E {
|
|
| ---------- similarly named enum `E` defined here
|
|
...
|
|
LL | let _: Z = m::n::Z::Fn;
|
|
| ^ help: an enum with a similar name exists: `E`
|
|
|
|
|
note: enum `m::Z` exists but is inaccessible
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^ not accessible
|
|
|
|
error[E0412]: cannot find type `Z` in this scope
|
|
--> $DIR/privacy-enum-ctor.rs:64:12
|
|
|
|
|
LL | pub enum E {
|
|
| ---------- similarly named enum `E` defined here
|
|
...
|
|
LL | let _: Z = m::n::Z::Struct;
|
|
| ^ help: an enum with a similar name exists: `E`
|
|
|
|
|
note: enum `m::Z` exists but is inaccessible
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^ not accessible
|
|
|
|
error[E0412]: cannot find type `Z` in this scope
|
|
--> $DIR/privacy-enum-ctor.rs:68:12
|
|
|
|
|
LL | pub enum E {
|
|
| ---------- similarly named enum `E` defined here
|
|
...
|
|
LL | let _: Z = m::n::Z::Unit {};
|
|
| ^ help: an enum with a similar name exists: `E`
|
|
|
|
|
note: enum `m::Z` exists but is inaccessible
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^ not accessible
|
|
|
|
error[E0603]: enum `Z` is private
|
|
--> $DIR/privacy-enum-ctor.rs:57:22
|
|
|
|
|
LL | let _: Z = m::n::Z;
|
|
| ^ private enum
|
|
|
|
|
note: the enum `Z` is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error[E0603]: enum `Z` is private
|
|
--> $DIR/privacy-enum-ctor.rs:61:22
|
|
|
|
|
LL | let _: Z = m::n::Z::Fn;
|
|
| ^ -- tuple variant `Fn` is not publicly re-exported
|
|
| |
|
|
| private enum
|
|
|
|
|
note: the enum `Z` is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error[E0603]: enum `Z` is private
|
|
--> $DIR/privacy-enum-ctor.rs:64:22
|
|
|
|
|
LL | let _: Z = m::n::Z::Struct;
|
|
| ^ private enum
|
|
|
|
|
note: the enum `Z` is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error[E0603]: enum `Z` is private
|
|
--> $DIR/privacy-enum-ctor.rs:68:22
|
|
|
|
|
LL | let _: Z = m::n::Z::Unit {};
|
|
| ^ ---- variant `Unit` is not publicly re-exported
|
|
| |
|
|
| private enum
|
|
|
|
|
note: the enum `Z` is defined here
|
|
--> $DIR/privacy-enum-ctor.rs:11:9
|
|
|
|
|
LL | pub(in m) enum Z {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/privacy-enum-ctor.rs:27:20
|
|
|
|
|
LL | Fn(u8),
|
|
| -- `Fn` defines an enum variant constructor here, which should be called
|
|
...
|
|
LL | let _: Z = Z::Fn;
|
|
| - ^^^^^ expected `Z`, found enum constructor
|
|
| |
|
|
| expected due to this
|
|
|
|
|
= note: expected enum `Z`
|
|
found enum constructor `fn(u8) -> Z {Z::Fn}`
|
|
help: use parentheses to construct this tuple variant
|
|
|
|
|
LL | let _: Z = Z::Fn(/* u8 */);
|
|
| ++++++++++
|
|
|
|
error[E0533]: expected value, found struct variant `Z::Struct`
|
|
--> $DIR/privacy-enum-ctor.rs:29:20
|
|
|
|
|
LL | let _: Z = Z::Struct;
|
|
| ^^^^^^^^^ not a value
|
|
|
|
error[E0618]: expected function, found enum variant `Z::Unit`
|
|
--> $DIR/privacy-enum-ctor.rs:31:17
|
|
|
|
|
LL | Unit,
|
|
| ---- enum variant `Z::Unit` defined here
|
|
...
|
|
LL | let _ = Z::Unit();
|
|
| ^^^^^^^--
|
|
| |
|
|
| call expression requires function
|
|
|
|
|
help: `Z::Unit` is a unit enum variant, and does not take parentheses to be constructed
|
|
|
|
|
LL - let _ = Z::Unit();
|
|
LL + let _ = Z::Unit;
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/privacy-enum-ctor.rs:43:16
|
|
|
|
|
LL | Fn(u8),
|
|
| -- `Fn` defines an enum variant constructor here, which should be called
|
|
...
|
|
LL | let _: E = m::E::Fn;
|
|
| - ^^^^^^^^ expected `E`, found enum constructor
|
|
| |
|
|
| expected due to this
|
|
|
|
|
= note: expected enum `E`
|
|
found enum constructor `fn(u8) -> E {E::Fn}`
|
|
help: use parentheses to construct this tuple variant
|
|
|
|
|
LL | let _: E = m::E::Fn(/* u8 */);
|
|
| ++++++++++
|
|
|
|
error[E0533]: expected value, found struct variant `m::E::Struct`
|
|
--> $DIR/privacy-enum-ctor.rs:45:16
|
|
|
|
|
LL | let _: E = m::E::Struct;
|
|
| ^^^^^^^^^^^^ not a value
|
|
|
|
error[E0618]: expected function, found enum variant `m::E::Unit`
|
|
--> $DIR/privacy-enum-ctor.rs:47:16
|
|
|
|
|
LL | Unit,
|
|
| ---- enum variant `m::E::Unit` defined here
|
|
...
|
|
LL | let _: E = m::E::Unit();
|
|
| ^^^^^^^^^^--
|
|
| |
|
|
| call expression requires function
|
|
|
|
|
help: `m::E::Unit` is a unit enum variant, and does not take parentheses to be constructed
|
|
|
|
|
LL - let _: E = m::E::Unit();
|
|
LL + let _: E = m::E::Unit;
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/privacy-enum-ctor.rs:51:16
|
|
|
|
|
LL | Fn(u8),
|
|
| -- `Fn` defines an enum variant constructor here, which should be called
|
|
...
|
|
LL | let _: E = E::Fn;
|
|
| - ^^^^^ expected `E`, found enum constructor
|
|
| |
|
|
| expected due to this
|
|
|
|
|
= note: expected enum `E`
|
|
found enum constructor `fn(u8) -> E {E::Fn}`
|
|
help: use parentheses to construct this tuple variant
|
|
|
|
|
LL | let _: E = E::Fn(/* u8 */);
|
|
| ++++++++++
|
|
|
|
error[E0533]: expected value, found struct variant `E::Struct`
|
|
--> $DIR/privacy-enum-ctor.rs:53:16
|
|
|
|
|
LL | let _: E = E::Struct;
|
|
| ^^^^^^^^^ not a value
|
|
|
|
error[E0618]: expected function, found enum variant `E::Unit`
|
|
--> $DIR/privacy-enum-ctor.rs:55:16
|
|
|
|
|
LL | Unit,
|
|
| ---- enum variant `E::Unit` defined here
|
|
...
|
|
LL | let _: E = E::Unit();
|
|
| ^^^^^^^--
|
|
| |
|
|
| call expression requires function
|
|
|
|
|
help: `E::Unit` is a unit enum variant, and does not take parentheses to be constructed
|
|
|
|
|
LL - let _: E = E::Unit();
|
|
LL + let _: E = E::Unit;
|
|
|
|
|
|
|
error[E0533]: expected value, found struct variant `m::n::Z::Struct`
|
|
--> $DIR/privacy-enum-ctor.rs:64:16
|
|
|
|
|
LL | let _: Z = m::n::Z::Struct;
|
|
| ^^^^^^^^^^^^^^^ not a value
|
|
|
|
error: aborting due to 23 previous errors
|
|
|
|
Some errors have detailed explanations: E0308, E0412, E0423, E0533, E0603, E0618.
|
|
For more information about an error, try `rustc --explain E0308`.
|