diff options
Diffstat (limited to 'crates/ssr/src/matching.rs')
-rw-r--r-- | crates/ssr/src/matching.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/ssr/src/matching.rs b/crates/ssr/src/matching.rs index ffc7202ae..7f0b5061e 100644 --- a/crates/ssr/src/matching.rs +++ b/crates/ssr/src/matching.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | //! process of matching, placeholder values are recorded. | 2 | //! process of matching, placeholder values are recorded. |
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | parsing::{Constraint, NodeKind, Placeholder}, | 5 | parsing::{Constraint, NodeKind, Placeholder, Var}, |
6 | resolving::{ResolvedPattern, ResolvedRule, UfcsCallInfo}, | 6 | resolving::{ResolvedPattern, ResolvedRule, UfcsCallInfo}, |
7 | SsrMatches, | 7 | SsrMatches, |
8 | }; | 8 | }; |
@@ -56,10 +56,6 @@ pub struct Match { | |||
56 | pub(crate) rendered_template_paths: FxHashMap<SyntaxNode, hir::ModPath>, | 56 | pub(crate) rendered_template_paths: FxHashMap<SyntaxNode, hir::ModPath>, |
57 | } | 57 | } |
58 | 58 | ||
59 | /// Represents a `$var` in an SSR query. | ||
60 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
61 | pub(crate) struct Var(pub String); | ||
62 | |||
63 | /// Information about a placeholder bound in a match. | 59 | /// Information about a placeholder bound in a match. |
64 | #[derive(Debug)] | 60 | #[derive(Debug)] |
65 | pub(crate) struct PlaceholderMatch { | 61 | pub(crate) struct PlaceholderMatch { |
@@ -182,10 +178,9 @@ impl<'db, 'sema> Matcher<'db, 'sema> { | |||
182 | // We validated the range for the node when we started the match, so the placeholder | 178 | // We validated the range for the node when we started the match, so the placeholder |
183 | // probably can't fail range validation, but just to be safe... | 179 | // probably can't fail range validation, but just to be safe... |
184 | self.validate_range(&original_range)?; | 180 | self.validate_range(&original_range)?; |
185 | matches_out.placeholder_values.insert( | 181 | matches_out |
186 | Var(placeholder.ident.to_string()), | 182 | .placeholder_values |
187 | PlaceholderMatch::new(code, original_range), | 183 | .insert(placeholder.ident.clone(), PlaceholderMatch::new(code, original_range)); |
188 | ); | ||
189 | } | 184 | } |
190 | return Ok(()); | 185 | return Ok(()); |
191 | } | 186 | } |
@@ -487,7 +482,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { | |||
487 | } | 482 | } |
488 | if let Phase::Second(match_out) = phase { | 483 | if let Phase::Second(match_out) = phase { |
489 | match_out.placeholder_values.insert( | 484 | match_out.placeholder_values.insert( |
490 | Var(placeholder.ident.to_string()), | 485 | placeholder.ident.clone(), |
491 | PlaceholderMatch::from_range(FileRange { | 486 | PlaceholderMatch::from_range(FileRange { |
492 | file_id: self.sema.original_range(code).file_id, | 487 | file_id: self.sema.original_range(code).file_id, |
493 | range: first_matched_token | 488 | range: first_matched_token |