rust/src
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
..
bootstrap Rollup merge of #90800 - aplanas:fix_cargo_config, r=Mark-Simulacrum 2021-11-19 13:06:35 +09:00
build_helper
ci Rollup merge of #90733 - wesleywiser:musl_debuginfo, r=Mark-Simulacrum 2021-11-16 23:58:21 +01:00
doc Put back removed empty line 2021-11-19 10:20:49 +01:00
etc
librustdoc Rollup merge of #91054 - camelid:fix-tags, r=GuillaumeGomez 2021-11-20 01:09:45 +01:00
llvm-project@f9b03d0e2d Update llvm submodule 2021-11-16 16:49:16 +00:00
rustdoc-json-types
test 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
tools Rollup merge of #90947 - c410-f3r:testsssssss, r=petrochenkov 2021-11-19 13:06:36 +09:00
README.md
stage0.json bump boostrap compiler 2021-10-23 21:55:57 -04:00
version

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.