Skip to content

Commit

Permalink
Rollup merge of rust-lang#67936 - euclio:assoc-type-bad-style, r=Centril
Browse files Browse the repository at this point in the history
fire "non_camel_case_types" for associated types

Fixes rust-lang#67920.
  • Loading branch information
Dylan-DPC authored Jan 6, 2020
2 parents d6b7b17 + a7727c5 commit 6492679
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/librustc_lint/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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

0 comments on commit 6492679

Please sign in to comment.