3 use syntax::parse::token::InternedString;
6 /// **What it does:** This lint checks for various things we like to keep tidy in clippy
8 /// **Why is this bad?** ???
10 /// **Known problems:** None.
12 /// **Example:** wrong ordering of the util::paths constants
14 pub CLIPPY_LINTS_INTERNAL, Allow,
15 "Various things that will negatively affect your clippy experience"
19 #[derive(Copy, Clone)]
22 impl LintPass for Clippy {
23 fn get_lints(&self) -> LintArray {
24 lint_array!(CLIPPY_LINTS_INTERNAL)
28 impl EarlyLintPass for Clippy {
29 fn check_crate(&mut self, cx: &EarlyContext, krate: &Crate) {
30 if let Some(utils) = krate.module.items.iter().find(|item| item.ident.name.as_str() == "utils") {
31 if let ItemKind::Mod(ref utils_mod) = utils.node {
32 if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name.as_str() == "paths") {
33 if let ItemKind::Mod(ref paths_mod) = paths.node {
34 let mut last_name: Option<InternedString> = None;
35 for item in &paths_mod.items {
36 let name = item.ident.name.as_str();
37 if let Some(ref last_name) = last_name {
38 if **last_name > *name {
40 CLIPPY_LINTS_INTERNAL,
42 "this constant should be before the previous constant due to lexical ordering",
46 last_name = Some(name);