diff options
author | Aleksey Kladov <[email protected]> | 2020-07-31 17:41:37 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-31 17:41:37 +0100 |
commit | 040b4c800d5279e77a6825fc90cb2921d26c7f95 (patch) | |
tree | 17de1c83aa3d392902777c9eebbbb17f14b05e12 /crates/ra_assists/src | |
parent | d21b5db891d605c7c10118daca1f06c09c14b07e (diff) |
Fix GenericArgs grammar
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/ast_transform.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index e23331773..0a7be87a0 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs | |||
@@ -79,19 +79,25 @@ impl<'a> SubstituteTypeParams<'a> { | |||
79 | }; | 79 | }; |
80 | 80 | ||
81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the | 81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the |
82 | // trait ref, and then go from the types in the substs back to the syntax) | 82 | // trait ref, and then go from the types in the substs back to the syntax). |
83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { | 83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { |
84 | let target_trait = impl_def.target_trait()?; | 84 | let target_trait = impl_def.target_trait()?; |
85 | let path_type = match target_trait { | 85 | let path_type = match target_trait { |
86 | ast::Type::PathType(path) => path, | 86 | ast::Type::PathType(path) => path, |
87 | _ => return None, | 87 | _ => return None, |
88 | }; | 88 | }; |
89 | let type_arg_list = path_type.path()?.segment()?.generic_arg_list()?; | 89 | let generic_arg_list = path_type.path()?.segment()?.generic_arg_list()?; |
90 | |||
90 | let mut result = Vec::new(); | 91 | let mut result = Vec::new(); |
91 | for type_arg in type_arg_list.type_args() { | 92 | for generic_arg in generic_arg_list.generic_args() { |
92 | let type_arg: ast::TypeArg = type_arg; | 93 | match generic_arg { |
93 | result.push(type_arg.ty()?); | 94 | ast::GenericArg::TypeArg(type_arg) => result.push(type_arg.ty()?), |
95 | ast::GenericArg::AssocTypeArg(_) | ||
96 | | ast::GenericArg::LifetimeArg(_) | ||
97 | | ast::GenericArg::ConstArg(_) => (), | ||
98 | } | ||
94 | } | 99 | } |
100 | |||
95 | Some(result) | 101 | Some(result) |
96 | } | 102 | } |
97 | } | 103 | } |