1
Fork 0

Rollup merge of #101492 - TaKO8Ki:suggest-adding-array-length-to-ref-to-array, r=oli-obk

Suggest adding array lengths to references to arrays if possible

ref: https://github.com/rust-lang/rust/pull/100590#pullrequestreview-1096851146
This commit is contained in:
Dylan DPC 2022-09-09 22:02:16 +05:30 committed by GitHub
commit bef48f9314
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 120 additions and 29 deletions

View file

@ -2401,6 +2401,14 @@ impl<'hir> Ty<'hir> {
_ => None,
}
}
pub fn peel_refs(&self) -> &Self {
let mut final_ty = self;
while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind {
final_ty = &ty;
}
final_ty
}
}
/// Not represented directly in the AST; referred to by name through a `ty_path`.