forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#123377 - oli-obk:private_projection, r=compil…
…er-errors Only inspect user-written predicates for privacy concerns fixes rust-lang#123288 Previously we looked at the elaborated predicates, which, due to adding various bounds on fields, end up requiring trivially true bounds. But these bounds can contain private types, which the privacy visitor then found and errored about.
- Loading branch information
Showing
2 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! To determine all the types that need to be private when looking at `Struct`, we | ||
//! used to invoke `predicates_of` to also look at types in `where` bounds. | ||
//! Unfortunately this also computes the inferred outlives bounds, which means for | ||
//! every field we check that if it is of type `&'a T` then `T: 'a` and if it is of | ||
//! struct type, we check that the struct satisfies its lifetime parameters by looking | ||
//! at its inferred outlives bounds. This means we end up with a `<Foo as Trait>::Assoc: 'a` | ||
//! in the outlives bounds of `Struct`. While this is trivially provable, privacy | ||
//! only sees `Foo` and `Trait` and determines that `Foo` is private and then errors. | ||
//! So now we invoke `explicit_predicates_of` to make sure we only care about user-written | ||
//! predicates. | ||
|
||
//@ check-pass | ||
|
||
mod baz { | ||
struct Foo; | ||
|
||
pub trait Trait { | ||
type Assoc; | ||
} | ||
|
||
impl Trait for Foo { | ||
type Assoc = (); | ||
} | ||
|
||
pub struct Bar<'a, T: Trait> { | ||
source: &'a T::Assoc, | ||
} | ||
|
||
pub struct Baz<'a> { | ||
mode: Bar<'a, Foo>, | ||
} | ||
} | ||
|
||
pub struct Struct<'a> { | ||
lexer: baz::Baz<'a>, | ||
} | ||
|
||
fn main() {} |