diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index b354116993c..bb03994fc7a 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -432,7 +432,10 @@ impl<'a> Iterator for Chars<'a> { #[inline] fn size_hint(&self) -> (usize, Option) { let (len, _) = self.iter.size_hint(); - (len.saturating_add(3) / 4, Some(len)) + // `(len + 3)` can't overflow, because we know that the `slice::Iter` + // belongs to a slice in memory which has a maximum length of + // `isize::MAX` (that's well below `usize::MAX`). + ((len + 3) / 4, Some(len)) } }