Skip to content

Commit 769ab55

Browse files
committed
Add regression test
1 parent e2cf2cb commit 769ab55

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Diff for: tests/ui/privacy/generic_struct_field_projection.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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() {}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+

0 commit comments

Comments
 (0)