rust/compiler
Matthias Krüger 81f3ae8997
Rollup merge of #90628 - ken-matsui:clarify-error-messages-caused-by-reexporting-pub-crate-visibility-to-outside, r=oli-obk
Clarify error messages caused by re-exporting `pub(crate)` visibility to outside

This PR clarifies error messages and suggestions caused by re-exporting pub(crate) visibility outside the crate.

Here is a small example ([Rust Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e2cd0bd4422d4f20e6522dcbad167d3b)):

```rust
mod m {
    pub(crate) enum E {}
}
pub use m::E;

fn main() {}
```

This code is compiled to:

```
error[E0365]: `E` is private, and cannot be re-exported
 --> prog.rs:4:9
  |
4 | pub use m::E;
  |         ^^^^ re-export of private `E`
  |
  = note: consider declaring type or module `E` with `pub`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0365`.
```

However, enum `E` is actually public to the crate, not private totally—nevertheless, rustc treats `pub(crate)` and private visibility as the same on the error messages. They are not clear and should be segmented distinctly.

By applying changes in this PR, the error message below will be the following message that would be clearer:

```
error[E0365]: `E` is only public to inside of the crate, and cannot be re-exported outside
 --> prog.rs:4:9
  |
4 | pub use m::E;
  |         ^^^^ re-export of crate public `E`
  |
  = note: consider declaring type or module `E` with `pub`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0365`.
```
2021-11-20 10:21:13 +01:00
..
rustc Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_apfloat Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_arena Add some comments. 2021-11-19 07:52:59 +11:00
rustc_ast Auto merge of #89316 - asquared31415:multiple-clobber-abi, r=Amanieu 2021-11-12 16:29:25 +00:00
rustc_ast_lowering Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obk 2021-11-19 13:06:38 +09:00
rustc_ast_passes rustc_feature: Convert BuiltinAttribute from tuple to a struct 2021-11-12 20:15:14 +08:00
rustc_ast_pretty Add support for specifying multiple clobber_abi in asm! 2021-11-10 01:06:03 -05:00
rustc_attr Correct typo 2021-10-16 13:36:05 -07:00
rustc_borrowck Rollup merge of #90801 - b-naber:missing_normalization_equate_inputs_output, r=jackh726 2021-11-16 15:59:39 +09:00
rustc_builtin_macros Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_codegen_cranelift Make hash_result an Option. 2021-10-20 18:29:18 +02:00
rustc_codegen_gcc Remove workaround for the forward progress handling in LLVM 2021-11-14 16:35:09 +01:00
rustc_codegen_llvm Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett 2021-11-18 17:19:27 +00:00
rustc_codegen_ssa Rollup merge of #90900 - andjo403:removeLlvm12Check, r=nikic 2021-11-17 15:58:05 +01:00
rustc_const_eval Auto merge of #90535 - tmiasko:clone-from, r=oli-obk 2021-11-20 04:12:03 +00:00
rustc_data_structures Add #[inline]s to SortedIndexMultiMap 2021-11-11 08:35:59 +09:00
rustc_driver Don't proceed to codegen if there are lint errors 2021-11-08 01:22:28 +00:00
rustc_error_codes Update Copy/Clone documentation WRT arrays 2021-11-08 13:11:59 -05:00
rustc_errors Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_expand Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_feature rustc: Remove #[rustc_synthetic] 2021-11-18 14:32:29 +08:00
rustc_fs_util Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_graphviz Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_hir Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obk 2021-11-19 13:06:38 +09:00
rustc_hir_pretty Auto merge of #89124 - cjgillot:owner-info, r=michaelwoerister 2021-10-18 19:53:05 +00:00
rustc_incremental Add -Zassert-incr-state to assert state of incremental cache 2021-11-12 13:41:46 -06:00
rustc_index Generate documentation in rustc rustc_index::newtype_index macro 2021-11-13 18:50:29 -06:00
rustc_infer Rollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebank 2021-11-17 15:58:04 +01:00
rustc_interface Auto merge of #90329 - nbdd0121:typeck, r=nagisa 2021-11-19 03:00:46 +00:00
rustc_lexer use matches!() macro in more places 2021-11-06 16:13:14 +01:00
rustc_lint Stabilize format_args_capture 2021-11-15 10:14:29 +01:00
rustc_lint_defs Properly register text_direction_codepoint_in_comment lint. 2021-11-05 20:12:40 +01:00
rustc_llvm PassWrapper: additional sanitizer update to match clang 2021-11-11 09:05:21 -05:00
rustc_macros more clippy fixes 2021-11-07 16:59:05 +01:00
rustc_metadata Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00
rustc_middle Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obk 2021-11-20 01:09:41 +01:00
rustc_mir_build Rollup merge of #90925 - krasimirgg:rustc_mir_build_fix, r=petrochenkov 2021-11-16 15:59:42 +09:00
rustc_mir_dataflow Use associated_item_def_ids more 2021-11-11 23:15:57 +00:00
rustc_mir_transform impl Copy/Clone for arrays in std, not in compiler 2021-11-08 13:11:58 -05:00
rustc_monomorphize Rollup merge of #90701 - michaelwoerister:more-artifact-sizes, r=davidtwco 2021-11-09 19:00:45 +01:00
rustc_parse Inline printable function 2021-11-16 08:06:31 +00:00
rustc_parse_format Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_passes Rollup merge of #89610 - guswynn:must_use_future, r=wesleywiser 2021-11-17 15:57:56 +01:00
rustc_plugin_impl Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
rustc_privacy Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00
rustc_query_impl Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
rustc_query_system Auto merge of #90361 - Mark-Simulacrum:always-verify, r=michaelwoerister 2021-11-08 13:38:08 +00:00
rustc_resolve Rollup merge of #90628 - ken-matsui:clarify-error-messages-caused-by-reexporting-pub-crate-visibility-to-outside, r=oli-obk 2021-11-20 10:21:13 +01:00
rustc_save_analysis Give inline const separate DefKind 2021-11-07 03:59:06 +00:00
rustc_serialize Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov" 2021-10-15 11:28:23 +02:00
rustc_session Auto merge of #90329 - nbdd0121:typeck, r=nagisa 2021-11-19 03:00:46 +00:00
rustc_span Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebank 2021-11-20 10:21:12 +01:00
rustc_symbol_mangling Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
rustc_target Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett 2021-11-18 17:19:27 +00:00
rustc_trait_selection rustc: Remove #[rustc_synthetic] 2021-11-18 14:32:29 +08:00
rustc_traits Make select_* methods return Vec for TraitEngine 2021-11-08 23:35:23 +08:00
rustc_ty_utils Recurse through query system when checking ADT drop types, hopefully improving perf 2021-11-13 14:47:17 -05:00
rustc_type_ir Add two inline annotations for hot functions 2021-10-03 12:43:43 -04:00
rustc_typeck Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebank 2021-11-20 10:21:12 +01:00