Skip to content

Commit 8d1e3d3

Browse files
committed
Auto merge of #85732 - Smittyvb:trait-alias-camelcase-lint, r=varkor
Lint against non-CamelCase trait alias names Type aliases are linted as such, so (unstable) trait aliases should be treated the same way.
2 parents 9814e83 + edef5bc commit 8d1e3d3

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

compiler/rustc_lint/src/nonstandard_style.rs

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ impl EarlyLintPass for NonCamelCaseTypes {
176176
| ast::ItemKind::Struct(..)
177177
| ast::ItemKind::Union(..) => self.check_case(cx, "type", &it.ident),
178178
ast::ItemKind::Trait(..) => self.check_case(cx, "trait", &it.ident),
179+
ast::ItemKind::TraitAlias(..) => self.check_case(cx, "trait alias", &it.ident),
179180
_ => (),
180181
}
181182
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-pass
2+
3+
#![feature(trait_alias)]
4+
5+
trait Foo = std::fmt::Display + std::fmt::Debug;
6+
trait bar = std::fmt::Display + std::fmt::Debug; //~WARN trait alias `bar` should have an upper camel case name
7+
8+
fn main() {}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: trait alias `bar` should have an upper camel case name
2+
--> $DIR/style_lint.rs:6:7
3+
|
4+
LL | trait bar = std::fmt::Display + std::fmt::Debug;
5+
| ^^^ help: convert the identifier to upper camel case: `Bar`
6+
|
7+
= note: `#[warn(non_camel_case_types)]` on by default
8+
9+
warning: 1 warning emitted
10+

0 commit comments

Comments
 (0)