Skip to content

Commit b065031

Browse files
authored
Rollup merge of rust-lang#67936 - euclio:assoc-type-bad-style, r=Centril
fire "non_camel_case_types" for associated types Fixes rust-lang#67920.
2 parents 1e7a6a8 + a7727c5 commit b065031

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
@@ -143,6 +143,12 @@ impl EarlyLintPass for NonCamelCaseTypes {
143143
}
144144
}
145145

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

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)