We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc1cc1d commit dcd80b8Copy full SHA for dcd80b8
src/libstd/io/buffered.rs
@@ -187,7 +187,10 @@ impl<R: Read> BufRead for BufReader<R> {
187
fn fill_buf(&mut self) -> io::Result<&[u8]> {
188
// If we've reached the end of our internal buffer then we need to fetch
189
// some more data from the underlying reader.
190
- if self.pos == self.cap {
+ // Branch using `>=` instead of the more correct `==`
191
+ // to tell the compiler that the pos..cap slice is always valid.
192
+ if self.pos >= self.cap {
193
+ debug_assert!(self.pos == self.cap);
194
self.cap = self.inner.read(&mut self.buf)?;
195
self.pos = 0;
196
}
0 commit comments