]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_lint/nonstandard_style.rs
Various minor/cosmetic improvements to code
[rust.git] / src / librustc_lint / nonstandard_style.rs
index 09871c0e84049d801888014eafc012a400faa67f..13be50ef01f62433e02f1be394e2658646d9b85f 100644 (file)
@@ -8,19 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use rustc::hir::{self, GenericParamKind, PatKind};
 use rustc::hir::def::Def;
+use rustc::hir::intravisit::FnKind;
 use rustc::ty;
+use rustc_target::spec::abi::Abi;
 use lint::{LateContext, LintContext, LintArray};
 use lint::{LintPass, LateLintPass};
-
-use rustc_target::spec::abi::Abi;
 use syntax::ast;
 use syntax::attr;
 use syntax_pos::Span;
 
-use rustc::hir::{self, GenericParamKind, PatKind};
-use rustc::hir::intravisit::FnKind;
-
 #[derive(PartialEq)]
 pub enum MethodLateContext {
     TraitAutoImpl,
@@ -29,7 +27,7 @@ pub enum MethodLateContext {
 }
 
 pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext {
-    let def_id = cx.tcx.hir.local_def_id(id);
+    let def_id = cx.tcx.hir().local_def_id(id);
     let item = cx.tcx.associated_item(def_id);
     match item.container {
         ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,
@@ -59,10 +57,10 @@ fn char_has_case(c: char) -> bool {
 
         fn is_camel_case(name: ast::Name) -> bool {
             let name = name.as_str();
+            let name = name.trim_matches('_');
             if name.is_empty() {
                 return true;
             }
-            let name = name.trim_matches('_');
 
             // start with a non-lowercase letter rather than non-uppercase
             // ones (some scripts don't have a concept of upper/lowercase)
@@ -121,7 +119,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         let has_repr_c = it.attrs
             .iter()
             .any(|attr| {
-                attr::find_repr_attrs(cx.tcx.sess.diagnostic(), attr)
+                attr::find_repr_attrs(&cx.tcx.sess.parse_sess, attr)
                     .iter()
                     .any(|r| r == &attr::ReprC)
             });