Merge pull request #387 from marcusklaas/prevent-overflow
Prevent arithmetic overflow handling match arm comments
This commit is contained in:
commit
d7efdd60c8
10
src/expr.rs
10
src/expr.rs
@ -693,11 +693,6 @@ fn rewrite_match_arm_comment(context: &RewriteContext,
|
|||||||
Some(n) => &missed_str[n+1..],
|
Some(n) => &missed_str[n+1..],
|
||||||
None => &missed_str[..],
|
None => &missed_str[..],
|
||||||
};
|
};
|
||||||
// Nor the trailing "}" which closes the match
|
|
||||||
let missed_str = match missed_str.find_uncommented("}") {
|
|
||||||
Some(n) => &missed_str[..n-1],
|
|
||||||
None => &missed_str[..],
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
// any text not preceeded by a newline is pushed unmodified to the block
|
// any text not preceeded by a newline is pushed unmodified to the block
|
||||||
@ -777,7 +772,10 @@ fn rewrite_match(context: &RewriteContext,
|
|||||||
result.push_str(&snippet);
|
result.push_str(&snippet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let last_comment = context.snippet(mk_sp(arm_end_pos(&arms[arms.len() - 1]), span.hi));
|
// BytePos(1) = closing match brace.
|
||||||
|
let last_span = mk_sp(arm_end_pos(&arms[arms.len() - 1]),
|
||||||
|
span.hi - BytePos(1));
|
||||||
|
let last_comment = context.snippet(last_span);
|
||||||
let comment = try_opt!(rewrite_match_arm_comment(context,
|
let comment = try_opt!(rewrite_match_arm_comment(context,
|
||||||
&last_comment,
|
&last_comment,
|
||||||
width,
|
width,
|
||||||
|
@ -221,3 +221,7 @@ fn issue280() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn issue383() {
|
||||||
|
match resolution.last_private {LastImport{..} => false, _ => true};
|
||||||
|
}
|
||||||
|
@ -210,3 +210,10 @@ fn issue280() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn issue383() {
|
||||||
|
match resolution.last_private {
|
||||||
|
LastImport{..} => false,
|
||||||
|
_ => true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user