3 #![deny(clippy::internal)]
4 #![feature(rustc_private)]
6 extern crate clippy_utils;
8 extern crate rustc_hir;
9 extern crate rustc_lint;
10 extern crate rustc_middle;
11 extern crate rustc_span;
14 use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item, match_type};
17 is_expr_path_def_path, is_path_diagnostic_item, is_res_diagnostic_ctor, is_res_lang_ctor, is_trait_method,
18 match_def_path, match_trait_method, path_res,
22 use rustc_hir::LangItem;
26 use rustc_hir::def_id::DefId;
28 use rustc_lint::LateContext;
29 use rustc_middle::ty::Ty;
31 #[allow(unused, clippy::unnecessary_def_path)]
32 static OPTION: [&str; 3] = ["core", "option", "Option"];
33 #[allow(unused, clippy::unnecessary_def_path)]
34 const RESULT: &[&str] = &["core", "result", "Result"];
36 fn _f<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, did: DefId, expr: &Expr<'_>) {
37 let _ = match_type(cx, ty, &OPTION);
38 let _ = match_type(cx, ty, RESULT);
39 let _ = match_type(cx, ty, &["core", "result", "Result"]);
41 #[allow(unused, clippy::unnecessary_def_path)]
42 let rc_path = &["alloc", "rc", "Rc"];
43 let _ = clippy_utils::ty::match_type(cx, ty, rc_path);
45 let _ = match_type(cx, ty, &paths::OPTION);
46 let _ = match_type(cx, ty, paths::RESULT);
48 let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]);
49 let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]);
51 let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]);
52 let _ = match_def_path(cx, did, &["core", "option", "Option"]);
53 let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]);
55 let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]);
57 let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]);
58 let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]);
59 let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]);