]> git.lizzy.rs Git - rust.git/blob - tests/ui-internal/match_type_on_diag_item.rs
Auto merge of #8330 - flip1995:changelog, r=llogiq
[rust.git] / tests / ui-internal / match_type_on_diag_item.rs
1 #![deny(clippy::internal)]
2 #![allow(clippy::missing_clippy_version_attribute)]
3 #![feature(rustc_private)]
4
5 extern crate clippy_utils;
6 extern crate rustc_hir;
7 extern crate rustc_lint;
8 extern crate rustc_middle;
9
10 #[macro_use]
11 extern crate rustc_session;
12 use clippy_utils::{paths, ty::match_type};
13 use rustc_hir::Expr;
14 use rustc_lint::{LateContext, LateLintPass};
15 use rustc_middle::ty::Ty;
16
17 declare_lint! {
18     pub TEST_LINT,
19     Warn,
20     ""
21 }
22
23 declare_lint_pass!(Pass => [TEST_LINT]);
24
25 static OPTION: [&str; 3] = ["core", "option", "Option"];
26
27 impl<'tcx> LateLintPass<'tcx> for Pass {
28     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr) {
29         let ty = cx.typeck_results().expr_ty(expr);
30
31         let _ = match_type(cx, ty, &OPTION);
32         let _ = match_type(cx, ty, &["core", "result", "Result"]);
33
34         let rc_path = &["alloc", "rc", "Rc"];
35         let _ = clippy_utils::ty::match_type(cx, ty, rc_path);
36     }
37 }
38
39 fn main() {}