aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/traits.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-07-06 15:41:04 +0100
committerFlorian Diebold <[email protected]>2019-07-06 16:34:05 +0100
commit065d3987012b138b123f0544de193f8bb560b1b5 (patch)
tree029ff3c3a9beb816c3056cd38595e15f3c541998 /crates/ra_hir/src/ty/traits.rs
parent219e0e8c8d6672feaab2f19b7c3280d5967360e4 (diff)
Add trait obligations for where clauses when calling functions/methods
E.g. if we call `foo<T: Into<u32>>(x)`, that adds an obligation that `x: Into<u32>`, etc.
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,