1 #![deny(clippy::internal)]
2 #![feature(rustc_private)]
4 extern crate clippy_utils;
5 extern crate rustc_hir;
6 extern crate rustc_lint;
7 extern crate rustc_middle;
10 extern crate rustc_session;
11 use clippy_utils::{paths, ty::match_type};
13 use rustc_lint::{LateContext, LateLintPass};
14 use rustc_middle::ty::Ty;
22 declare_lint_pass!(Pass => [TEST_LINT]);
24 static OPTION: [&str; 3] = ["core", "option", "Option"];
26 impl<'tcx> LateLintPass<'tcx> for Pass {
27 fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr) {
28 let ty = cx.typeck_results().expr_ty(expr);
30 let _ = match_type(cx, ty, &paths::VEC); // FIXME: Doesn't lint external paths
31 let _ = match_type(cx, ty, &OPTION);
32 let _ = match_type(cx, ty, &["core", "result", "Result"]);
34 let rc_path = &["alloc", "rc", "Rc"];
35 let _ = clippy_utils::ty::match_type(cx, ty, rc_path);