mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
parameter parsing does not destroy blocks
This commit is contained in:
parent
b0aac1ca98
commit
f104458d45
10 changed files with 70 additions and 4 deletions
|
@ -58,6 +58,10 @@ pub fn parse(text: &str) -> SyntaxNode {
|
|||
res
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn validate_block_structure(_: SyntaxNodeRef) {}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn validate_block_structure(root: SyntaxNodeRef) {
|
||||
let mut stack = Vec::new();
|
||||
for node in algo::walk::preorder(root) {
|
||||
|
@ -67,7 +71,12 @@ fn validate_block_structure(root: SyntaxNodeRef) {
|
|||
}
|
||||
SyntaxKind::R_CURLY => {
|
||||
if let Some(pair) = stack.pop() {
|
||||
assert_eq!(node.parent(), pair.parent());
|
||||
assert_eq!(
|
||||
node.parent(),
|
||||
pair.parent(),
|
||||
"unpaired curleys:\n{}",
|
||||
utils::dump_tree(root),
|
||||
);
|
||||
assert!(
|
||||
node.next_sibling().is_none() && pair.prev_sibling().is_none(),
|
||||
"floating curlys at {:?}\nfile:\n{}\nerror:\n{}\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue