aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_ssr/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_ssr/src')
-rw-r--r--crates/ide_ssr/src/matching.rs6
-rw-r--r--crates/ide_ssr/src/replacing.rs10
-rw-r--r--crates/ide_ssr/src/resolving.rs2
-rw-r--r--crates/ide_ssr/src/search.rs2
-rw-r--r--crates/ide_ssr/src/tests.rs4
5 files changed, 12 insertions, 12 deletions
diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs
index b3072fb9f..fb92a0ccc 100644
--- a/crates/ide_ssr/src/matching.rs
+++ b/crates/ide_ssr/src/matching.rs
@@ -382,7 +382,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
382 code: Option<T>, 382 code: Option<T>,
383 ) -> Result<(), MatchFailed> { 383 ) -> Result<(), MatchFailed> {
384 match (pattern, code) { 384 match (pattern, code) {
385 (Some(p), Some(c)) => self.attempt_match_node(phase, &p.syntax(), &c.syntax()), 385 (Some(p), Some(c)) => self.attempt_match_node(phase, p.syntax(), c.syntax()),
386 (None, None) => Ok(()), 386 (None, None) => Ok(()),
387 (Some(p), None) => fail_match!("Pattern `{}` had nothing to match", p.syntax().text()), 387 (Some(p), None) => fail_match!("Pattern `{}` had nothing to match", p.syntax().text()),
388 (None, Some(c)) => { 388 (None, Some(c)) => {
@@ -478,7 +478,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
478 if Some(first_token.text()) == next_pattern_token.as_deref() { 478 if Some(first_token.text()) == next_pattern_token.as_deref() {
479 if let Some(SyntaxElement::Node(p)) = pattern.next() { 479 if let Some(SyntaxElement::Node(p)) = pattern.next() {
480 // We have a subtree that starts with the next token in our pattern. 480 // We have a subtree that starts with the next token in our pattern.
481 self.attempt_match_token_tree(phase, &p, &n)?; 481 self.attempt_match_token_tree(phase, &p, n)?;
482 break; 482 break;
483 } 483 }
484 } 484 }
@@ -609,7 +609,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
609 expr: &ast::Expr, 609 expr: &ast::Expr,
610 ) -> Result<usize, MatchFailed> { 610 ) -> Result<usize, MatchFailed> {
611 use hir::HirDisplay; 611 use hir::HirDisplay;
612 let code_type = self.sema.type_of_expr(&expr).ok_or_else(|| { 612 let code_type = self.sema.type_of_expr(expr).ok_or_else(|| {
613 match_error!("Failed to get receiver type for `{}`", expr.syntax().text()) 613 match_error!("Failed to get receiver type for `{}`", expr.syntax().text())
614 })?; 614 })?;
615 // Temporary needed to make the borrow checker happy. 615 // Temporary needed to make the borrow checker happy.
diff --git a/crates/ide_ssr/src/replacing.rs b/crates/ide_ssr/src/replacing.rs
index c9ccc1961..9265af7c1 100644
--- a/crates/ide_ssr/src/replacing.rs
+++ b/crates/ide_ssr/src/replacing.rs
@@ -84,16 +84,16 @@ impl ReplacementRenderer<'_> {
84 fn render_node_or_token(&mut self, node_or_token: &SyntaxElement) { 84 fn render_node_or_token(&mut self, node_or_token: &SyntaxElement) {
85 match node_or_token { 85 match node_or_token {
86 SyntaxElement::Token(token) => { 86 SyntaxElement::Token(token) => {
87 self.render_token(&token); 87 self.render_token(token);
88 } 88 }
89 SyntaxElement::Node(child_node) => { 89 SyntaxElement::Node(child_node) => {
90 self.render_node(&child_node); 90 self.render_node(child_node);
91 } 91 }
92 } 92 }
93 } 93 }
94 94
95 fn render_node(&mut self, node: &SyntaxNode) { 95 fn render_node(&mut self, node: &SyntaxNode) {
96 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) { 96 if let Some(mod_path) = self.match_info.rendered_template_paths.get(node) {
97 self.out.push_str(&mod_path.to_string()); 97 self.out.push_str(&mod_path.to_string());
98 // Emit everything except for the segment's name-ref, since we already effectively 98 // Emit everything except for the segment's name-ref, since we already effectively
99 // emitted that as part of `mod_path`. 99 // emitted that as part of `mod_path`.
@@ -107,12 +107,12 @@ impl ReplacementRenderer<'_> {
107 } 107 }
108 } 108 }
109 } else { 109 } else {
110 self.render_node_children(&node); 110 self.render_node_children(node);
111 } 111 }
112 } 112 }
113 113
114 fn render_token(&mut self, token: &SyntaxToken) { 114 fn render_token(&mut self, token: &SyntaxToken) {
115 if let Some(placeholder) = self.rule.get_placeholder(&token) { 115 if let Some(placeholder) = self.rule.get_placeholder(token) {
116 if let Some(placeholder_value) = 116 if let Some(placeholder_value) =
117 self.match_info.placeholder_values.get(&placeholder.ident) 117 self.match_info.placeholder_values.get(&placeholder.ident)
118 { 118 {
diff --git a/crates/ide_ssr/src/resolving.rs b/crates/ide_ssr/src/resolving.rs
index 541da4122..a66a7a4a8 100644
--- a/crates/ide_ssr/src/resolving.rs
+++ b/crates/ide_ssr/src/resolving.rs
@@ -211,7 +211,7 @@ impl<'db> ResolutionScope<'db> {
211 // First try resolving the whole path. This will work for things like 211 // First try resolving the whole path. This will work for things like
212 // `std::collections::HashMap`, but will fail for things like 212 // `std::collections::HashMap`, but will fail for things like
213 // `std::collections::HashMap::new`. 213 // `std::collections::HashMap::new`.
214 if let Some(resolution) = self.scope.speculative_resolve(&path) { 214 if let Some(resolution) = self.scope.speculative_resolve(path) {
215 return Some(resolution); 215 return Some(resolution);
216 } 216 }
217 // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if 217 // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if
diff --git a/crates/ide_ssr/src/search.rs b/crates/ide_ssr/src/search.rs
index 28cef742c..f2056919e 100644
--- a/crates/ide_ssr/src/search.rs
+++ b/crates/ide_ssr/src/search.rs
@@ -173,7 +173,7 @@ impl<'db> MatchFinder<'db> {
173 if !is_search_permitted(code) { 173 if !is_search_permitted(code) {
174 return; 174 return;
175 } 175 }
176 self.try_add_match(rule, &code, restrict_range, matches_out); 176 self.try_add_match(rule, code, restrict_range, matches_out);
177 // If we've got a macro call, we already tried matching it pre-expansion, which is the only 177 // If we've got a macro call, we already tried matching it pre-expansion, which is the only
178 // way to match the whole macro, now try expanding it and matching the expansion. 178 // way to match the whole macro, now try expanding it and matching the expansion.
179 if let Some(macro_call) = ast::MacroCall::cast(code.clone()) { 179 if let Some(macro_call) = ast::MacroCall::cast(code.clone()) {
diff --git a/crates/ide_ssr/src/tests.rs b/crates/ide_ssr/src/tests.rs
index 1d8565dc0..444c6b0af 100644
--- a/crates/ide_ssr/src/tests.rs
+++ b/crates/ide_ssr/src/tests.rs
@@ -75,7 +75,7 @@ pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Ve
75 match range_or_offset { 75 match range_or_offset {
76 RangeOrOffset::Range(range) => { 76 RangeOrOffset::Range(range) => {
77 position = FilePosition { file_id, offset: range.start() }; 77 position = FilePosition { file_id, offset: range.start() };
78 selections = vec![FileRange { file_id, range: range }]; 78 selections = vec![FileRange { file_id, range }];
79 } 79 }
80 RangeOrOffset::Offset(offset) => { 80 RangeOrOffset::Offset(offset) => {
81 position = FilePosition { file_id, offset }; 81 position = FilePosition { file_id, offset };
@@ -129,7 +129,7 @@ fn assert_matches(pattern: &str, code: &str, expected: &[&str]) {
129 let matched_strings: Vec<String> = 129 let matched_strings: Vec<String> =
130 match_finder.matches().flattened().matches.iter().map(|m| m.matched_text()).collect(); 130 match_finder.matches().flattened().matches.iter().map(|m| m.matched_text()).collect();
131 if matched_strings != expected && !expected.is_empty() { 131 if matched_strings != expected && !expected.is_empty() {
132 print_match_debug_info(&match_finder, position.file_id, &expected[0]); 132 print_match_debug_info(&match_finder, position.file_id, expected[0]);
133 } 133 }
134 assert_eq!(matched_strings, expected); 134 assert_eq!(matched_strings, expected);
135} 135}