Skip to content

Commit 2be37ad

Browse files
author
Christian
committed
Added the E0704 error with a link to the Rust reference.
1 parent 0d17322 commit 2be37ad

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/libsyntax/error_codes.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,35 @@ and likely to change in the future.
363363
364364
"##,
365365

366+
E0704: r##"
367+
This error indicates that a incorrect visibility restriction was specified.
368+
369+
Example of erroneous code:
370+
371+
```compile_fail,E0704
372+
mod foo {
373+
pub(foo) struct Bar {
374+
x: i32
375+
}
376+
}
377+
```
378+
379+
To make struct `Bar` only visible in module `foo` the `in` keyword should be
380+
used:
381+
```
382+
mod foo {
383+
pub(in crate::foo) struct Bar {
384+
x: i32
385+
}
386+
}
387+
# fn main() {}
388+
```
389+
390+
For more information see the Rust Reference on [Visibility].
391+
392+
[Visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html
393+
"##,
394+
366395
E0705: r##"
367396
A `#![feature]` attribute was declared for a feature that is stable in
368397
the current edition, but not in all editions.
@@ -417,6 +446,5 @@ register_diagnostics! {
417446
E0693, // incorrect `repr(align)` attribute format
418447
E0694, // an unknown tool name found in scoped attributes
419448
E0703, // invalid ABI
420-
E0704, // incorrect visibility restriction
421449
E0717, // rustc_promotable without stability attribute
422450
}

src/test/ui/pub/pub-restricted.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ LL | pub (in x) non_parent_invalid: usize,
5050

5151
error: aborting due to 5 previous errors
5252

53+
For more information about this error, try `rustc --explain E0704`.

0 commit comments

Comments
 (0)