privacy: Report priv-in-pub as errors in associated type bounds · rust-lang/rust@c5221eb (original) (raw)

`@@ -7,42 +7,32 @@ LL | struct Priv;

`

7

7

`LL | type A = Priv;

`

8

8

` | ^^^^^^ can't leak private type

`

9

9

``

10

``

`` -

warning: trait PrivTr is more private than the item PubTr::Alias1

``

``

10

`` +

error[E0446]: private trait PrivTr in public interface

``

11

11

` --> $DIR/private-in-public-assoc-ty.rs:24:9

`

12

12

` |

`

13

``

`-

LL | type Alias1: PrivTr;

`

14

``

`` -

| ^^^^^^^^^^^^^^^^^^^ associated type PubTr::Alias1 is reachable at visibility pub(crate)

``

15

``

`-

|

`

16

``

`` -

note: but trait PrivTr is only usable at visibility pub(self)

``

17

``

`-

--> $DIR/private-in-public-assoc-ty.rs:9:5

`

18

``

`-

|

`

19

13

`LL | trait PrivTr {}

`

20

``

`-

| ^^^^^^^^^^^^

`

21

``

`` -

= note: #[warn(private_bounds)] on by default

``

``

14

`` +

| ------------ PrivTr declared as private

``

``

15

`+

...

`

``

16

`+

LL | type Alias1: PrivTr;

`

``

17

`+

| ^^^^^^^^^^^^^^^^^^^ can't leak private trait

`

22

18

``

23

``

`` -

warning: type Priv is more private than the item PubTr::Alias2

``

``

19

`` +

error[E0446]: private type Priv in public interface

``

24

20

` --> $DIR/private-in-public-assoc-ty.rs:26:9

`

25

21

` |

`

26

``

`-

LL | type Alias2: PubTrAux1 = u8;

`

27

``

`` -

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type PubTr::Alias2 is reachable at visibility pub(crate)

``

28

``

`-

|

`

29

``

`` -

note: but type Priv is only usable at visibility pub(self)

``

30

``

`-

--> $DIR/private-in-public-assoc-ty.rs:8:5

`

31

``

`-

|

`

32

22

`LL | struct Priv;

`

33

``

`-

| ^^^^^^^^^^^

`

``

23

`` +

| ----------- Priv declared as private

``

``

24

`+

...

`

``

25

`+

LL | type Alias2: PubTrAux1 = u8;

`

``

26

`+

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type

`

34

27

``

35

``

`` -

warning: type Priv is more private than the item PubTr::Alias3

``

``

28

`` +

error[E0446]: private type Priv in public interface

``

36

29

` --> $DIR/private-in-public-assoc-ty.rs:28:9

`

37

30

` |

`

38

``

`-

LL | type Alias3: PubTrAux2<A = Priv> = u8;

`

39

``

`` -

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type PubTr::Alias3 is reachable at visibility pub(crate)

``

40

``

`-

|

`

41

``

`` -

note: but type Priv is only usable at visibility pub(self)

``

42

``

`-

--> $DIR/private-in-public-assoc-ty.rs:8:5

`

43

``

`-

|

`

44

31

`LL | struct Priv;

`

45

``

`-

| ^^^^^^^^^^^

`

``

32

`` +

| ----------- Priv declared as private

``

``

33

`+

...

`

``

34

`+

LL | type Alias3: PubTrAux2<A = Priv> = u8;

`

``

35

`+

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type

`

46

36

``

47

37

`` error[E0446]: private type Priv in public interface

``

48

38

` --> $DIR/private-in-public-assoc-ty.rs:31:9

`

`@@ -71,6 +61,6 @@ LL | trait PrivTr {}

`

71

61

`LL | type Exist = impl PrivTr;

`

72

62

` | ^^^^^^^^^^ can't leak private trait

`

73

63

``

74

``

`-

error: aborting due to 4 previous errors; 3 warnings emitted

`

``

64

`+

error: aborting due to 7 previous errors

`

75

65

``

76

66

`` For more information about this error, try rustc --explain E0446.

``