From 3c612bfa3a86675ef18b1effcc76037cb6b9fddf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Jan 2018 22:41:57 +0300 Subject: Simplify --- src/parser/event_parser/grammar/items.rs | 4 +--- src/parser/event_parser/parser.rs | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index d2bfeac97..5b0180b81 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs @@ -49,9 +49,7 @@ fn item(p: &mut Parser) -> bool { || node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item) || node_if(p, FN_KW, FN_ITEM, fn_item); - if item_parsed && attrs_start != item_start { - p.forward_parent(attrs_start, item_start); - } + p.forward_parent(attrs_start, item_start); item_parsed } diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index 14c0efe2d..6171b3579 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs @@ -55,6 +55,9 @@ impl<'t> Parser<'t> { } pub(crate) fn forward_parent(&mut self, child: Mark, parent: Mark) { + if child == parent || parent == self.mark() { + return + } assert!(child.0 < parent.0); let diff = parent.0 - child.0; match self.events[child.0 as usize] { -- cgit v1.2.3