aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-12 18:45:34 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-12 18:45:34 +0100
commit1944fc2c2b9ed5d9414afbc1b167e628d6e4e7f9 (patch)
tree50999df2191aa13204ca05f255ebe2b2105a1832 /crates/ra_syntax/src/ast
parent940c538ecf42a53e5a0e0e9ebad7267c1fe843ca (diff)
parentcbe75676b90d93e5b0ac461dce2d916cef4c0476 (diff)
Merge #1262
1262: Where clauses and other Chalk improvements r=matklad a=flodiebold This adds support for where clauses to the Chalk integration; it also adds FnDef lowering and partly handles auto traits. One thing I'm not sure about is the error handling -- what do we do if we can't resolve a trait reference in a where clause? For impls, I think it's clear we need to disregard the impl for trait solving. I've solved this for now by introducing an 'unknown trait' that has no impls, so if we encounter an unknown trait we can use that and basically get a where clause that's always false. (The alternative would be somehow not returning the impl to Chalk at all, but we would need to know that we need to do that in `impls_for_trait` already, and we don't resolve anything there.) A bit surprisingly, this has almost no impact on the type inference stats for RA, probably because of missing edge cases. Probably impl Trait support and closure support will do more. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 9cbd2c6b8..f3466c585 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -170,6 +170,10 @@ impl ast::ImplBlock {
170 let second = types.next(); 170 let second = types.next();
171 (first, second) 171 (first, second)
172 } 172 }
173
174 pub fn is_negative(&self) -> bool {
175 self.syntax().children_with_tokens().any(|t| t.kind() == EXCL)
176 }
173} 177}
174 178
175#[derive(Debug, Clone, PartialEq, Eq)] 179#[derive(Debug, Clone, PartialEq, Eq)]
@@ -348,3 +352,9 @@ impl ast::WherePred {
348 .find(|it| it.kind() == LIFETIME) 352 .find(|it| it.kind() == LIFETIME)
349 } 353 }
350} 354}
355
356impl ast::TraitDef {
357 pub fn is_auto(&self) -> bool {
358 self.syntax().children_with_tokens().any(|t| t.kind() == AUTO_KW)
359 }
360}