1 #![deny(clippy::internal)]
2 #![feature(rustc_private)]
4 extern crate rustc_hir;
5 extern crate rustc_lint;
6 extern crate rustc_middle;
8 extern crate rustc_session;
10 use rustc_lint::{LateContext, LateLintPass};
11 use rustc_middle::ty::Ty;
14 pub const VEC: [&str; 3] = ["alloc", "vec", "Vec"];
20 pub fn match_type(_cx: &LateContext<'_>, _ty: Ty<'_>, _path: &[&str]) -> bool {
25 use utils::match_type;
33 declare_lint_pass!(Pass => [TEST_LINT]);
35 static OPTION: [&str; 3] = ["core", "option", "Option"];
37 impl<'tcx> LateLintPass<'tcx> for Pass {
38 fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr) {
39 let ty = cx.typeck_results().expr_ty(expr);
41 let _ = match_type(cx, ty, &paths::VEC);
42 let _ = match_type(cx, ty, &OPTION);
43 let _ = match_type(cx, ty, &["core", "result", "Result"]);
45 let rc_path = &["alloc", "rc", "Rc"];
46 let _ = utils::match_type(cx, ty, rc_path);