aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs2
-rw-r--r--crates/ra_hir_def/src/path.rs2
-rw-r--r--crates/ra_hir_def/src/path/lower.rs46
3 files changed, 27 insertions, 23 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 0cacc63ef..6bedc6b56 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -337,7 +337,7 @@ impl ExprCollector<'_> {
337 }; 337 };
338 let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); 338 let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
339 let generic_args = 339 let generic_args =
340 e.type_arg_list().and_then(|it| GenericArgs::from_ast(&self.ctx(), it)); 340 e.generic_arg_list().and_then(|it| GenericArgs::from_ast(&self.ctx(), it));
341 self.alloc_expr( 341 self.alloc_expr(
342 Expr::MethodCall { receiver, method_name, args, generic_args }, 342 Expr::MethodCall { receiver, method_name, args, generic_args },
343 syntax_ptr, 343 syntax_ptr,
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 68b9f89c3..cc1726e9e 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -258,7 +258,7 @@ impl<'a> PathSegments<'a> {
258} 258}
259 259
260impl GenericArgs { 260impl GenericArgs {
261 pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::TypeArgList) -> Option<GenericArgs> { 261 pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::GenericArgList) -> Option<GenericArgs> {
262 lower::lower_generic_args(lower_ctx, node) 262 lower::lower_generic_args(lower_ctx, node)
263 } 263 }
264 264
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index 257f9a033..d09fc66e4 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -41,7 +41,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
41 match hygiene.name_ref_to_name(name_ref) { 41 match hygiene.name_ref_to_name(name_ref) {
42 Either::Left(name) => { 42 Either::Left(name) => {
43 let args = segment 43 let args = segment
44 .type_arg_list() 44 .generic_arg_list()
45 .and_then(|it| lower_generic_args(&ctx, it)) 45 .and_then(|it| lower_generic_args(&ctx, it))
46 .or_else(|| { 46 .or_else(|| {
47 lower_generic_args_from_fn_path( 47 lower_generic_args_from_fn_path(
@@ -148,33 +148,37 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
148 148
149pub(super) fn lower_generic_args( 149pub(super) fn lower_generic_args(
150 lower_ctx: &LowerCtx, 150 lower_ctx: &LowerCtx,
151 node: ast::TypeArgList, 151 node: ast::GenericArgList,
152) -> Option<GenericArgs> { 152) -> Option<GenericArgs> {
153 let mut args = Vec::new(); 153 let mut args = Vec::new();
154 for type_arg in node.type_args() {
155 let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.ty());
156 args.push(GenericArg::Type(type_ref));
157 }
158 // lifetimes ignored for now
159 let mut bindings = Vec::new(); 154 let mut bindings = Vec::new();
160 for assoc_type_arg in node.assoc_type_args() { 155 for generic_arg in node.generic_args() {
161 let assoc_type_arg: ast::AssocTypeArg = assoc_type_arg; 156 match generic_arg {
162 if let Some(name_ref) = assoc_type_arg.name_ref() { 157 ast::GenericArg::TypeArg(type_arg) => {
163 let name = name_ref.as_name(); 158 let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.ty());
164 let type_ref = assoc_type_arg.ty().map(|it| TypeRef::from_ast(lower_ctx, it)); 159 args.push(GenericArg::Type(type_ref));
165 let bounds = if let Some(l) = assoc_type_arg.type_bound_list() { 160 }
166 l.bounds().map(|it| TypeBound::from_ast(lower_ctx, it)).collect() 161 ast::GenericArg::AssocTypeArg(assoc_type_arg) => {
167 } else { 162 if let Some(name_ref) = assoc_type_arg.name_ref() {
168 Vec::new() 163 let name = name_ref.as_name();
169 }; 164 let type_ref = assoc_type_arg.ty().map(|it| TypeRef::from_ast(lower_ctx, it));
170 bindings.push(AssociatedTypeBinding { name, type_ref, bounds }); 165 let bounds = if let Some(l) = assoc_type_arg.type_bound_list() {
166 l.bounds().map(|it| TypeBound::from_ast(lower_ctx, it)).collect()
167 } else {
168 Vec::new()
169 };
170 bindings.push(AssociatedTypeBinding { name, type_ref, bounds });
171 }
172 }
173 // Lifetimes and constants are ignored for now.
174 ast::GenericArg::LifetimeArg(_) | ast::GenericArg::ConstArg(_) => (),
171 } 175 }
172 } 176 }
177
173 if args.is_empty() && bindings.is_empty() { 178 if args.is_empty() && bindings.is_empty() {
174 None 179 return None;
175 } else {
176 Some(GenericArgs { args, has_self_type: false, bindings })
177 } 180 }
181 Some(GenericArgs { args, has_self_type: false, bindings })
178} 182}
179 183
180/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y) 184/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)