Auto merge of #13115 - tesuji:rm-dup-peels, r=dswij

Remove duplicated `peel_middle_ty_refs`

TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too?

changelog: none
This commit is contained in:
bors 2024-08-03 07:32:30 +00:00
commit 1ea827fa03
7 changed files with 22 additions and 35 deletions

View file

@ -525,19 +525,6 @@ pub fn needs_ordered_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
needs_ordered_drop_inner(cx, ty, &mut FxHashSet::default())
}
/// Peels off all references on the type. Returns the underlying type and the number of references
/// removed.
pub fn peel_mid_ty_refs(ty: Ty<'_>) -> (Ty<'_>, usize) {
fn peel(ty: Ty<'_>, count: usize) -> (Ty<'_>, usize) {
if let ty::Ref(_, ty, _) = ty.kind() {
peel(*ty, count + 1)
} else {
(ty, count)
}
}
peel(ty, 0)
}
/// Peels off all references on the type. Returns the underlying type, the number of references
/// removed, and whether the pointer is ultimately mutable or not.
pub fn peel_mid_ty_refs_is_mutable(ty: Ty<'_>) -> (Ty<'_>, usize, Mutability) {