This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ //! To determine all the types that need to be private when looking at `Struct`, we
2
+ //! invoke `predicates_of` to also look at types in `where` bounds.
3
+ //! Unfortunately this also computes the inferred outlives bounds, which means for
4
+ //! every field we check that if it is of type `&'a T` then `T: 'a` and if it is of
5
+ //! struct type, we check that the struct satisfies its lifetime parameters by looking
6
+ //! at its inferred outlives bounds. This means we end up with a `<Foo as Trait>::Assoc: 'a`
7
+ //! in the outlives bounds of `Struct`. While this is trivially provable, privacy
8
+ //! only sees `Foo` and `Trait` and determins that `Foo` is private and then errors.
9
+
10
+ mod baz {
11
+ struct Foo ;
12
+
13
+ pub trait Trait {
14
+ type Assoc ;
15
+ }
16
+
17
+ impl Trait for Foo {
18
+ type Assoc = ( ) ;
19
+ }
20
+
21
+ pub struct Bar < ' a , T : Trait > {
22
+ source : & ' a T :: Assoc ,
23
+ //~^ ERROR: type `Foo` is private
24
+ }
25
+
26
+ pub struct Baz < ' a > {
27
+ mode : Bar < ' a , Foo > ,
28
+ }
29
+ }
30
+
31
+ pub struct Struct < ' a > {
32
+ lexer : baz:: Baz < ' a > ,
33
+ }
34
+
35
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: type `Foo` is private
2
+ --> $DIR/generic_struct_field_projection.rs:22:9
3
+ |
4
+ LL | source: &'a T::Assoc,
5
+ | ^^^^^^^^^^^^^^^^^^^^ private type
6
+
7
+ error: aborting due to 1 previous error
8
+
You can’t perform that action at this time.
0 commit comments