rust/compiler/rustc_trait_selection/src/traits
bors 04075b3202 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:🅱️:Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a:🅱️: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:🅱️: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:🅱️: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 {
   |     ^^^^^
```
2023-06-22 18:23:19 +00:00
..
error_reporting Account for sealed traits in trait bound errors 2023-06-22 16:50:21 +00:00
query Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr 2023-06-21 07:37:01 +02:00
select Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr 2023-06-21 07:37:01 +02:00
specialize s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
auto_trait.rs s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
chalk_fulfill.rs Report overflows gracefully with new solver 2023-04-10 16:36:30 +00:00
coherence.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
const_evaluatable.rs s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
engine.rs Make TraitEngine::new use the right solver, add compare mode 2023-06-06 18:43:20 +00:00
fulfill.rs s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
misc.rs Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too 2023-06-01 18:21:42 +00:00
mod.rs Don't substitute a GAT that has mismatched generics in OpaqueTypeCollector 2023-06-21 16:33:17 +00:00
object_safety.rs s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
outlives_bounds.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
project.rs Don't substitute a GAT that has mismatched generics in OpaqueTypeCollector 2023-06-21 16:33:17 +00:00
structural_match.rs remove search_for_adt_const_param_violation 2023-06-01 18:03:59 +00:00
structural_normalize.rs New trait solver is a property of inference context 2023-06-06 18:43:06 +00:00
util.rs Don't substitute a GAT that has mismatched generics in OpaqueTypeCollector 2023-06-21 16:33:17 +00:00
vtable.rs Collect VTable stats & add -Zprint-vtable-sizes 2023-06-12 15:58:35 +00:00
wf.rs s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00