aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/traits.rs')
-rw-r--r--crates/ra_hir_ty/src/traits.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 6bc6d474c..892fbd6d1 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -2,7 +2,9 @@
2use std::{panic, sync::Arc}; 2use std::{panic, sync::Arc};
3 3
4use chalk_ir::cast::Cast; 4use chalk_ir::cast::Cast;
5use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId}; 5use hir_def::{
6 expr::ExprId, lang_item::LangItemTarget, DefWithBodyId, ImplId, TraitId, TypeAliasId,
7};
6use ra_db::{impl_intern_key, salsa, CrateId}; 8use ra_db::{impl_intern_key, salsa, CrateId};
7use ra_prof::profile; 9use ra_prof::profile;
8use rustc_hash::FxHashSet; 10use rustc_hash::FxHashSet;
@@ -298,6 +300,14 @@ impl FnTrait {
298 FnTrait::Fn => "fn", 300 FnTrait::Fn => "fn",
299 } 301 }
300 } 302 }
303
304 pub fn get_id(&self, db: &dyn HirDatabase, krate: CrateId) -> Option<TraitId> {
305 let target = db.lang_item(krate, self.lang_item_name().into())?;
306 match target {
307 LangItemTarget::TraitId(t) => Some(t),
308 _ => None,
309 }
310 }
301} 311}
302 312
303#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 313#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]