From bc993bbe85a231a7aa0414c6bea65d31d7375277 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 6 Apr 2021 12:40:11 +0200 Subject: Remove TyExt::dyn_trait_ref --- crates/hir_ty/src/chalk_ext.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs index b101e904f..8e8a1aa48 100644 --- a/crates/hir_ty/src/chalk_ext.rs +++ b/crates/hir_ty/src/chalk_ext.rs @@ -29,9 +29,6 @@ pub trait TyExt { fn strip_references(&self) -> &Ty; - /// If this is a `dyn Trait` type, this returns the `Trait` part. - fn dyn_trait_ref(&self) -> Option<&TraitRef>; - /// If this is a `dyn Trait`, returns that trait. fn dyn_trait(&self) -> Option; @@ -123,8 +120,8 @@ impl TyExt for Ty { } } - fn dyn_trait_ref(&self) -> Option<&TraitRef> { - match self.kind(&Interner) { + fn dyn_trait(&self) -> Option { + let trait_ref = match self.kind(&Interner) { TyKind::Dyn(dyn_ty) => dyn_ty.bounds.skip_binders().interned().get(0).and_then(|b| { match b.skip_binders() { WhereClause::Implemented(trait_ref) => Some(trait_ref), @@ -132,11 +129,8 @@ impl TyExt for Ty { } }), _ => None, - } - } - - fn dyn_trait(&self) -> Option { - self.dyn_trait_ref().map(|it| it.trait_id).map(from_chalk_trait_id) + }?; + Some(from_chalk_trait_id(trait_ref.trait_id)) } fn strip_references(&self) -> &Ty { -- cgit v1.2.3