Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/traits.rs')
-rw-r--r--crates/hir-ty/src/traits.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs
index 3ab85c68f5..aebf59f315 100644
--- a/crates/hir-ty/src/traits.rs
+++ b/crates/hir-ty/src/traits.rs
@@ -11,6 +11,7 @@ use hir_def::{
lang_item::{LangItem, LangItemTarget},
TraitId,
};
+use hir_expand::name::{name, Name};
use stdx::panic_context;
use crate::{
@@ -187,6 +188,14 @@ impl FnTrait {
}
}
+ pub fn method_name(&self) -> Name {
+ match self {
+ FnTrait::FnOnce => name!(call_once),
+ FnTrait::FnMut => name!(call_mut),
+ FnTrait::Fn => name!(call),
+ }
+ }
+
pub fn get_id(&self, db: &dyn HirDatabase, krate: CrateId) -> Option<TraitId> {
let target = db.lang_item(krate, self.lang_item())?;
match target {