]> git.lizzy.rs Git - rust.git/blob - tests/ui-internal/match_type_on_diag_item.rs
Use relative deps path
[rust.git] / tests / ui-internal / match_type_on_diag_item.rs
1 #![deny(clippy::internal)]
2 #![feature(rustc_private)]
3
4 extern crate clippy_utils;
5 extern crate rustc_hir;
6 extern crate rustc_lint;
7 extern crate rustc_middle;
8
9 #[macro_use]
10 extern crate rustc_session;
11 use clippy_utils::{paths, ty::match_type};
12 use rustc_hir::Expr;
13 use rustc_lint::{LateContext, LateLintPass};
14 use rustc_middle::ty::Ty;
15
16 declare_lint! {
17     pub TEST_LINT,
18     Warn,
19     ""
20 }
21
22 declare_lint_pass!(Pass => [TEST_LINT]);
23
24 static OPTION: [&str; 3] = ["core", "option", "Option"];
25
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);
29
30         let _ = match_type(cx, ty, &OPTION);
31         let _ = match_type(cx, ty, &["core", "result", "Result"]);
32
33         let rc_path = &["alloc", "rc", "Rc"];
34         let _ = clippy_utils::ty::match_type(cx, ty, rc_path);
35     }
36 }
37
38 fn main() {}