Skip to content

Commit d45c4a6

Browse files
authored
Rollup merge of rust-lang#48386 - withoutboats:nonstandard-style, r=Manishearth
Add nonstandard_style alias for bad_style.
2 parents 58af0c7 + 5949d8b commit d45c4a6

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

src/librustc_lint/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
152152
NON_SNAKE_CASE,
153153
NON_UPPER_CASE_GLOBALS);
154154

155+
add_lint_group!(sess,
156+
"nonstandard_style",
157+
NON_CAMEL_CASE_TYPES,
158+
NON_SNAKE_CASE,
159+
NON_UPPER_CASE_GLOBALS);
160+
155161
add_lint_group!(sess,
156162
"unused",
157163
UNUSED_IMPORTS,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2014–2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(nonstandard_style)]
12+
#![allow(dead_code)]
13+
14+
fn CamelCase() {} //~ ERROR should have a snake
15+
16+
#[allow(nonstandard_style)]
17+
mod test {
18+
fn CamelCase() {}
19+
20+
#[forbid(nonstandard_style)]
21+
mod bad {
22+
fn CamelCase() {} //~ ERROR should have a snake
23+
24+
static bad: isize = 1; //~ ERROR should have an upper
25+
}
26+
27+
mod warn {
28+
#![warn(nonstandard_style)]
29+
30+
fn CamelCase() {} //~ WARN should have a snake
31+
32+
struct snake_case; //~ WARN should have a camel
33+
}
34+
}
35+
36+
fn main() {}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
error: function `CamelCase` should have a snake case name such as `camel_case`
2+
--> $DIR/lint-group-nonstandard-style.rs:14:1
3+
|
4+
14 | fn CamelCase() {} //~ ERROR should have a snake
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/lint-group-nonstandard-style.rs:11:9
9+
|
10+
11 | #![deny(nonstandard_style)]
11+
| ^^^^^^^^^^^^^^^^^
12+
= note: #[deny(non_snake_case)] implied by #[deny(nonstandard_style)]
13+
14+
error: function `CamelCase` should have a snake case name such as `camel_case`
15+
--> $DIR/lint-group-nonstandard-style.rs:22:9
16+
|
17+
22 | fn CamelCase() {} //~ ERROR should have a snake
18+
| ^^^^^^^^^^^^^^^^^
19+
|
20+
note: lint level defined here
21+
--> $DIR/lint-group-nonstandard-style.rs:20:14
22+
|
23+
20 | #[forbid(nonstandard_style)]
24+
| ^^^^^^^^^^^^^^^^^
25+
= note: #[forbid(non_snake_case)] implied by #[forbid(nonstandard_style)]
26+
27+
error: static variable `bad` should have an upper case name such as `BAD`
28+
--> $DIR/lint-group-nonstandard-style.rs:24:9
29+
|
30+
24 | static bad: isize = 1; //~ ERROR should have an upper
31+
| ^^^^^^^^^^^^^^^^^^^^^^
32+
|
33+
note: lint level defined here
34+
--> $DIR/lint-group-nonstandard-style.rs:20:14
35+
|
36+
20 | #[forbid(nonstandard_style)]
37+
| ^^^^^^^^^^^^^^^^^
38+
= note: #[forbid(non_upper_case_globals)] implied by #[forbid(nonstandard_style)]
39+
40+
warning: function `CamelCase` should have a snake case name such as `camel_case`
41+
--> $DIR/lint-group-nonstandard-style.rs:30:9
42+
|
43+
30 | fn CamelCase() {} //~ WARN should have a snake
44+
| ^^^^^^^^^^^^^^^^^
45+
|
46+
note: lint level defined here
47+
--> $DIR/lint-group-nonstandard-style.rs:28:17
48+
|
49+
28 | #![warn(nonstandard_style)]
50+
| ^^^^^^^^^^^^^^^^^
51+
= note: #[warn(non_snake_case)] implied by #[warn(nonstandard_style)]
52+
53+
warning: type `snake_case` should have a camel case name such as `SnakeCase`
54+
--> $DIR/lint-group-nonstandard-style.rs:32:9
55+
|
56+
32 | struct snake_case; //~ WARN should have a camel
57+
| ^^^^^^^^^^^^^^^^^^
58+
|
59+
note: lint level defined here
60+
--> $DIR/lint-group-nonstandard-style.rs:28:17
61+
|
62+
28 | #![warn(nonstandard_style)]
63+
| ^^^^^^^^^^^^^^^^^
64+
= note: #[warn(non_camel_case_types)] implied by #[warn(nonstandard_style)]
65+
66+
error: aborting due to 3 previous errors
67+

0 commit comments

Comments
 (0)