--- /dev/null
+use rustc_hir::{self as hir, def_id::DefId};
+use rustc_lint::LateContext;
+
+use crate::utils::{match_def_path, paths, span_lint_and_help};
+
+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,
+ super::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
+ }
+}
#![allow(rustc::default_hash_types)]
mod box_vec;
+mod linked_list;
mod option_option;
mod rc_buffer;
mod redundant_allocation;
use crate::utils::sugg::Sugg;
use crate::utils::{
clip, comparisons, differing_macro_contexts, higher, in_constant, indent_of, int_bits, is_hir_ty_cfg_dependant,
- is_ty_param_diagnostic_item, is_type_diagnostic_item, match_def_path, match_path, meets_msrv, method_chain_args,
- multispan_sugg, numeric_literal::NumericLiteral, reindent_multiline, sext, snippet, snippet_opt,
- snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_help, span_lint_and_sugg,
- span_lint_and_then, unsext,
+ is_type_diagnostic_item, match_path, meets_msrv, method_chain_args, multispan_sugg,
+ numeric_literal::NumericLiteral, reindent_multiline, sext, snippet, snippet_opt, snippet_with_applicability,
+ snippet_with_macro_callsite, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then, unsext,
};
declare_clippy_lint! {
///
/// The parameter `is_local` distinguishes the context of the type; types from
/// local bindings should only be checked for the `BORROWED_BOX` lint.
- #[allow(clippy::too_many_lines)]
fn check_ty(&mut self, cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, is_local: bool) {
if hir_ty.span.from_expansion() {
return;
triggered |= rc_buffer::check(cx, hir_ty, qpath, def_id);
triggered |= vec_box::check(cx, hir_ty, qpath, def_id, self.vec_box_size_threshold);
triggered |= option_option::check(cx, hir_ty, qpath, def_id);
-
- 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",
- );
- return; // don't recurse into the type
- }
+ triggered |= linked_list::check(cx, hir_ty, def_id);
if triggered {
return;
}
},
TyKind::Rptr(ref lt, ref mut_ty) => self.check_ty_rptr(cx, hir_ty, is_local, lt, mut_ty),
- // recurse
TyKind::Slice(ref ty) | TyKind::Array(ref ty, _) | TyKind::Ptr(MutTy { ref ty, .. }) => {
self.check_ty(cx, ty, is_local)
},
use rustc_lint::LateContext;
use rustc_span::symbol::sym;
-use crate::utils::span_lint;
-
-use super::utils;
+use crate::utils::{is_ty_param_diagnostic_item, span_lint};
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
if cx.tcx.is_diagnostic_item(sym::option_type, def_id) {
- if utils::is_ty_param_diagnostic_item(cx, qpath, sym::option_type).is_some() {
+ if is_ty_param_diagnostic_item(cx, qpath, sym::option_type).is_some() {
span_lint(
cx,
super::OPTION_OPTION,