@@ -827,23 +827,26 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
827
827
!ident. contains_char ( '_' )
828
828
}
829
829
830
- fn check_case ( cx : & Context , ident : ast:: ident , span : span ) {
830
+ fn check_case ( cx : & Context , sort : & str , ident : ast:: ident , span : span ) {
831
831
if !is_camel_case ( cx. tcx , ident) {
832
- cx. span_lint ( non_camel_case_types, span,
833
- "type, variant, or trait should have \
834
- a camel case identifier") ;
832
+ cx. span_lint (
833
+ non_camel_case_types, span,
834
+ fmt ! ( "%s `%s` should have a camel case identifier" ,
835
+ sort, cx. tcx. sess. str_of( ident) ) ) ;
835
836
}
836
837
}
837
838
838
839
match it. node {
839
- ast:: item_ty( * ) | ast:: item_struct( * ) |
840
+ ast:: item_ty( * ) | ast:: item_struct( * ) => {
841
+ check_case ( cx, "type" , it. ident , it. span )
842
+ }
840
843
ast:: item_trait( * ) => {
841
- check_case ( cx, it. ident , it. span )
844
+ check_case ( cx, "trait" , it. ident , it. span )
842
845
}
843
846
ast:: item_enum( ref enum_definition, _) => {
844
- check_case ( cx, it. ident , it. span ) ;
847
+ check_case ( cx, "type" , it. ident , it. span ) ;
845
848
for enum_definition . variants. iter( ) . advance |variant| {
846
- check_case( cx, variant. node. name, variant. span) ;
849
+ check_case( cx, "variant" , variant. node. name, variant. span) ;
847
850
}
848
851
}
849
852
_ => ( )
0 commit comments