Skip to content

Commit f899513

Browse files
committed
Auto merge of #23251 - tbu-:pr_rm_core_str_checked_add, r=alexcrichton
2 parents cfea8ec + 5199a70 commit f899513

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/str/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ impl<'a> Iterator for Chars<'a> {
442442
#[inline]
443443
fn size_hint(&self) -> (usize, Option<usize>) {
444444
let (len, _) = self.iter.size_hint();
445-
(len.saturating_add(3) / 4, Some(len))
445+
// `(len + 3)` can't overflow, because we know that the `slice::Iter`
446+
// belongs to a slice in memory which has a maximum length of
447+
// `isize::MAX` (that's well below `usize::MAX`).
448+
((len + 3) / 4, Some(len))
446449
}
447450
}
448451

0 commit comments

Comments
 (0)