Skip to content

Commit 7d1718d

Browse files
---
yaml --- r: 231913 b: refs/heads/auto c: 42e1622 h: refs/heads/master i: 231911: 8f16096 v: v3
1 parent 22c8196 commit 7d1718d

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
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: c4a3936327f2f1082e3ac52e3dc7b250e3a04506
11+
refs/heads/auto: 42e16223cfbe9fc1ee22cde8e698914eaf8dab55
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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/auto/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)