Skip to content

Commit

Permalink
Do not handle comment when converting try
Browse files Browse the repository at this point in the history
As we get faulty span.
  • Loading branch information
topecongiro committed Aug 5, 2018
1 parent 75967f0 commit 9e113b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,20 @@ impl Chain {
}
}

fn is_tries(s: &str) -> bool {
s.chars().all(|c| c == '?')
}

let parent = rev_children.pop().unwrap();
let mut children = vec![];
let mut prev_hi = parent.span.hi();
for chain_item in rev_children.into_iter().rev() {
let comment_span = mk_sp(prev_hi, chain_item.span.lo());
let comment_snippet = context.snippet(comment_span);
if !comment_snippet.trim().is_empty() {
if !(context.config.use_try_shorthand()
|| comment_snippet.trim().is_empty()
|| is_tries(comment_snippet.trim()))
{
children.push(ChainItem::comment(comment_span));
}
prev_hi = chain_item.span.hi();
Expand Down

0 comments on commit 9e113b5

Please sign in to comment.