about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/hir-ty/src/method_resolution.rs23
1 files 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(),
+                )?;
+            }
         }
         _ => {}
     }