make error emitted on impl &Trait nicer

This commit is contained in:
Ezra Shaw 2023-01-14 21:20:20 +13:00
parent ca5d92d789
commit e590b93499
No known key found for this signature in database
GPG key ID: 17CD5C2ADAE0D344
4 changed files with 154 additions and 5 deletions

View file

@ -2032,7 +2032,8 @@ impl Clone for Ty {
impl Ty {
pub fn peel_refs(&self) -> &Self {
let mut final_ty = self;
while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
while let TyKind::Ref(_, MutTy { ty, .. }) | TyKind::Ptr(MutTy { ty, .. }) = &final_ty.kind
{
final_ty = ty;
}
final_ty