Auto merge of #13257 - rust-lang:revert-13147-fix/dyn-ty-inherent-methods, r=lnicola
fix: Fix a crash introduced in #13147
Reverts rust-lang/rust-analyzer#13147
https://github.com/rust-lang/rust-analyzer/actions/runs/3041499441/jobs/4898678721#step:18:62
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index dbf2750..41fcef7 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -989,17 +989,18 @@
)?;
}
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(),
+ )?;
+ }
}
_ => {}
}