diff options
| author | bors <bors@rust-lang.org> | 2023-06-22 18:23:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-22 18:23:19 +0000 |
| commit | 04075b32021932e3e8f6ab55d519b3b3494b6ef9 (patch) | |
| tree | 8ab8fad9c6ca4c70974c2d08a1337b906fa6b0ea /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 2efe09170530fa18e42ff05b8d9dd23f00b5c430 (diff) | |
| parent | 7dffd24da5292cc01f18c4ab53f0b96f682fcbe3 (diff) | |
| download | rust-04075b32021932e3e8f6ab55d519b3b3494b6ef9.tar.gz rust-04075b32021932e3e8f6ab55d519b3b3494b6ef9.zip | |
Auto merge of #112686 - estebank:sealed-traits, r=petrochenkov
Account for sealed traits in privacy and trait bound errors
On trait bound errors caused by super-traits, identify if the super-trait is publicly accessibly and if not, explain "sealed traits".
```
error[E0277]: the trait bound `S: Hidden` is not satisfied
--> $DIR/sealed-trait-local.rs:17:20
|
LL | impl a::Sealed for S {}
| ^ the trait `Hidden` is not implemented for `S`
|
note: required by a bound in `Sealed`
--> $DIR/sealed-trait-local.rs:3:23
|
LL | pub trait Sealed: self::b::Hidden {
| ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
= note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a::b::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
```
Deduplicate privacy errors that point to the same path segment even if their deduplication span are different.
When encountering a path that is not reachable due to privacy constraints path segments other than the last, keep metadata for the last path segment's `Res` in order to look for alternative import paths for that item to suggest. If there are none, be explicit that the item is not accessible.
```
error[E0603]: module `b` is private
--> $DIR/re-exported-trait.rs:11:9
|
LL | impl a::b::Trait for S {}
| ^ private module
|
note: the module `b` is defined here
--> $DIR/re-exported-trait.rs:5:5
|
LL | mod b {
| ^^^^^
help: consider importing this trait through its public re-export instead
|
LL | impl a::Trait for S {}
| ~~~~~~~~
```
```
error[E0603]: module `b` is private
--> $DIR/private-trait.rs:8:9
|
LL | impl a::b::Hidden for S {}
| ^ ------ trait `b` is not publicly reachable
| |
| private module
|
note: the module `b` is defined here
--> $DIR/private-trait.rs:2:5
|
LL | mod b {
| ^^^^^
```
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
0 files changed, 0 insertions, 0 deletions
