Use check_variant for non_camel_case_types lint

This commit is contained in:
Seo Sanghyeon 2017-02-14 19:46:48 +09:00
parent 48bc08247a
commit 255b5ed842
2 changed files with 23 additions and 9 deletions

View File

@ -117,22 +117,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
match it.node {
hir::ItemTy(..) |
hir::ItemEnum(..) |
hir::ItemStruct(..) |
hir::ItemUnion(..) => self.check_case(cx, "type", it.name, it.span),
hir::ItemTrait(..) => self.check_case(cx, "trait", it.name, it.span),
hir::ItemEnum(ref enum_definition, _) => {
if has_extern_repr {
return;
}
self.check_case(cx, "type", it.name, it.span);
for variant in &enum_definition.variants {
self.check_case(cx, "variant", variant.node.name, variant.span);
}
}
_ => (),
}
}
fn check_variant(&mut self, cx: &LateContext, v: &hir::Variant, _: &hir::Generics) {
self.check_case(cx, "variant", v.node.name, v.span);
}
fn check_generics(&mut self, cx: &LateContext, it: &hir::Generics) {
for gen in it.ty_params.iter() {
self.check_case(cx, "type parameter", gen.name, gen.span);

View File

@ -0,0 +1,18 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(non_camel_case_types)]
pub enum Foo {
#[allow(non_camel_case_types)]
bar
}
fn main() {}