diff options
Diffstat (limited to 'crates/ra_ide_api/src/inlay_hints.rs')
-rw-r--r-- | crates/ra_ide_api/src/inlay_hints.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs index 0b3c96d26..058cd68e2 100644 --- a/crates/ra_ide_api/src/inlay_hints.rs +++ b/crates/ra_ide_api/src/inlay_hints.rs | |||
@@ -3,7 +3,7 @@ use hir::{HirDisplay, SourceAnalyzer, Ty}; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::visit::{visitor, Visitor}, | 4 | algo::visit::{visitor, Visitor}, |
5 | ast::{ | 5 | ast::{ |
6 | AstNode, ForExpr, IfExpr, LambdaExpr, LetStmt, MatchArmList, Pat, PatKind, SourceFile, | 6 | self, AstNode, ForExpr, IfExpr, LambdaExpr, LetStmt, MatchArmList, SourceFile, |
7 | TypeAscriptionOwner, WhileExpr, | 7 | TypeAscriptionOwner, WhileExpr, |
8 | }, | 8 | }, |
9 | SmolStr, SyntaxKind, SyntaxNode, TextRange, | 9 | SmolStr, SyntaxKind, SyntaxNode, TextRange, |
@@ -88,7 +88,7 @@ fn get_inlay_hints( | |||
88 | fn get_pat_type_hints( | 88 | fn get_pat_type_hints( |
89 | db: &RootDatabase, | 89 | db: &RootDatabase, |
90 | analyzer: &SourceAnalyzer, | 90 | analyzer: &SourceAnalyzer, |
91 | root_pat: Pat, | 91 | root_pat: ast::Pat, |
92 | skip_root_pat_hint: bool, | 92 | skip_root_pat_hint: bool, |
93 | ) -> Vec<InlayHint> { | 93 | ) -> Vec<InlayHint> { |
94 | let original_pat = &root_pat.clone(); | 94 | let original_pat = &root_pat.clone(); |
@@ -108,27 +108,27 @@ fn get_pat_type_hints( | |||
108 | .collect() | 108 | .collect() |
109 | } | 109 | } |
110 | 110 | ||
111 | fn get_leaf_pats(root_pat: Pat) -> Vec<Pat> { | 111 | fn get_leaf_pats(root_pat: ast::Pat) -> Vec<ast::Pat> { |
112 | let mut pats_to_process = std::collections::VecDeque::<Pat>::new(); | 112 | let mut pats_to_process = std::collections::VecDeque::<ast::Pat>::new(); |
113 | pats_to_process.push_back(root_pat); | 113 | pats_to_process.push_back(root_pat); |
114 | 114 | ||
115 | let mut leaf_pats = Vec::new(); | 115 | let mut leaf_pats = Vec::new(); |
116 | 116 | ||
117 | while let Some(maybe_leaf_pat) = pats_to_process.pop_front() { | 117 | while let Some(maybe_leaf_pat) = pats_to_process.pop_front() { |
118 | match maybe_leaf_pat.kind() { | 118 | match &maybe_leaf_pat { |
119 | PatKind::BindPat(bind_pat) => { | 119 | ast::Pat::BindPat(bind_pat) => { |
120 | if let Some(pat) = bind_pat.pat() { | 120 | if let Some(pat) = bind_pat.pat() { |
121 | pats_to_process.push_back(pat); | 121 | pats_to_process.push_back(pat); |
122 | } else { | 122 | } else { |
123 | leaf_pats.push(maybe_leaf_pat); | 123 | leaf_pats.push(maybe_leaf_pat); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | PatKind::TuplePat(tuple_pat) => { | 126 | ast::Pat::TuplePat(tuple_pat) => { |
127 | for arg_pat in tuple_pat.args() { | 127 | for arg_pat in tuple_pat.args() { |
128 | pats_to_process.push_back(arg_pat); | 128 | pats_to_process.push_back(arg_pat); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | PatKind::StructPat(struct_pat) => { | 131 | ast::Pat::StructPat(struct_pat) => { |
132 | if let Some(pat_list) = struct_pat.field_pat_list() { | 132 | if let Some(pat_list) = struct_pat.field_pat_list() { |
133 | pats_to_process.extend( | 133 | pats_to_process.extend( |
134 | pat_list | 134 | pat_list |
@@ -139,12 +139,12 @@ fn get_leaf_pats(root_pat: Pat) -> Vec<Pat> { | |||
139 | .filter(|pat| pat.syntax().kind() != SyntaxKind::BIND_PAT) | 139 | .filter(|pat| pat.syntax().kind() != SyntaxKind::BIND_PAT) |
140 | }) | 140 | }) |
141 | .chain(pat_list.bind_pats().map(|bind_pat| { | 141 | .chain(pat_list.bind_pats().map(|bind_pat| { |
142 | bind_pat.pat().unwrap_or_else(|| Pat::from(bind_pat)) | 142 | bind_pat.pat().unwrap_or_else(|| ast::Pat::from(bind_pat)) |
143 | })), | 143 | })), |
144 | ); | 144 | ); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | PatKind::TupleStructPat(tuple_struct_pat) => { | 147 | ast::Pat::TupleStructPat(tuple_struct_pat) => { |
148 | for arg_pat in tuple_struct_pat.args() { | 148 | for arg_pat in tuple_struct_pat.args() { |
149 | pats_to_process.push_back(arg_pat); | 149 | pats_to_process.push_back(arg_pat); |
150 | } | 150 | } |
@@ -158,7 +158,7 @@ fn get_leaf_pats(root_pat: Pat) -> Vec<Pat> { | |||
158 | fn get_node_displayable_type( | 158 | fn get_node_displayable_type( |
159 | db: &RootDatabase, | 159 | db: &RootDatabase, |
160 | analyzer: &SourceAnalyzer, | 160 | analyzer: &SourceAnalyzer, |
161 | node_pat: &Pat, | 161 | node_pat: &ast::Pat, |
162 | ) -> Option<Ty> { | 162 | ) -> Option<Ty> { |
163 | analyzer.type_of_pat(db, node_pat).and_then(|resolved_type| { | 163 | analyzer.type_of_pat(db, node_pat).and_then(|resolved_type| { |
164 | if let Ty::Apply(_) = resolved_type { | 164 | if let Ty::Apply(_) = resolved_type { |