]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/clippy_lints/src/types/linked_list.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / clippy_lints / src / types / linked_list.rs
diff --git a/src/tools/clippy/clippy_lints/src/types/linked_list.rs b/src/tools/clippy/clippy_lints/src/types/linked_list.rs
new file mode 100644 (file)
index 0000000..47eb4ed
--- /dev/null
@@ -0,0 +1,22 @@
+use rustc_hir::{self as hir, def_id::DefId};
+use rustc_lint::LateContext;
+
+use crate::utils::{match_def_path, paths, span_lint_and_help};
+
+use super::LINKEDLIST;
+
+pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, def_id: DefId) -> bool {
+    if match_def_path(cx, def_id, &paths::LINKED_LIST) {
+        span_lint_and_help(
+            cx,
+            LINKEDLIST,
+            hir_ty.span,
+            "you seem to be using a `LinkedList`! Perhaps you meant some other data structure?",
+            None,
+            "a `VecDeque` might work",
+        );
+        true
+    } else {
+        false
+    }
+}