From 360bdf653b91f5232a5584c7f4b13960caa48dda Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Tue, 14 Apr 2020 16:06:57 -0700 Subject: fix false positive for enum with no variants --- crates/ra_hir_ty/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/ra_hir_ty/src/lib.rs') diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 18f74d3b1..2677f3af2 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -680,6 +680,16 @@ impl Ty { } } + pub fn strip_references(&self) -> &Ty { + let mut t: &Ty = self; + + while let Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(_mutability), parameters }) = t { + t = parameters.as_single(); + } + + t + } + pub fn as_adt(&self) -> Option<(AdtId, &Substs)> { match self { Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => { -- cgit v1.2.3