Skip to content

Commit d003c56

Browse files
---
yaml --- r: 234150 b: refs/heads/beta c: bda7ec0 h: refs/heads/master v: v3
1 parent 5d4f3bb commit d003c56

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 42e16223cfbe9fc1ee22cde8e698914eaf8dab55
26+
refs/heads/beta: bda7ec0755e7eda62ff3e5d26365f6fd0cc7e4fb
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_privacy/diagnostics.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,29 @@ elements does not impact outer code. So using the `pub` keyword in this context
7878
is invalid.
7979
"##,
8080

81+
E0448: r##"
82+
The `pub` keyword was used inside a public enum. Erroneous code example:
83+
84+
```
85+
pub enum Foo {
86+
pub Bar, // error: unnecessary `pub` visibility
87+
}
88+
```
89+
90+
Since the enum is already public, adding `pub` on one its elements is
91+
unnecessary. Example:
92+
93+
```
94+
enum Foo {
95+
pub Bar, // ok!
96+
}
97+
98+
// or:
99+
100+
pub enum Foo {
101+
Bar, // ok!
102+
}
103+
```
104+
"##,
105+
81106
}

branches/beta/src/librustc_privacy/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ use rustc::front::map as ast_map;
5050
use syntax::ast;
5151
use syntax::codemap::Span;
5252

53+
pub mod diagnostics;
54+
5355
type Context<'a, 'tcx> = (&'a ty::MethodMap<'tcx>, &'a def::ExportMap);
5456

5557
/// Result of a checking operation - None => no errors were found. Some => an
@@ -1076,8 +1078,8 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
10761078
match v.node.vis {
10771079
hir::Public => {
10781080
if item.vis == hir::Public {
1079-
tcx.sess.span_err(v.span, "unnecessary `pub` \
1080-
visibility");
1081+
span_err!(tcx.sess, v.span, E0448,
1082+
"unnecessary `pub` visibility");
10811083
}
10821084
}
10831085
hir::Inherited => {}

0 commit comments

Comments
 (0)