From ff5b82282c626a70871e98b536b2a9d7d353d1e1 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Sun, 5 May 2024 15:14:47 +0200 Subject: [PATCH] Now? --- clippy_utils/src/ty.rs | 120 ++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 7ba7013f2112..6c6c9a8bdaa1 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -4,7 +4,7 @@ use core::ops::ControlFlow; use itertools::Itertools; -use mid::ty::ParamTy; +use ty::ParamTy; use rustc_ast::ast::Mutability; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; @@ -31,7 +31,7 @@ use rustc_trait_selection::traits::{Obligation, ObligationCause}; use std::assert_matches::debug_assert_matches; use std::collections::hash_map::Entry; use std::iter; -use {rustc_hir as hir, rustc_middle as mid}; +use rustc_hir as hir; use crate::{def_path_def_ids, match_def_path, path_res}; @@ -972,7 +972,7 @@ pub fn for_each_region<'tcx>(ty: Ty<'tcx>, f: impl FnMut(Region<'tcx>)) { // } // impl<'tcx, F: FnMut(DefId)> TypeVisitor> for V { // fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { -// if let mid::ty::TyKind::Param(param) = ty.kind() +// if let ty::Param(param) = ty.kind() // { // (self.f)(def_id); // } @@ -984,41 +984,41 @@ pub fn for_each_region<'tcx>(ty: Ty<'tcx>, f: impl FnMut(Region<'tcx>)) { /// This function calls the given function `f` for every region on a reference. /// For example `&'a Type<'b>` would call the function once for `'a`. -pub fn for_each_ref_region<'tcx>(ty: Ty<'tcx>, f: &mut impl FnMut(Region<'tcx>, mid::ty::Ty<'tcx>, Mutability)) { +pub fn for_each_ref_region<'tcx>(ty: Ty<'tcx>, f: &mut impl FnMut(Region<'tcx>, Ty<'tcx>, Mutability)) { match ty.kind() { - mid::ty::TyKind::Tuple(next_tys) => next_tys.iter().for_each(|next_ty| for_each_ref_region(next_ty, f)), - mid::ty::TyKind::Pat(next_ty, _) - | mid::ty::TyKind::RawPtr(next_ty, _) - | mid::ty::TyKind::Slice(next_ty) - | mid::ty::TyKind::Array(next_ty, _) => for_each_ref_region(*next_ty, f), - mid::ty::TyKind::Ref(region, ty, mutability) => { + ty::Tuple(next_tys) => next_tys.iter().for_each(|next_ty| for_each_ref_region(next_ty, f)), + ty::Pat(next_ty, _) + | ty::RawPtr(next_ty, _) + | ty::Slice(next_ty) + | ty::Array(next_ty, _) => for_each_ref_region(*next_ty, f), + ty::Ref(region, ty, mutability) => { f(*region, *ty, *mutability); for_each_ref_region(*ty, f); }, // All of these are either uninteresting or we don't want to visit their generics - mid::ty::TyKind::Bool - | mid::ty::TyKind::Char - | mid::ty::TyKind::Int(_) - | mid::ty::TyKind::Uint(_) - | mid::ty::TyKind::Float(_) - | mid::ty::TyKind::Adt(_, _) - | mid::ty::TyKind::Foreign(_) - | mid::ty::TyKind::Str - | mid::ty::TyKind::FnDef(_, _) - | mid::ty::TyKind::FnPtr(_) - | mid::ty::TyKind::Dynamic(_, _, _) - | mid::ty::TyKind::Closure(_, _) - | mid::ty::TyKind::CoroutineClosure(_, _) - | mid::ty::TyKind::Coroutine(_, _) - | mid::ty::TyKind::CoroutineWitness(_, _) - | mid::ty::TyKind::Never - | mid::ty::TyKind::Alias(_, _) - | mid::ty::TyKind::Param(_) - | mid::ty::TyKind::Bound(_, _) - | mid::ty::TyKind::Placeholder(_) - | mid::ty::TyKind::Infer(_) - | mid::ty::TyKind::Error(_) => {}, + ty::Bool + | ty::Char + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Adt(_, _) + | ty::Foreign(_) + | ty::Str + | ty::FnDef(_, _) + | ty::FnPtr(_) + | ty::Dynamic(_, _, _) + | ty::Closure(_, _) + | ty::CoroutineClosure(_, _) + | ty::Coroutine(_, _) + | ty::CoroutineWitness(_, _) + | ty::Never + | ty::Alias(_, _) + | ty::Param(_) + | ty::Bound(_, _) + | ty::Placeholder(_) + | ty::Infer(_) + | ty::Error(_) => {}, } } @@ -1026,16 +1026,16 @@ pub fn for_each_ref_region<'tcx>(ty: Ty<'tcx>, f: &mut impl FnMut(Region<'tcx>, /// For example `&'a Type<'b>` would call the function once for `'a`. pub fn for_each_param_ty(ty: Ty<'_>, f: &mut impl FnMut(ParamTy)) { match ty.kind() { - mid::ty::TyKind::Tuple(next_tys) => next_tys.iter().for_each(|next_ty| for_each_param_ty(next_ty, f)), - mid::ty::TyKind::Pat(next_ty, _) - | mid::ty::TyKind::RawPtr(next_ty, _) - | mid::ty::TyKind::Slice(next_ty) - | mid::ty::TyKind::Array(next_ty, _) => for_each_param_ty(*next_ty, f), - mid::ty::TyKind::Ref(_region, ty, _mutability) => { + ty::Tuple(next_tys) => next_tys.iter().for_each(|next_ty| for_each_param_ty(next_ty, f)), + ty::Pat(next_ty, _) + | ty::RawPtr(next_ty, _) + | ty::Slice(next_ty) + | ty::Array(next_ty, _) => for_each_param_ty(*next_ty, f), + ty::Ref(_region, ty, _mutability) => { for_each_param_ty(*ty, f); }, - mid::ty::TyKind::Param(param) => f(*param), - mid::ty::TyKind::Adt(_, generics) => { + ty::Param(param) => f(*param), + ty::Adt(_, generics) => { generics .iter() .filter_map(rustc_middle::ty::GenericArg::as_type) @@ -1043,26 +1043,26 @@ pub fn for_each_param_ty(ty: Ty<'_>, f: &mut impl FnMut(ParamTy)) { }, // All of these are either uninteresting or we don't want to visit their generics - mid::ty::TyKind::Bool - | mid::ty::TyKind::Char - | mid::ty::TyKind::Int(_) - | mid::ty::TyKind::Uint(_) - | mid::ty::TyKind::Float(_) - | mid::ty::TyKind::Foreign(_) - | mid::ty::TyKind::Str - | mid::ty::TyKind::FnDef(_, _) - | mid::ty::TyKind::FnPtr(_) - | mid::ty::TyKind::Dynamic(_, _, _) - | mid::ty::TyKind::Closure(_, _) - | mid::ty::TyKind::CoroutineClosure(_, _) - | mid::ty::TyKind::Coroutine(_, _) - | mid::ty::TyKind::CoroutineWitness(_, _) - | mid::ty::TyKind::Never - | mid::ty::TyKind::Alias(_, _) - | mid::ty::TyKind::Bound(_, _) - | mid::ty::TyKind::Placeholder(_) - | mid::ty::TyKind::Infer(_) - | mid::ty::TyKind::Error(_) => {}, + ty::Bool + | ty::Char + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Foreign(_) + | ty::Str + | ty::FnDef(_, _) + | ty::FnPtr(_) + | ty::Dynamic(_, _, _) + | ty::Closure(_, _) + | ty::CoroutineClosure(_, _) + | ty::Coroutine(_, _) + | ty::CoroutineWitness(_, _) + | ty::Never + | ty::Alias(_, _) + | ty::Bound(_, _) + | ty::Placeholder(_) + | ty::Infer(_) + | ty::Error(_) => {}, } }