Fixed several error_codes/Exxxx.md messages which used UpperCamelCase instead of snake_case for module names

This commit is contained in:
CorinJG 2022-06-10 11:25:47 +01:00
parent 3dea0033f7
commit 20e166eab4
5 changed files with 30 additions and 30 deletions

View File

@ -3,14 +3,14 @@ A struct constructor with private fields was invoked.
Erroneous code example:
```compile_fail,E0451
mod Bar {
mod bar {
pub struct Foo {
pub a: isize,
b: isize,
}
}
let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`
let f = bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `bar::Foo`
// is private
```
@ -18,20 +18,20 @@ To fix this error, please ensure that all the fields of the struct are public,
or implement a function for easy instantiation. Examples:
```
mod Bar {
mod bar {
pub struct Foo {
pub a: isize,
pub b: isize, // we set `b` field public
}
}
let f = Bar::Foo{ a: 0, b: 0 }; // ok!
let f = bar::Foo{ a: 0, b: 0 }; // ok!
```
Or:
```
mod Bar {
mod bar {
pub struct Foo {
pub a: isize,
b: isize, // still private
@ -44,5 +44,5 @@ mod Bar {
}
}
let f = Bar::Foo::new(); // ok!
let f = bar::Foo::new(); // ok!
```

View File

@ -4,9 +4,9 @@ expected.
Erroneous code example:
```compile_fail,E0574
mod Mordor {}
mod mordor {}
let sauron = Mordor { x: () }; // error!
let sauron = mordor { x: () }; // error!
enum Jak {
Daxter { i: isize },
@ -19,17 +19,17 @@ match eco {
```
In all these errors, a type was expected. For example, in the first error,
we tried to instantiate the `Mordor` module, which is impossible. If you want
we tried to instantiate the `mordor` module, which is impossible. If you want
to instantiate a type inside a module, you can do it as follow:
```
mod Mordor {
mod mordor {
pub struct TheRing {
pub x: usize,
}
}
let sauron = Mordor::TheRing { x: 1 }; // ok!
let sauron = mordor::TheRing { x: 1 }; // ok!
```
In the second error, we tried to bind the `Jak` enum directly, which is not

View File

@ -3,21 +3,21 @@ Something other than a module was found in visibility scope.
Erroneous code example:
```compile_fail,E0577,edition2018
pub struct Sea;
pub struct sea;
pub (in crate::Sea) struct Shark; // error!
pub (in crate::sea) struct Shark; // error!
fn main() {}
```
`Sea` is not a module, therefore it is invalid to use it in a visibility path.
To fix this error we need to ensure `Sea` is a module.
`sea` is not a module, therefore it is invalid to use it in a visibility path.
To fix this error we need to ensure `sea` is a module.
Please note that the visibility scope can only be applied on ancestors!
```edition2018
pub mod Sea {
pub (in crate::Sea) struct Shark; // ok!
pub mod sea {
pub (in crate::sea) struct Shark; // ok!
}
fn main() {}

View File

@ -3,13 +3,13 @@ A private item was used outside its scope.
Erroneous code example:
```compile_fail,E0603
mod SomeModule {
mod foo {
const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we
// can't use it outside of the
// `SomeModule` module.
// `foo` module.
}
println!("const value: {}", SomeModule::PRIVATE); // error: constant `PRIVATE`
println!("const value: {}", foo::PRIVATE); // error: constant `PRIVATE`
// is private
```
@ -17,10 +17,10 @@ In order to fix this error, you need to make the item public by using the `pub`
keyword. Example:
```
mod SomeModule {
mod foo {
pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the
// `pub` keyword.
}
println!("const value: {}", SomeModule::PRIVATE); // ok!
println!("const value: {}", foo::PRIVATE); // ok!
```

View File

@ -4,18 +4,18 @@ item.
Erroneous code example:
```compile_fail,E0742,edition2018
pub mod Sea {}
pub mod sea {}
pub (in crate::Sea) struct Shark; // error!
pub (in crate::sea) struct Shark; // error!
fn main() {}
```
To fix this error, we need to move the `Shark` struct inside the `Sea` module:
To fix this error, we need to move the `Shark` struct inside the `sea` module:
```edition2018
pub mod Sea {
pub (in crate::Sea) struct Shark; // ok!
pub mod sea {
pub (in crate::sea) struct Shark; // ok!
}
fn main() {}
@ -25,9 +25,9 @@ Of course, you can do it as long as the module you're referring to is an
ancestor:
```edition2018
pub mod Earth {
pub mod Sea {
pub (in crate::Earth) struct Shark; // ok!
pub mod earth {
pub mod sea {
pub (in crate::earth) struct Shark; // ok!
}
}