Skip to content

Commit aede7a9

Browse files
committed
Only inspect user-written predicates for privacy concerns
1 parent 79021b0 commit aede7a9

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

compiler/rustc_ty_utils/src/sig_types.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub trait SpannedTypeVisitor<'tcx> {
1313
fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) -> Self::Result;
1414
}
1515

16+
#[instrument(level = "trace", skip(tcx, visitor))]
1617
pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
1718
tcx: TyCtxt<'tcx>,
1819
item: LocalDefId,
@@ -36,7 +37,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
3637
for (hir, ty) in hir_sig.inputs.iter().zip(ty_sig.inputs().iter()) {
3738
try_visit!(visitor.visit(hir.span, ty.map_bound(|x| *x)));
3839
}
39-
for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) {
40+
for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) {
4041
try_visit!(visitor.visit(span, pred));
4142
}
4243
}
@@ -54,7 +55,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
5455
// Associated types in traits don't necessarily have a type that we can visit
5556
try_visit!(visitor.visit(ty.span, tcx.type_of(item).instantiate_identity()));
5657
}
57-
for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) {
58+
for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) {
5859
try_visit!(visitor.visit(span, pred));
5960
}
6061
}
@@ -76,7 +77,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
7677
let ty = field.ty(tcx, args);
7778
try_visit!(visitor.visit(span, ty));
7879
}
79-
for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) {
80+
for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) {
8081
try_visit!(visitor.visit(span, pred));
8182
}
8283
}
@@ -95,12 +96,12 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
9596
_ => tcx.def_span(item),
9697
};
9798
try_visit!(visitor.visit(span, tcx.type_of(item).instantiate_identity()));
98-
for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) {
99+
for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) {
99100
try_visit!(visitor.visit(span, pred));
100101
}
101102
}
102103
DefKind::TraitAlias | DefKind::Trait => {
103-
for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) {
104+
for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) {
104105
try_visit!(visitor.visit(span, pred));
105106
}
106107
}

tests/ui/privacy/generic_struct_field_projection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ check-pass
2+
13
mod baz {
24
struct Foo;
35

@@ -11,7 +13,6 @@ mod baz {
1113

1214
pub struct Bar<'a, T: Trait> {
1315
source: &'a T::Assoc,
14-
//~^ ERROR: type `Foo` is private
1516
}
1617

1718
pub struct Baz<'a> {

tests/ui/privacy/generic_struct_field_projection.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)