aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-08-12 20:43:57 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-08-12 20:43:57 +0100
commit2c65a059840dd2092a00e90337a8221cd832c456 (patch)
treefa1f8c46158271eb859928ed9da3eb389f861c09 /crates/ra_syntax
parent0cf48e48d75d267bfa38ff1319e7f7c0468fb53f (diff)
parent5af9691dc9132db61b50c4e90cdeda6fea0c5dd9 (diff)
Merge #1677
1677: Associated types r=flodiebold a=flodiebold This implements basic support for (fully qualified) associated type projections: - handle fully qualified paths like `<T as Trait>::AssocType` (basically desugaring to something like `Trait<Self=T>::AssocType`) - lower these to a new `Ty::Projection` enum variant - also introduce `Ty::UnselectedProjection` for cases like `T::AssocType` where the trait from which the type comes isn't specified, but these aren't handled further so far - in inference, normalize these projections using Chalk: basically, when encountering a type e.g. from a type annotation or signature, we replace these `Ty::Projection`s by type variables and add obligations to normalize the associated type Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-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 d4873b39a..2a59cf653 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -91,6 +91,7 @@ impl ast::Attr {
91#[derive(Debug, Clone, PartialEq, Eq)] 91#[derive(Debug, Clone, PartialEq, Eq)]
92pub enum PathSegmentKind { 92pub enum PathSegmentKind {
93 Name(ast::NameRef), 93 Name(ast::NameRef),
94 Type { type_ref: Option<ast::TypeRef>, trait_ref: Option<ast::PathType> },
94 SelfKw, 95 SelfKw,
95 SuperKw, 96 SuperKw,
96 CrateKw, 97 CrateKw,
@@ -112,6 +113,15 @@ impl ast::PathSegment {
112 T![self] => PathSegmentKind::SelfKw, 113 T![self] => PathSegmentKind::SelfKw,
113 T![super] => PathSegmentKind::SuperKw, 114 T![super] => PathSegmentKind::SuperKw,
114 T![crate] => PathSegmentKind::CrateKw, 115 T![crate] => PathSegmentKind::CrateKw,
116 T![<] => {
117 // <T> or <T as Trait>
118 // T is any TypeRef, Trait has to be a PathType
119 let mut type_refs =
120 self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind()));
121 let type_ref = type_refs.next().and_then(ast::TypeRef::cast);
122 let trait_ref = type_refs.next().and_then(ast::PathType::cast);
123 PathSegmentKind::Type { type_ref, trait_ref }
124 }
115 _ => return None, 125 _ => return None,
116 } 126 }
117 }; 127 };