diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-06-02 21:38:52 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-06-02 21:40:22 +0200 |
| commit | 6675bb3e732b5dccc250419755acb35cf7f8155c (patch) | |
| tree | 444696d2ba4ed9a7a9e0de4792f47f2df3cbdebb /src/librustc_resolve | |
| parent | 4ed2edaafe82fb8d44e81e00ca3e4f7659855ba2 (diff) | |
| download | rust-6675bb3e732b5dccc250419755acb35cf7f8155c.tar.gz rust-6675bb3e732b5dccc250419755acb35cf7f8155c.zip | |
Add E0603 error code
Diffstat (limited to 'src/librustc_resolve')
| -rw-r--r-- | src/librustc_resolve/diagnostics.rs | 29 | ||||
| -rw-r--r-- | src/librustc_resolve/lib.rs | 2 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index fa6ea9dba43..1a5cf89f969 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -1578,6 +1578,35 @@ fn print_on_failure(state: &State) { ``` "##, +E0603: r##" +A private item was used outside its scope. + +Erroneous code example: + +```compile_fail,E0603 +mod SomeModule { + const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we + // can't use it outside of the + // `SomeModule` module. +} + +println!("const value: {}", SomeModule::PRIVATE); // error: constant `CONSTANT` + // is private +``` + +In order to fix this error, you need to make the item public by using the `pub` +keyword. Example: + +``` +mod SomeModule { + pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the + // `pub` keyword. +} + +println!("const value: {}", SomeModule::PRIVATE); // ok! +``` +"##, + } register_diagnostics! { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a40c191f7bd..b23cce6d425 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3428,7 +3428,7 @@ impl<'a> Resolver<'a> { for &PrivacyError(span, name, binding) in &self.privacy_errors { if !reported_spans.insert(span) { continue } - self.session.span_err(span, &format!("{} `{}` is private", binding.descr(), name)); + span_err!(self.session, span, E0603, "{} `{}` is private", binding.descr(), name); } } |
