Skip to content

Commit a32ce0f

Browse files
---
yaml --- r: 231914 b: refs/heads/auto c: bda7ec0 h: refs/heads/master v: v3
1 parent 7d1718d commit a32ce0f

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
@@ -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: 42e16223cfbe9fc1ee22cde8e698914eaf8dab55
11+
refs/heads/auto: bda7ec0755e7eda62ff3e5d26365f6fd0cc7e4fb
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: 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/auto/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)