aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-24 18:50:37 +0100
committerAleksey Kladov <[email protected]>2018-08-24 18:50:37 +0100
commitf104458d45e30024f8a4a02c1ad4101ed74b08f9 (patch)
tree4317dc4c504a90ea0876c862b049eee6d6513e98 /crates/libsyntax2/src/lib.rs
parentb0aac1ca98280efee9587897d86ef447933004dd (diff)
parameter parsing does not destroy blocks
Diffstat (limited to 'crates/libsyntax2/src/lib.rs')
-rw-r--r--crates/libsyntax2/src/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs
index d3ecbe470..9f9f3ab3a 100644
--- a/crates/libsyntax2/src/lib.rs
+++ b/crates/libsyntax2/src/lib.rs
@@ -58,6 +58,10 @@ pub fn parse(text: &str) -> SyntaxNode {
58 res 58 res
59} 59}
60 60
61#[cfg(not(debug_assertions))]
62fn validate_block_structure(_: SyntaxNodeRef) {}
63
64#[cfg(debug_assertions)]
61fn validate_block_structure(root: SyntaxNodeRef) { 65fn validate_block_structure(root: SyntaxNodeRef) {
62 let mut stack = Vec::new(); 66 let mut stack = Vec::new();
63 for node in algo::walk::preorder(root) { 67 for node in algo::walk::preorder(root) {
@@ -67,7 +71,12 @@ fn validate_block_structure(root: SyntaxNodeRef) {
67 } 71 }
68 SyntaxKind::R_CURLY => { 72 SyntaxKind::R_CURLY => {
69 if let Some(pair) = stack.pop() { 73 if let Some(pair) = stack.pop() {
70 assert_eq!(node.parent(), pair.parent()); 74 assert_eq!(
75 node.parent(),
76 pair.parent(),
77 "unpaired curleys:\n{}",
78 utils::dump_tree(root),
79 );
71 assert!( 80 assert!(
72 node.next_sibling().is_none() && pair.prev_sibling().is_none(), 81 node.next_sibling().is_none() && pair.prev_sibling().is_none(),
73 "floating curlys at {:?}\nfile:\n{}\nerror:\n{}\n", 82 "floating curlys at {:?}\nfile:\n{}\nerror:\n{}\n",