From 714836959be857e2fbd9c497974055deb2a91f9b Mon Sep 17 00:00:00 2001 From: Chetan Khilosiya Date: Tue, 16 Mar 2021 01:16:59 +0530 Subject: 7709: Added the check for return type of len function. --- crates/hir/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index c5161dadd..1a1454068 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -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 { match &self.ty.value.interned(&Interner) { TyKind::Ref(.., ty) => Some(self.derived(ty.clone())), -- cgit v1.2.3 From 847ec9e84049fb51b0d8d9b3e7b167764fb93d9d Mon Sep 17 00:00:00 2001 From: Chetan Khilosiya Date: Tue, 16 Mar 2021 01:58:21 +0530 Subject: 7709: Import changes. --- crates/hir/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 1a1454068..52939e990 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -52,6 +52,7 @@ use hir_ty::{ autoderef, display::{write_bounds_like_dyn_trait_with_prefix, HirDisplayError, HirFormatter}, method_resolution::{self, TyFingerprint}, + primitive::UintTy, to_assoc_type_id, traits::{FnTrait, Solution, SolutionVariables}, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, DebruijnIndex, GenericPredicate, @@ -1632,10 +1633,7 @@ impl Type { } pub fn is_usize(&self) -> bool { - matches!( - self.ty.value.interned(&Interner), - TyKind::Scalar(Scalar::Uint(hir_ty::primitive::UintTy::Usize)) - ) + matches!(self.ty.value.interned(&Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize))) } pub fn remove_ref(&self) -> Option { -- cgit v1.2.3