Skip to content

Commit cf1911e

Browse files
committed
Limit caching to alias types (including projections)
1 parent 7c19744 commit cf1911e

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

compiler/rustc_privacy/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ where
193193
| ty::Closure(def_id, ..)
194194
| ty::CoroutineClosure(def_id, ..)
195195
| ty::Coroutine(def_id, ..) => {
196-
if let ty::Adt(..) = ty_kind
197-
&& !self.visited_tys.insert(ty)
198-
{
199-
return V::Result::output();
200-
}
201196
try_visit!(self.def_id_visitor.visit_def_id(def_id, "type", &ty));
202197
if V::SHALLOW {
203198
return V::Result::output();
@@ -228,6 +223,9 @@ where
228223
// free type aliases, but this isn't done yet.
229224
return V::Result::output();
230225
}
226+
if !self.visited_tys.insert(ty) {
227+
return V::Result::output();
228+
}
231229

232230
try_visit!(self.def_id_visitor.visit_def_id(
233231
data.def_id,

tests/ui/privacy/pub-priv-dep/pub-priv1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ impl From<PublicWithStdImpl> for OtherType {
145145
//~| ERROR type `OtherType` from private dependency 'priv_dep' in public interface
146146
fn from(val: PublicWithStdImpl) -> Self { Self }
147147
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
148+
//~| ERROR type `OtherType` from private dependency 'priv_dep' in public interface
148149
}
149150

150151
pub struct AllowedPrivType {

tests/ui/privacy/pub-priv-dep/pub-priv1.stderr

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,55 @@ LL | #![deny(exported_private_dependencies)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: macro `m` from private dependency 'priv_dep' is re-exported
14-
--> $DIR/pub-priv1.rs:155:9
14+
--> $DIR/pub-priv1.rs:156:9
1515
|
1616
LL | pub use priv_dep::m;
1717
| ^^^^^^^^^^^
1818

1919
error: macro `fn_like` from private dependency 'pm' is re-exported
20-
--> $DIR/pub-priv1.rs:157:9
20+
--> $DIR/pub-priv1.rs:158:9
2121
|
2222
LL | pub use pm::fn_like;
2323
| ^^^^^^^^^^^
2424

2525
error: derive macro `PmDerive` from private dependency 'pm' is re-exported
26-
--> $DIR/pub-priv1.rs:159:9
26+
--> $DIR/pub-priv1.rs:160:9
2727
|
2828
LL | pub use pm::PmDerive;
2929
| ^^^^^^^^^^^^
3030

3131
error: attribute macro `pm_attr` from private dependency 'pm' is re-exported
32-
--> $DIR/pub-priv1.rs:161:9
32+
--> $DIR/pub-priv1.rs:162:9
3333
|
3434
LL | pub use pm::pm_attr;
3535
| ^^^^^^^^^^^
3636

3737
error: variant `V1` from private dependency 'priv_dep' is re-exported
38-
--> $DIR/pub-priv1.rs:164:9
38+
--> $DIR/pub-priv1.rs:165:9
3939
|
4040
LL | pub use priv_dep::E::V1;
4141
| ^^^^^^^^^^^^^^^
4242

4343
error: type alias `Unit` from private dependency 'priv_dep' is re-exported
44-
--> $DIR/pub-priv1.rs:167:9
44+
--> $DIR/pub-priv1.rs:168:9
4545
|
4646
LL | pub use priv_dep::Unit;
4747
| ^^^^^^^^^^^^^^
4848

4949
error: type alias `PubPub` from private dependency 'priv_dep' is re-exported
50-
--> $DIR/pub-priv1.rs:169:9
50+
--> $DIR/pub-priv1.rs:170:9
5151
|
5252
LL | pub use priv_dep::PubPub;
5353
| ^^^^^^^^^^^^^^^^
5454

5555
error: type alias `PubPriv` from private dependency 'priv_dep' is re-exported
56-
--> $DIR/pub-priv1.rs:171:9
56+
--> $DIR/pub-priv1.rs:172:9
5757
|
5858
LL | pub use priv_dep::PubPriv;
5959
| ^^^^^^^^^^^^^^^^^
6060

6161
error: struct `Renamed` from private dependency 'priv_dep' is re-exported
62-
--> $DIR/pub-priv1.rs:173:9
62+
--> $DIR/pub-priv1.rs:174:9
6363
|
6464
LL | pub use priv_dep::OtherType as Renamed;
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -248,5 +248,13 @@ error: type `OtherType` from private dependency 'priv_dep' in public interface
248248
LL | fn from(val: PublicWithStdImpl) -> Self { Self }
249249
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
250250

251-
error: aborting due to 40 previous errors
251+
error: type `OtherType` from private dependency 'priv_dep' in public interface
252+
--> $DIR/pub-priv1.rs:146:5
253+
|
254+
LL | fn from(val: PublicWithStdImpl) -> Self { Self }
255+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
256+
|
257+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
258+
259+
error: aborting due to 41 previous errors
252260

0 commit comments

Comments
 (0)