From e54f61dbdb9183cc5fdf58cd098dd783178bc3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 19 Sep 2022 12:45:38 +0300 Subject: [PATCH] Try to fix crash introduced in #13147 --- crates/hir-ty/src/method_resolution.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs index dbf27500320..41fcef73d9b 100644 --- a/crates/hir-ty/src/method_resolution.rs +++ b/crates/hir-ty/src/method_resolution.rs @@ -989,17 +989,18 @@ fn iterate_inherent_methods( )?; } TyKind::Dyn(_) => { - let principal_trait = self_ty.dyn_trait().unwrap(); - let traits = all_super_traits(db.upcast(), principal_trait); - iterate_inherent_trait_methods( - self_ty, - table, - name, - receiver_ty, - receiver_adjustments.clone(), - callback, - traits.into_iter(), - )?; + if let Some(principal_trait) = self_ty.dyn_trait() { + let traits = all_super_traits(db.upcast(), principal_trait); + iterate_inherent_trait_methods( + self_ty, + table, + name, + receiver_ty, + receiver_adjustments.clone(), + callback, + traits.into_iter(), + )?; + } } _ => {} }