Unnamed repository; edit this file 'description' to name the repository.
verify during parse
| -rw-r--r-- | crates/ide_ssr/src/fragments.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ide_ssr/src/fragments.rs b/crates/ide_ssr/src/fragments.rs index 5eaad8b1d5..72d26d53a3 100644 --- a/crates/ide_ssr/src/fragments.rs +++ b/crates/ide_ssr/src/fragments.rs @@ -6,7 +6,6 @@ //! needs to determine it somehow. We do this in a stupid way -- by pasting SSR //! rule into different contexts and checking what works. -use parser::SyntaxKind; use syntax::{ast, AstNode, SyntaxNode}; pub(crate) fn ty(s: &str) -> Result<SyntaxNode, ()> { @@ -17,6 +16,9 @@ pub(crate) fn ty(s: &str) -> Result<SyntaxNode, ()> { return Err(()); } let node = parse.tree().syntax().descendants().find_map(ast::Type::cast).ok_or(())?; + if node.to_string() != s { + return Err(()); + } Ok(node.syntax().clone()) } @@ -28,5 +30,8 @@ pub(crate) fn item(s: &str) -> Result<SyntaxNode, ()> { return Err(()); } let node = parse.tree().syntax().descendants().find_map(ast::Item::cast).ok_or(())?; + if node.to_string() != s { + return Err(()); + } Ok(node.syntax().clone()) } |