Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustc_lint/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ impl EarlyLintPass for NonCamelCaseTypes {
}
}

fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
if let ast::AssocItemKind::TyAlias(..) = it.kind {
self.check_case(cx, "associated type", &it.ident);
}
}

fn check_variant(&mut self, cx: &EarlyContext<'_>, v: &ast::Variant) {
self.check_case(cx, "variant", &v.ident);
}
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-17732.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// check-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]
// pretty-expanded FIXME #23616

trait Person {
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/issues/issue-35600.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// run-pass
#![allow(non_camel_case_types)]
#![allow(unused_variables)]

trait Foo {
type bar;
fn bar();
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/lint/lint-non-camel-case-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum Foo5 {
}

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

Expand Down
10 changes: 8 additions & 2 deletions src/test/ui/lint/lint-non-camel-case-types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ error: trait `foo6` should have an upper camel case name
LL | trait foo6 {
| ^^^^ help: convert the identifier to upper camel case (notice the capitalization): `Foo6`

error: associated type `foo7` should have an upper camel case name
--> $DIR/lint-non-camel-case-types.rs:26:10
|
LL | type foo7;
| ^^^^ help: convert the identifier to upper camel case (notice the capitalization): `Foo7`

error: type parameter `ty` should have an upper camel case name
--> $DIR/lint-non-camel-case-types.rs:29:6
--> $DIR/lint-non-camel-case-types.rs:30:6
|
LL | fn f<ty>(_: ty) {}
| ^^ help: convert the identifier to upper camel case: `Ty`

error: aborting due to 8 previous errors
error: aborting due to 9 previous errors