Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy issues #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/construct/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Result<Option<Subresult>, message::
let result = subtokenize(
&mut tokenizer.events,
tokenizer.parse_state,
&Some(Content::Content),
Some(&Content::Content),
)?;

Ok(Some(result))
Expand Down
65 changes: 30 additions & 35 deletions src/construct/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,26 +304,24 @@ pub fn containers_after(tokenizer: &mut Tokenizer) -> State {
!= tokenizer.tokenize_state.document_container_stack.len();
child.define_skip(tokenizer.point.clone());

match tokenizer.current {
// Note: EOL is part of data.
None => State::Retry(StateName::DocumentFlowEnd),
Some(_) => {
let current = tokenizer.events.len();
let previous = tokenizer.tokenize_state.document_data_index;
if let Some(previous) = previous {
tokenizer.events[previous].link.as_mut().unwrap().next = Some(current);
}
tokenizer.tokenize_state.document_data_index = Some(current);
tokenizer.enter_link(
Name::Data,
Link {
previous,
next: None,
content: Content::Flow,
},
);
State::Retry(StateName::DocumentFlowInside)
if tokenizer.current.is_some() {
let current = tokenizer.events.len();
let previous = tokenizer.tokenize_state.document_data_index;
if let Some(previous) = previous {
tokenizer.events[previous].link.as_mut().unwrap().next = Some(current);
}
tokenizer.tokenize_state.document_data_index = Some(current);
tokenizer.enter_link(
Name::Data,
Link {
previous,
next: None,
content: Content::Flow,
},
);
State::Retry(StateName::DocumentFlowInside)
} else {
State::Retry(StateName::DocumentFlowEnd)
}
}

Expand Down Expand Up @@ -450,23 +448,20 @@ pub fn flow_end(tokenizer: &mut Tokenizer) -> State {
debug_assert!(result.is_ok(), "did not expect error when exiting");
}

match tokenizer.current {
None => {
tokenizer.tokenize_state.document_continued = 0;
if let Err(message) = exit_containers(tokenizer, &Phase::Eof) {
return State::Error(message);
}
resolve(tokenizer);
State::Ok
}
Some(_) => {
tokenizer.tokenize_state.document_continued = 0;
tokenizer.tokenize_state.document_lazy_accepting_before =
document_lazy_continuation_current;
// Containers would only be interrupting if we’ve continued.
tokenizer.interrupt = false;
State::Retry(StateName::DocumentContainerExistingBefore)
if tokenizer.current.is_some() {
tokenizer.tokenize_state.document_continued = 0;
tokenizer.tokenize_state.document_lazy_accepting_before =
document_lazy_continuation_current;
// Containers would only be interrupting if we’ve continued.
tokenizer.interrupt = false;
State::Retry(StateName::DocumentContainerExistingBefore)
} else {
tokenizer.tokenize_state.document_continued = 0;
if let Err(message) = exit_containers(tokenizer, &Phase::Eof) {
return State::Error(message);
}
resolve(tokenizer);
State::Ok
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ pub fn parse<'a>(
return Ok((events, parse_state));
}

result = subtokenize(&mut events, &parse_state, &None)?;
result = subtokenize(&mut events, &parse_state, None)?;
}
}
6 changes: 2 additions & 4 deletions src/subtokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn link_to(events: &mut [Event], previous: usize, next: usize) {
pub fn subtokenize(
events: &mut Vec<Event>,
parse_state: &ParseState,
filter: &Option<Content>,
filter: Option<&Content>,
) -> Result<Subresult, message::Message> {
let mut map = EditMap::new();
let mut index = 0;
Expand All @@ -97,9 +97,7 @@ pub fn subtokenize(
debug_assert_eq!(event.kind, Kind::Enter);

// No need to enter linked events again.
if link.previous.is_none()
&& (filter.is_none() || &link.content == filter.as_ref().unwrap())
{
if link.previous.is_none() && (filter.is_none() || link.content == *filter.unwrap()) {
// Index into `events` pointing to a chunk.
let mut link_index = Some(index);
// Subtokenizer.
Expand Down