diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-09 19:21:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-09 19:21:17 +0100 |
| commit | 8f00ffc901badd27e7d58641daecb30b8cd76a74 (patch) | |
| tree | 0e2ee84c7547d469c7668fa811a0cfeb2f1d9a66 /clippy_utils/src/ty.rs | |
| parent | e0caf3980711f8f911f45a6710aa5f2560aaafa2 (diff) | |
| parent | f3b3d23416f1da77103bb74788f23b4f9c78ee7e (diff) | |
Rollup merge of #120806 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
Diffstat (limited to 'clippy_utils/src/ty.rs')
| -rw-r--r-- | clippy_utils/src/ty.rs | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 11bb16ff6c5..6762c883005 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -1000,35 +1000,6 @@ pub fn adt_and_variant_of_res<'tcx>(cx: &LateContext<'tcx>, res: Res) -> Option< } } -/// Checks if the type is a type parameter implementing `FnOnce`, but not `FnMut`. -pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tcx [ty::Clause<'_>]) -> bool { - let ty::Param(ty) = *ty.kind() else { - return false; - }; - let lang = tcx.lang_items(); - let (Some(fn_once_id), Some(fn_mut_id), Some(fn_id)) = (lang.fn_once_trait(), lang.fn_mut_trait(), lang.fn_trait()) - else { - return false; - }; - predicates - .iter() - .try_fold(false, |found, p| { - if let ty::ClauseKind::Trait(p) = p.kind().skip_binder() - && let ty::Param(self_ty) = p.trait_ref.self_ty().kind() - && ty.index == self_ty.index - { - // This should use `super_traits_of`, but that's a private function. - if p.trait_ref.def_id == fn_once_id { - return Some(true); - } else if p.trait_ref.def_id == fn_mut_id || p.trait_ref.def_id == fn_id { - return None; - } - } - Some(found) - }) - .unwrap_or(false) -} - /// Comes up with an "at least" guesstimate for the type's size, not taking into /// account the layout of type parameters. pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 { |
