about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel Moelius <sam@moeli.us>2022-09-30 21:10:10 -0400
committerSamuel Moelius <sam@moeli.us>2022-10-15 07:03:29 -0400
commitc84ac4cee96f13b0abe8dc1f1b2d4e9406f80791 (patch)
tree633a92df240a87edf2c1749b48698e57b3afe613
parentdfd3525cff90fe2363494559499276ca07d2aef7 (diff)
downloadrust-c84ac4cee96f13b0abe8dc1f1b2d4e9406f80791.tar.gz
rust-c84ac4cee96f13b0abe8dc1f1b2d4e9406f80791.zip
Move some things around
-rw-r--r--clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs4
-rw-r--r--clippy_lints/src/utils/internal_lints/invalid_paths.rs64
2 files changed, 34 insertions, 34 deletions
diff --git a/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs b/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs
index 67357a5cb6b..d7e4a2c4422 100644
--- a/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs
+++ b/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs
@@ -30,6 +30,8 @@ declare_clippy_lint! {
     "usage of the lint functions of the compiler instead of the utils::* variant"
 }
 
+impl_lint_pass!(CompilerLintFunctions => [COMPILER_LINT_FUNCTIONS]);
+
 #[derive(Clone, Default)]
 pub struct CompilerLintFunctions {
     map: FxHashMap<&'static str, &'static str>,
@@ -48,8 +50,6 @@ impl CompilerLintFunctions {
     }
 }
 
-impl_lint_pass!(CompilerLintFunctions => [COMPILER_LINT_FUNCTIONS]);
-
 impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if is_lint_allowed(cx, COMPILER_LINT_FUNCTIONS, expr.hir_id) {
diff --git a/clippy_lints/src/utils/internal_lints/invalid_paths.rs b/clippy_lints/src/utils/internal_lints/invalid_paths.rs
index 57eb3f49d06..04f1952e813 100644
--- a/clippy_lints/src/utils/internal_lints/invalid_paths.rs
+++ b/clippy_lints/src/utils/internal_lints/invalid_paths.rs
@@ -25,6 +25,38 @@ declare_clippy_lint! {
     "invalid path"
 }
 
+declare_lint_pass!(InvalidPaths => [INVALID_PATHS]);
+
+impl<'tcx> LateLintPass<'tcx> for InvalidPaths {
+    fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
+        let local_def_id = &cx.tcx.parent_module(item.hir_id());
+        let mod_name = &cx.tcx.item_name(local_def_id.to_def_id());
+        if_chain! {
+            if mod_name.as_str() == "paths";
+            if let hir::ItemKind::Const(ty, body_id) = item.kind;
+            let ty = hir_ty_to_ty(cx.tcx, ty);
+            if let ty::Array(el_ty, _) = &ty.kind();
+            if let ty::Ref(_, el_ty, _) = &el_ty.kind();
+            if el_ty.is_str();
+            let body = cx.tcx.hir().body(body_id);
+            let typeck_results = cx.tcx.typeck_body(body_id);
+            if let Some(Constant::Vec(path)) = constant_simple(cx, typeck_results, body.value);
+            let path: Vec<&str> = path.iter().map(|x| {
+                    if let Constant::Str(s) = x {
+                        s.as_str()
+                    } else {
+                        // We checked the type of the constant above
+                        unreachable!()
+                    }
+                }).collect();
+            if !check_path(cx, &path[..]);
+            then {
+                span_lint(cx, INVALID_PATHS, item.span, "invalid path");
+            }
+        }
+    }
+}
+
 // This is not a complete resolver for paths. It works on all the paths currently used in the paths
 // module.  That's all it does and all it needs to do.
 pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
@@ -71,35 +103,3 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
 
     false
 }
-
-declare_lint_pass!(InvalidPaths => [INVALID_PATHS]);
-
-impl<'tcx> LateLintPass<'tcx> for InvalidPaths {
-    fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
-        let local_def_id = &cx.tcx.parent_module(item.hir_id());
-        let mod_name = &cx.tcx.item_name(local_def_id.to_def_id());
-        if_chain! {
-            if mod_name.as_str() == "paths";
-            if let hir::ItemKind::Const(ty, body_id) = item.kind;
-            let ty = hir_ty_to_ty(cx.tcx, ty);
-            if let ty::Array(el_ty, _) = &ty.kind();
-            if let ty::Ref(_, el_ty, _) = &el_ty.kind();
-            if el_ty.is_str();
-            let body = cx.tcx.hir().body(body_id);
-            let typeck_results = cx.tcx.typeck_body(body_id);
-            if let Some(Constant::Vec(path)) = constant_simple(cx, typeck_results, body.value);
-            let path: Vec<&str> = path.iter().map(|x| {
-                    if let Constant::Str(s) = x {
-                        s.as_str()
-                    } else {
-                        // We checked the type of the constant above
-                        unreachable!()
-                    }
-                }).collect();
-            if !check_path(cx, &path[..]);
-            then {
-                span_lint(cx, INVALID_PATHS, item.span, "invalid path");
-            }
-        }
-    }
-}