Skip to content

Commit 93d872d

Browse files
committed
Add UI test
1 parent 23014b4 commit 93d872d

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct OtherType;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// aux-build:priv_dep.rs
2+
#![feature(public_private_dependencies)]
3+
#![deny(leaked_private_dependency)]
4+
5+
// This crate is a private dependency
6+
extern crate priv_dep;
7+
8+
use priv_dep::OtherType;
9+
10+
// Type from private dependency used in private
11+
// type - this is fine
12+
struct PrivateType {
13+
field: OtherType
14+
}
15+
16+
pub struct PublicType {
17+
pub field: OtherType,
18+
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
19+
//~| WARNING this was previously accepted
20+
priv_field: OtherType,
21+
}
22+
23+
impl PublicType {
24+
pub fn pub_fn(param: OtherType) {}
25+
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
26+
//~| WARNING this was previously accepted
27+
28+
fn priv_fn(param: OtherType) {}
29+
}
30+
31+
fn main() {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
2+
--> $DIR/pub-priv1.rs:17:5
3+
|
4+
LL | pub field: OtherType,
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/pub-priv1.rs:3:9
9+
|
10+
LL | #![deny(leaked_private_dependency)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
13+
= note: for more information, see issue #44663 <https://github.com/rust-lang/rust/issues/44663>
14+
15+
error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
16+
--> $DIR/pub-priv1.rs:24:5
17+
|
18+
LL | pub fn pub_fn(param: OtherType) {}
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
|
21+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
22+
= note: for more information, see issue #44663 <https://github.com/rust-lang/rust/issues/44663>
23+
24+
error: aborting due to 2 previous errors
25+

0 commit comments

Comments
 (0)