aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/traits.rs')
-rw-r--r--crates/ra_hir/src/ty/traits.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs
index cff4de316..23a26a971 100644
--- a/crates/ra_hir/src/ty/traits.rs
+++ b/crates/ra_hir/src/ty/traits.rs
@@ -7,7 +7,7 @@ use parking_lot::Mutex;
7use ra_prof::profile; 7use ra_prof::profile;
8use rustc_hash::FxHashSet; 8use rustc_hash::FxHashSet;
9 9
10use super::{Canonical, ProjectionTy, TraitRef, Ty}; 10use super::{Canonical, GenericPredicate, ProjectionTy, TraitRef, Ty};
11use crate::{db::HirDatabase, Crate, ImplBlock, Trait}; 11use crate::{db::HirDatabase, Crate, ImplBlock, Trait};
12 12
13use self::chalk::{from_chalk, ToChalk}; 13use self::chalk::{from_chalk, ToChalk};
@@ -78,6 +78,15 @@ pub enum Obligation {
78 // Projection(ProjectionPredicate), 78 // Projection(ProjectionPredicate),
79} 79}
80 80
81impl Obligation {
82 pub fn from_predicate(predicate: GenericPredicate) -> Option<Obligation> {
83 match predicate {
84 GenericPredicate::Implemented(trait_ref) => Some(Obligation::Trait(trait_ref)),
85 GenericPredicate::Error => None,
86 }
87 }
88}
89
81#[derive(Clone, Debug, PartialEq, Eq, Hash)] 90#[derive(Clone, Debug, PartialEq, Eq, Hash)]
82pub struct ProjectionPredicate { 91pub struct ProjectionPredicate {
83 pub projection_ty: ProjectionTy, 92 pub projection_ty: ProjectionTy,