Skip to content

Commit a7727c5

Browse files
committed
fire "non_camel_case_types" for associated types
1 parent a80e63f commit a7727c5

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

src/librustc_lint/nonstandard_style.rs

+6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ impl EarlyLintPass for NonCamelCaseTypes {
142142
}
143143
}
144144

145+
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
146+
if let ast::AssocItemKind::TyAlias(..) = it.kind {
147+
self.check_case(cx, "associated type", &it.ident);
148+
}
149+
}
150+
145151
fn check_variant(&mut self, cx: &EarlyContext<'_>, v: &ast::Variant) {
146152
self.check_case(cx, "variant", &v.ident);
147153
}

src/test/ui/issues/issue-17732.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// check-pass
22
#![allow(dead_code)]
3+
#![allow(non_camel_case_types)]
34
// pretty-expanded FIXME #23616
45

56
trait Person {

src/test/ui/issues/issue-35600.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// run-pass
2+
#![allow(non_camel_case_types)]
23
#![allow(unused_variables)]
4+
35
trait Foo {
46
type bar;
57
fn bar();

src/test/ui/lint/lint-non-camel-case-types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum Foo5 {
2323
}
2424

2525
trait foo6 { //~ ERROR trait `foo6` should have an upper camel case name
26+
type foo7; //~ ERROR associated type `foo7` should have an upper camel case name
2627
fn dummy(&self) { }
2728
}
2829

src/test/ui/lint/lint-non-camel-case-types.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@ error: trait `foo6` should have an upper camel case name
4646
LL | trait foo6 {
4747
| ^^^^ help: convert the identifier to upper camel case (notice the capitalization): `Foo6`
4848

49+
error: associated type `foo7` should have an upper camel case name
50+
--> $DIR/lint-non-camel-case-types.rs:26:10
51+
|
52+
LL | type foo7;
53+
| ^^^^ help: convert the identifier to upper camel case (notice the capitalization): `Foo7`
54+
4955
error: type parameter `ty` should have an upper camel case name
50-
--> $DIR/lint-non-camel-case-types.rs:29:6
56+
--> $DIR/lint-non-camel-case-types.rs:30:6
5157
|
5258
LL | fn f<ty>(_: ty) {}
5359
| ^^ help: convert the identifier to upper camel case: `Ty`
5460

55-
error: aborting due to 8 previous errors
61+
error: aborting due to 9 previous errors
5662

0 commit comments

Comments
 (0)