fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1//@aux-build:paths.rs 2#![deny(clippy::internal)] 3#![feature(rustc_private)] 4 5extern crate clippy_utils; 6extern crate paths; 7extern crate rustc_hir; 8extern crate rustc_lint; 9extern crate rustc_middle; 10extern crate rustc_span; 11 12#[allow(unused)] 13use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item, match_type}; 14#[allow(unused)] 15use clippy_utils::{ 16 is_expr_path_def_path, is_path_diagnostic_item, is_res_diagnostic_ctor, is_res_lang_ctor, is_trait_method, 17 match_def_path, match_trait_method, path_res, 18}; 19 20#[allow(unused)] 21use rustc_hir::LangItem; 22#[allow(unused)] 23use rustc_span::sym; 24 25use rustc_hir::def_id::DefId; 26use rustc_hir::Expr; 27use rustc_lint::LateContext; 28use rustc_middle::ty::Ty; 29 30#[allow(unused, clippy::unnecessary_def_path)] 31static OPTION: [&str; 3] = ["core", "option", "Option"]; 32#[allow(unused, clippy::unnecessary_def_path)] 33const RESULT: &[&str] = &["core", "result", "Result"]; 34 35fn _f<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, did: DefId, expr: &Expr<'_>) { 36 let _ = is_type_diagnostic_item(cx, ty, sym::Option); 37 let _ = is_type_diagnostic_item(cx, ty, sym::Result); 38 let _ = is_type_diagnostic_item(cx, ty, sym::Result); 39 40 #[allow(unused, clippy::unnecessary_def_path)] 41 let rc_path = &["alloc", "rc", "Rc"]; 42 let _ = is_type_diagnostic_item(cx, ty, sym::Rc); 43 44 let _ = is_type_diagnostic_item(cx, ty, sym::Option); 45 let _ = is_type_diagnostic_item(cx, ty, sym::Result); 46 47 let _ = is_type_lang_item(cx, ty, LangItem::OwnedBox); 48 let _ = is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit); 49 50 let _ = cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did); 51 let _ = cx.tcx.is_diagnostic_item(sym::Option, did); 52 let _ = cx.tcx.lang_items().get(LangItem::OptionSome) == Some(did); 53 54 let _ = is_trait_method(cx, expr, sym::AsRef); 55 56 let _ = is_path_diagnostic_item(cx, expr, sym::Option); 57 let _ = path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id)); 58 let _ = is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome); 59} 60 61fn main() {}