@@ -852,23 +852,26 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
852
852
!ident. contains_char ( '_' )
853
853
}
854
854
855
- fn check_case ( cx : & Context , ident : ast:: ident , span : span ) {
855
+ fn check_case ( cx : & Context , sort : & str , ident : ast:: ident , span : span ) {
856
856
if !is_camel_case ( cx. tcx , ident) {
857
- cx. span_lint ( non_camel_case_types, span,
858
- "type, variant, or trait should have \
859
- a camel case identifier") ;
857
+ cx. span_lint (
858
+ non_camel_case_types, span,
859
+ fmt ! ( "%s `%s` should have a camel case identifier" ,
860
+ sort, cx. tcx. sess. str_of( ident) ) ) ;
860
861
}
861
862
}
862
863
863
864
match it. node {
864
- ast:: item_ty( * ) | ast:: item_struct( * ) |
865
+ ast:: item_ty( * ) | ast:: item_struct( * ) => {
866
+ check_case ( cx, "type" , it. ident , it. span )
867
+ }
865
868
ast:: item_trait( * ) => {
866
- check_case ( cx, it. ident , it. span )
869
+ check_case ( cx, "trait" , it. ident , it. span )
867
870
}
868
871
ast:: item_enum( ref enum_definition, _) => {
869
- check_case ( cx, it. ident , it. span ) ;
872
+ check_case ( cx, "type" , it. ident , it. span ) ;
870
873
for enum_definition . variants. iter( ) . advance |variant| {
871
- check_case( cx, variant. node. name, variant. span) ;
874
+ check_case( cx, "variant" , variant. node. name, variant. span) ;
872
875
}
873
876
}
874
877
_ => ( )
0 commit comments