Skip to content

Commit 12f9b79

Browse files
committed
Improve UI tests
1 parent 08c901f commit 12f9b79

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pub struct OtherType;
2+
pub trait OtherTrait {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct PubType;

src/test/ui/privacy/pub-priv-dep/pub-priv1.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// aux-build:priv_dep.rs
2+
// aux-build:pub_dep.rs
3+
// compile-flags: --extern-public=pub_dep
24
#![feature(public_private_dependencies)]
35
#![deny(leaked_private_dependency)]
46

57
// This crate is a private dependency
68
extern crate priv_dep;
9+
// This crate is a public dependenct
10+
extern crate pub_dep;
711

8-
use priv_dep::OtherType;
12+
use priv_dep::{OtherType, OtherTrait};
13+
use pub_dep::PubType;
914

1015
// Type from private dependency used in private
1116
// type - this is fine
@@ -17,7 +22,8 @@ pub struct PublicType {
1722
pub field: OtherType,
1823
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
1924
//~| WARNING this was previously accepted
20-
priv_field: OtherType,
25+
priv_field: OtherType, // Private field - this is fine
26+
pub other_field: PubType // Type from public dependency - this is fine
2127
}
2228

2329
impl PublicType {
@@ -28,4 +34,11 @@ impl PublicType {
2834
fn priv_fn(param: OtherType) {}
2935
}
3036

37+
pub trait MyPubTrait {
38+
type Foo: OtherTrait;
39+
}
40+
//~^^^ ERROR trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
41+
//~| WARNING this was previously accepted
42+
43+
3144
fn main() {}
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
2-
--> $DIR/pub-priv1.rs:17:5
2+
--> $DIR/pub-priv1.rs:22:5
33
|
44
LL | pub field: OtherType,
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
77
note: lint level defined here
8-
--> $DIR/pub-priv1.rs:3:9
8+
--> $DIR/pub-priv1.rs:5:9
99
|
1010
LL | #![deny(leaked_private_dependency)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1313
= note: for more information, see issue #44663 <https://github.com/rust-lang/rust/issues/44663>
1414

1515
error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
16-
--> $DIR/pub-priv1.rs:24:5
16+
--> $DIR/pub-priv1.rs:30:5
1717
|
1818
LL | pub fn pub_fn(param: OtherType) {}
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020
|
2121
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2222
= note: for more information, see issue #44663 <https://github.com/rust-lang/rust/issues/44663>
2323

24-
error: aborting due to 2 previous errors
24+
error: trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface
25+
--> $DIR/pub-priv1.rs:37:1
26+
|
27+
LL | / pub trait MyPubTrait {
28+
LL | | type Foo: OtherTrait;
29+
LL | | }
30+
| |_^
31+
|
32+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
33+
= note: for more information, see issue #44663 <https://github.com/rust-lang/rust/issues/44663>
34+
35+
error: aborting due to 3 previous errors
2536

0 commit comments

Comments
 (0)