Skip to content

Commit 4ea862f

Browse files
authored
Rollup merge of rust-lang#97941 - CorinJG:error_naming_conventions, r=compiler-errors
nit: Fixed several error_codes/Exxxx.md messages which used UpperCamelCase… … instead of snake_case for module names
2 parents 30a8903 + 6227d89 commit 4ea862f

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

compiler/rustc_error_codes/src/error_codes/E0451.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ A struct constructor with private fields was invoked.
33
Erroneous code example:
44

55
```compile_fail,E0451
6-
mod Bar {
6+
mod bar {
77
pub struct Foo {
88
pub a: isize,
99
b: isize,
1010
}
1111
}
1212
13-
let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`
13+
let f = bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `bar::Foo`
1414
// is private
1515
```
1616

1717
To fix this error, please ensure that all the fields of the struct are public,
1818
or implement a function for easy instantiation. Examples:
1919

2020
```
21-
mod Bar {
21+
mod bar {
2222
pub struct Foo {
2323
pub a: isize,
2424
pub b: isize, // we set `b` field public
2525
}
2626
}
2727
28-
let f = Bar::Foo{ a: 0, b: 0 }; // ok!
28+
let f = bar::Foo{ a: 0, b: 0 }; // ok!
2929
```
3030

3131
Or:
3232

3333
```
34-
mod Bar {
34+
mod bar {
3535
pub struct Foo {
3636
pub a: isize,
3737
b: isize, // still private
@@ -44,5 +44,5 @@ mod Bar {
4444
}
4545
}
4646
47-
let f = Bar::Foo::new(); // ok!
47+
let f = bar::Foo::new(); // ok!
4848
```

compiler/rustc_error_codes/src/error_codes/E0574.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ expected.
44
Erroneous code example:
55

66
```compile_fail,E0574
7-
mod Mordor {}
7+
mod mordor {}
88
9-
let sauron = Mordor { x: () }; // error!
9+
let sauron = mordor { x: () }; // error!
1010
1111
enum Jak {
1212
Daxter { i: isize },
@@ -19,17 +19,17 @@ match eco {
1919
```
2020

2121
In all these errors, a type was expected. For example, in the first error,
22-
we tried to instantiate the `Mordor` module, which is impossible. If you want
22+
we tried to instantiate the `mordor` module, which is impossible. If you want
2323
to instantiate a type inside a module, you can do it as follow:
2424

2525
```
26-
mod Mordor {
26+
mod mordor {
2727
pub struct TheRing {
2828
pub x: usize,
2929
}
3030
}
3131
32-
let sauron = Mordor::TheRing { x: 1 }; // ok!
32+
let sauron = mordor::TheRing { x: 1 }; // ok!
3333
```
3434

3535
In the second error, we tried to bind the `Jak` enum directly, which is not

compiler/rustc_error_codes/src/error_codes/E0577.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ fn main() {}
1111
```
1212

1313
`Sea` is not a module, therefore it is invalid to use it in a visibility path.
14-
To fix this error we need to ensure `Sea` is a module.
14+
To fix this error we need to ensure `sea` is a module.
1515

1616
Please note that the visibility scope can only be applied on ancestors!
1717

1818
```edition2018
19-
pub mod Sea {
20-
pub (in crate::Sea) struct Shark; // ok!
19+
pub mod sea {
20+
pub (in crate::sea) struct Shark; // ok!
2121
}
2222
2323
fn main() {}

compiler/rustc_error_codes/src/error_codes/E0603.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ A private item was used outside its scope.
33
Erroneous code example:
44

55
```compile_fail,E0603
6-
mod SomeModule {
6+
mod foo {
77
const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we
88
// can't use it outside of the
9-
// `SomeModule` module.
9+
// `foo` module.
1010
}
1111
12-
println!("const value: {}", SomeModule::PRIVATE); // error: constant `PRIVATE`
12+
println!("const value: {}", foo::PRIVATE); // error: constant `PRIVATE`
1313
// is private
1414
```
1515

1616
In order to fix this error, you need to make the item public by using the `pub`
1717
keyword. Example:
1818

1919
```
20-
mod SomeModule {
20+
mod foo {
2121
pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the
2222
// `pub` keyword.
2323
}
2424
25-
println!("const value: {}", SomeModule::PRIVATE); // ok!
25+
println!("const value: {}", foo::PRIVATE); // ok!
2626
```

compiler/rustc_error_codes/src/error_codes/E0742.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ item.
44
Erroneous code example:
55

66
```compile_fail,E0742,edition2018
7-
pub mod Sea {}
7+
pub mod sea {}
88
9-
pub (in crate::Sea) struct Shark; // error!
9+
pub (in crate::sea) struct Shark; // error!
1010
1111
fn main() {}
1212
```
1313

14-
To fix this error, we need to move the `Shark` struct inside the `Sea` module:
14+
To fix this error, we need to move the `Shark` struct inside the `sea` module:
1515

1616
```edition2018
17-
pub mod Sea {
18-
pub (in crate::Sea) struct Shark; // ok!
17+
pub mod sea {
18+
pub (in crate::sea) struct Shark; // ok!
1919
}
2020
2121
fn main() {}
@@ -25,9 +25,9 @@ Of course, you can do it as long as the module you're referring to is an
2525
ancestor:
2626

2727
```edition2018
28-
pub mod Earth {
29-
pub mod Sea {
30-
pub (in crate::Earth) struct Shark; // ok!
28+
pub mod earth {
29+
pub mod sea {
30+
pub (in crate::earth) struct Shark; // ok!
3131
}
3232
}
3333

0 commit comments

Comments
 (0)