Merge pull request #1061 from marcusklaas/fix-subtract2
Fix integer underflow in extra_offset
This commit is contained in:
commit
1743f5caf6
@ -23,11 +23,10 @@ use rewrite::{Rewrite, RewriteContext};
|
||||
use SKIP_ANNOTATION;
|
||||
|
||||
// Computes the length of a string's last line, minus offset.
|
||||
#[inline]
|
||||
pub fn extra_offset(text: &str, offset: Indent) -> usize {
|
||||
match text.rfind('\n') {
|
||||
// 1 for newline character
|
||||
Some(idx) => text.len() - idx - 1 - offset.width(),
|
||||
Some(idx) => text.len().checked_sub(idx + 1 + offset.width()).unwrap_or(0),
|
||||
None => text.len(),
|
||||
}
|
||||
}
|
||||
|
4
tests/target/issue-1055.rs
Normal file
4
tests/target/issue-1055.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn issue_1055() {
|
||||
let foo = (|| {
|
||||
})();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user