From 1db7caab017b5814d8a8ac3baa5786af18870869 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 13 Oct 2022 20:07:27 +0200 Subject: Replace some unused code with assertions --- src/construct/document.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/construct/document.rs b/src/construct/document.rs index 82f2ebd..daf7131 100644 --- a/src/construct/document.rs +++ b/src/construct/document.rs @@ -442,9 +442,11 @@ pub fn flow_end(tokenizer: &mut Tokenizer) -> State { if tokenizer.tokenize_state.document_continued != tokenizer.tokenize_state.document_container_stack.len() { - if let Err(message) = exit_containers(tokenizer, &Phase::After) { - return State::Error(message); - } + let result = exit_containers(tokenizer, &Phase::After); + // `Phase::After` doesn’t deal with flow: it only generates exits for + // containers. + // And that never errors. + debug_assert!(result.is_ok(), "did not expect error when exiting"); } match tokenizer.current { @@ -523,11 +525,11 @@ fn exit_containers(tokenizer: &mut Tokenizer, phase: &Phase) -> Result<(), Strin debug_assert!(found, "expected to find container event to exit"); } - if let Some(ref mut list) = tokenizer.tokenize_state.document_exits[index] { - list.append(&mut exits); - } else { - tokenizer.tokenize_state.document_exits[index] = Some(exits); - } + debug_assert!( + tokenizer.tokenize_state.document_exits[index].is_none(), + "expected no exits yet" + ); + tokenizer.tokenize_state.document_exits[index] = Some(exits); } child.interrupt = false; -- cgit