From 9b7ff501a65f132ee4bfdea0aac4807e5a7cc877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Mon, 18 Mar 2019 12:43:10 +0100 Subject: [PATCH] Replace most of ty:Ty with Ty --- clippy_lints/src/consts.rs | 6 +++--- clippy_lints/src/eta_reduction.rs | 8 ++++---- clippy_lints/src/fallible_impl_from.rs | 4 ++-- clippy_lints/src/map_unit_fn.rs | 4 ++-- clippy_lints/src/methods/mod.rs | 4 ++-- clippy_lints/src/non_copy_const.rs | 4 ++-- clippy_lints/src/redundant_clone.rs | 4 ++-- clippy_lints/src/utils/mod.rs | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 8d71eb54277..61bfc78b3de 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -117,7 +117,7 @@ impl Hash for Constant { } impl Constant { - pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: ty::Ty<'_>, left: &Self, right: &Self) -> Option { + pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: Ty<'_>, left: &Self, right: &Self) -> Option { match (left, right) { (&Constant::Str(ref ls), &Constant::Str(ref rs)) => Some(ls.cmp(rs)), (&Constant::Char(ref l), &Constant::Char(ref r)) => Some(l.cmp(r)), @@ -268,7 +268,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { } #[allow(clippy::cast_possible_wrap)] - fn constant_not(&self, o: &Constant, ty: ty::Ty<'_>) -> Option { + fn constant_not(&self, o: &Constant, ty: Ty<'_>) -> Option { use self::Constant::*; match *o { Bool(b) => Some(Bool(!b)), @@ -284,7 +284,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { } } - fn constant_negate(&self, o: &Constant, ty: ty::Ty<'_>) -> Option { + fn constant_negate(&self, o: &Constant, ty: Ty<'_>) -> Option { use self::Constant::*; match *o { Int(value) => { diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 30436716ff9..e0fa9e5e929 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -1,7 +1,7 @@ use if_chain::if_chain; use rustc::hir::*; use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass}; -use rustc::ty; +use rustc::ty::{self, Ty}; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; @@ -147,7 +147,7 @@ fn get_ufcs_type_name( }) } -fn match_borrow_depth(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool { +fn match_borrow_depth(lhs: Ty<'_>, rhs: Ty<'_>) -> bool { match (&lhs.sty, &rhs.sty) { (ty::Ref(_, t1, _), ty::Ref(_, t2, _)) => match_borrow_depth(&t1, &t2), (l, r) => match (l, r) { @@ -157,7 +157,7 @@ fn match_borrow_depth(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool { } } -fn match_types(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool { +fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool { match (&lhs.sty, &rhs.sty) { (ty::Bool, ty::Bool) | (ty::Char, ty::Char) @@ -172,7 +172,7 @@ fn match_types(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool { } } -fn get_type_name(cx: &LateContext<'_, '_>, ty: ty::Ty<'_>) -> String { +fn get_type_name(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> String { match ty.sty { ty::Adt(t, _) => cx.tcx.def_path_str(t.did), ty::Ref(_, r, _) => get_type_name(cx, &r), diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index f8158bd16f7..bed5964fb32 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -3,7 +3,7 @@ use crate::utils::{is_expn_of, match_def_path, method_chain_args, span_lint_and_ use if_chain::if_chain; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::ty; +use rustc::ty::{self, Ty}; use rustc::{declare_tool_lint, lint_array}; use syntax_pos::Span; @@ -132,7 +132,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it } } -fn match_type<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, ty: ty::Ty<'_>, path: &[&str]) -> bool { +fn match_type<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'_>, path: &[&str]) -> bool { match ty.sty { ty::Adt(adt, _) => match_def_path(tcx, adt.did, path), _ => false, diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index f96418201da..22c336b8c47 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -3,7 +3,7 @@ use crate::utils::{in_macro, iter_input_pats, match_type, method_chain_args, sni use if_chain::if_chain; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::ty; +use rustc::ty::{self, Ty}; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use syntax::source_map::Span; @@ -87,7 +87,7 @@ impl LintPass for Pass { } } -fn is_unit_type(ty: ty::Ty<'_>) -> bool { +fn is_unit_type(ty: Ty<'_>) -> bool { match ty.sty { ty::Tuple(slice) => slice.is_empty(), ty::Never => true, diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index d7ab3505765..3e7403a3fe2 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -2196,7 +2196,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re fn ty_has_iter_method( cx: &LateContext<'_, '_>, - self_ref_ty: ty::Ty<'_>, + self_ref_ty: Ty<'_>, ) -> Option<(&'static Lint, &'static str, &'static str)> { if let Some(ty_name) = has_iter_method(cx, self_ref_ty) { let lint = match ty_name { @@ -2217,7 +2217,7 @@ fn ty_has_iter_method( } } -fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: ty::Ty<'_>, method_span: Span) { +fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_>, method_span: Span) { if !match_trait_method(cx, expr, &paths::INTO_ITERATOR) { return; } diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 9c184e8c54b..8b7b6b6c42c 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -8,7 +8,7 @@ use rustc::hir::def::Def; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, Lint, LintArray, LintPass}; use rustc::ty::adjustment::Adjust; -use rustc::ty::{self, TypeFlags}; +use rustc::ty::{Ty, TypeFlags}; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use rustc_typeck::hir_ty_to_ty; @@ -108,7 +108,7 @@ impl Source { } } -fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, source: Source) { +fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: Source) { if ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SP) || is_copy(cx, ty) { // An `UnsafeCell` is `!Copy`, and an `UnsafeCell` is also the only type which // is `!Freeze`, thus if our type is `Copy` we can be sure it must be `Freeze` diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 9a17e593fdf..086c76c20b6 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -12,7 +12,7 @@ use rustc::mir::{ visit::{MutatingUseContext, PlaceContext, Visitor}, TerminatorKind, }; -use rustc::ty; +use rustc::ty::{self, Ty}; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use std::convert::TryFrom; @@ -225,7 +225,7 @@ fn is_call_with_ref_arg<'tcx>( cx: &LateContext<'_, 'tcx>, mir: &'tcx mir::Mir<'tcx>, kind: &'tcx mir::TerminatorKind<'tcx>, -) -> Option<(def_id::DefId, mir::Local, ty::Ty<'tcx>, Option<&'tcx mir::Place<'tcx>>)> { +) -> Option<(def_id::DefId, mir::Local, Ty<'tcx>, Option<&'tcx mir::Place<'tcx>>)> { if_chain! { if let TerminatorKind::Call { func, args, destination, .. } = kind; if args.len() == 1; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index c91065e5c1c..7ffe226f5fc 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -1080,7 +1080,7 @@ pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_, '_, '_>, node: HirId) } /// Returns true if ty has `iter` or `iter_mut` methods -pub fn has_iter_method(cx: &LateContext<'_, '_>, probably_ref_ty: ty::Ty<'_>) -> Option<&'static str> { +pub fn has_iter_method(cx: &LateContext<'_, '_>, probably_ref_ty: Ty<'_>) -> Option<&'static str> { // FIXME: instead of this hard-coded list, we should check if `::iter` // exists and has the desired signature. Unfortunately FnCtxt is not exported // so we can't use its `lookup_method` method.