7709: Added the check for return type of len function.

This commit is contained in:
Chetan Khilosiya 2021-03-16 01:16:59 +05:30
parent c0a2b4e826
commit 714836959b
2 changed files with 33 additions and 9 deletions

View file

@ -1631,6 +1631,13 @@ impl Type {
matches!(self.ty.value.interned(&Interner), TyKind::Ref(hir_ty::Mutability::Mut, ..))
}
pub fn is_usize(&self) -> bool {
matches!(
self.ty.value.interned(&Interner),
TyKind::Scalar(Scalar::Uint(hir_ty::primitive::UintTy::Usize))
)
}
pub fn remove_ref(&self) -> Option<Type> {
match &self.ty.value.interned(&Interner) {
TyKind::Ref(.., ty) => Some(self.derived(ty.clone())),