Skip to content

Commit 8354446

Browse files
---
yaml --- r: 234495 b: refs/heads/tmp c: 42e1622 h: refs/heads/master i: 234493: 8c52b81 234491: 0220cba 234487: 0080199 234479: 895304c 234463: 5ce9f36 234431: 091a817 234367: da2baf8 234239: 79a56eb 233983: cec7bc8 233471: 1bfa0b2 v: v3
1 parent 9e797d8 commit 8354446

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: c4a3936327f2f1082e3ac52e3dc7b250e3a04506
28+
refs/heads/tmp: 42e16223cfbe9fc1ee22cde8e698914eaf8dab55
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/librustc_privacy/diagnostics.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
register_long_diagnostics! {
1414

1515
E0445: r##"
16-
A private trait was used on a "public" type. Erroneous code example:
16+
A private trait was used on a public type parameter bound. Erroneous code
17+
examples:
1718
1819
```
1920
trait Foo {
@@ -23,8 +24,9 @@ trait Foo {
2324
pub trait Bar : Foo {} // error: private trait in exported type parameter bound
2425
```
2526
26-
To solve this error, please ensure the trait is accessible at the same level of
27-
the type(s) on which it's implemented. Example:
27+
To solve this error, please ensure that the trait is also public and accessible
28+
at the same level of the public functions or types which are bound on it.
29+
Example:
2830
2931
```
3032
pub trait Foo { // we set the Foo trait public
@@ -48,8 +50,8 @@ mod Foo {
4850
}
4951
```
5052
51-
To solve this error, please ensure the type is accessible at the same level of
52-
the exported type signature. Example:
53+
To solve this error, please ensure that the type is also public and accessible
54+
at the same level of the public functions or types which use it. Example:
5355
5456
```
5557
mod Foo {
@@ -62,4 +64,18 @@ mod Foo {
6264
```
6365
"##,
6466

67+
E0447: r##"
68+
The `pub` keyword was used inside a function. Erroneous code example:
69+
70+
```
71+
fn foo() {
72+
pub struct Bar; // error: visibility has no effect inside functions
73+
}
74+
```
75+
76+
Since we cannot access inside function's elements, the visibility of its
77+
elements does not impact outer code. So using the `pub` keyword in this context
78+
is invalid.
79+
"##,
80+
6581
}

branches/tmp/src/librustc_privacy/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,8 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
10981098
let tcx = self.tcx;
10991099
fn check_inherited(tcx: &ty::ctxt, sp: Span, vis: hir::Visibility) {
11001100
if vis != hir::Inherited {
1101-
tcx.sess.span_err(sp, "visibility has no effect inside functions");
1101+
span_err!(tcx.sess, sp, E0447,
1102+
"visibility has no effect inside functions");
11021103
}
11031104
}
11041105
let check_struct = |def: &hir::StructDef| {

0 commit comments

Comments
 (0)