diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/tests/ui-internal/match_type_on_diag_item.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui-internal/match_type_on_diag_item.rs b/src/tools/clippy/tests/ui-internal/match_type_on_diag_item.rs new file mode 100644 index 000000000..4b41ff15e --- /dev/null +++ b/src/tools/clippy/tests/ui-internal/match_type_on_diag_item.rs @@ -0,0 +1,39 @@ +#![deny(clippy::internal)] +#![allow(clippy::missing_clippy_version_attribute)] +#![feature(rustc_private)] + +extern crate clippy_utils; +extern crate rustc_hir; +extern crate rustc_lint; +extern crate rustc_middle; + +#[macro_use] +extern crate rustc_session; +use clippy_utils::{paths, ty::match_type}; +use rustc_hir::Expr; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::Ty; + +declare_lint! { + pub TEST_LINT, + Warn, + "" +} + +declare_lint_pass!(Pass => [TEST_LINT]); + +static OPTION: [&str; 3] = ["core", "option", "Option"]; + +impl<'tcx> LateLintPass<'tcx> for Pass { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr) { + let ty = cx.typeck_results().expr_ty(expr); + + let _ = match_type(cx, ty, &OPTION); + let _ = match_type(cx, ty, &["core", "result", "Result"]); + + let rc_path = &["alloc", "rc", "Rc"]; + let _ = clippy_utils::ty::match_type(cx, ty, rc_path); + } +} + +fn main() {} |