diff options
| author | bors <bors@rust-lang.org> | 2021-05-27 10:42:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-27 10:42:01 +0000 |
| commit | 8d1e3d3b74fa80ce14af6ec143f061897684582b (patch) | |
| tree | e90163de95de607cd8b72b61f65a2a0aab13a241 | |
| parent | 9814e830942dcc65e69a0d077cb2e013b5948795 (diff) | |
| parent | edef5bc31bce648723ad0ddb2de4c0d1969fc8d0 (diff) | |
| download | rust-8d1e3d3b74fa80ce14af6ec143f061897684582b.tar.gz rust-8d1e3d3b74fa80ce14af6ec143f061897684582b.zip | |
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.
| -rw-r--r-- | compiler/rustc_lint/src/nonstandard_style.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/traits/alias/style_lint.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/traits/alias/style_lint.stderr | 10 |
3 files changed, 19 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index be9c6eafb6f..7146dd51aa7 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -176,6 +176,7 @@ impl EarlyLintPass for NonCamelCaseTypes { | ast::ItemKind::Struct(..) | ast::ItemKind::Union(..) => self.check_case(cx, "type", &it.ident), ast::ItemKind::Trait(..) => self.check_case(cx, "trait", &it.ident), + ast::ItemKind::TraitAlias(..) => self.check_case(cx, "trait alias", &it.ident), _ => (), } } diff --git a/src/test/ui/traits/alias/style_lint.rs b/src/test/ui/traits/alias/style_lint.rs new file mode 100644 index 00000000000..33be20054b5 --- /dev/null +++ b/src/test/ui/traits/alias/style_lint.rs @@ -0,0 +1,8 @@ +// check-pass + +#![feature(trait_alias)] + +trait Foo = std::fmt::Display + std::fmt::Debug; +trait bar = std::fmt::Display + std::fmt::Debug; //~WARN trait alias `bar` should have an upper camel case name + +fn main() {} diff --git a/src/test/ui/traits/alias/style_lint.stderr b/src/test/ui/traits/alias/style_lint.stderr new file mode 100644 index 00000000000..91e2ea90eb9 --- /dev/null +++ b/src/test/ui/traits/alias/style_lint.stderr @@ -0,0 +1,10 @@ +warning: trait alias `bar` should have an upper camel case name + --> $DIR/style_lint.rs:6:7 + | +LL | trait bar = std::fmt::Display + std::fmt::Debug; + | ^^^ help: convert the identifier to upper camel case: `Bar` + | + = note: `#[warn(non_camel_case_types)]` on by default + +warning: 1 warning emitted + |
