diff options
author | adamrk <[email protected]> | 2020-06-20 07:42:35 +0100 |
---|---|---|
committer | adamrk <[email protected]> | 2020-06-20 07:42:35 +0100 |
commit | 38f6cdbc8a83b081ad1cef9171e28431be09db01 (patch) | |
tree | c6f30deba5f85f35950a558e5290a0cf56601fc5 /crates/ra_hir_ty/src/traits.rs | |
parent | cf870af8073e3a72fdfb1d36b017f0abd7593559 (diff) |
Make get_fn_trait a method of FnTrait
Diffstat (limited to 'crates/ra_hir_ty/src/traits.rs')
-rw-r--r-- | crates/ra_hir_ty/src/traits.rs | 14 |
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 @@ | |||
2 | use std::{panic, sync::Arc}; | 2 | use std::{panic, sync::Arc}; |
3 | 3 | ||
4 | use chalk_ir::cast::Cast; | 4 | use chalk_ir::cast::Cast; |
5 | use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId}; | 5 | use hir_def::{ |
6 | expr::ExprId, lang_item::LangItemTarget, DefWithBodyId, ImplId, TraitId, TypeAliasId, | ||
7 | }; | ||
6 | use ra_db::{impl_intern_key, salsa, CrateId}; | 8 | use ra_db::{impl_intern_key, salsa, CrateId}; |
7 | use ra_prof::profile; | 9 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | 10 | use rustc_hash::FxHashSet; |
@@ -14,7 +16,7 @@ use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, | |||
14 | use self::chalk::{from_chalk, Interner, ToChalk}; | 16 | use self::chalk::{from_chalk, Interner, ToChalk}; |
15 | 17 | ||
16 | pub(crate) mod chalk; | 18 | pub(crate) mod chalk; |
17 | pub(crate) mod builtin; | 19 | mod 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)] |