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.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 9fef9240d..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;
@@ -14,7 +16,7 @@ use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty,
14use self::chalk::{from_chalk, Interner, ToChalk}; 16use self::chalk::{from_chalk, Interner, ToChalk};
15 17
16pub(crate) mod chalk; 18pub(crate) mod chalk;
17pub(crate) mod builtin; 19mod builtin;
18 20
19// This controls the maximum size of types Chalk considers. If we set this too 21// This controls the maximum size of types Chalk considers. If we set this too
20// high, we can run into slow edge cases; if we set it too low, Chalk won't 22// high, we can run into slow edge cases; if we set it too low, Chalk won't
@@ -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)]