Skip to content

Commit 57f279d

Browse files
committed
Fix io::BufReader uses of read_buf
1 parent 8472204 commit 57f279d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

std/src/io/buffered/bufreader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<R: ?Sized + Read> Read for BufReader<R> {
349349
let prev = cursor.written();
350350

351351
let mut rem = self.fill_buf()?;
352-
rem.read_buf(cursor.reborrow())?;
352+
rem.read_buf(cursor.reborrow())?; // actually never fails
353353

354354
self.consume(cursor.written() - prev); //slice impl of read_buf known to never unfill buf
355355

std/src/io/buffered/bufreader/buffer.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ impl Buffer {
133133
buf.set_init(self.initialized);
134134
}
135135

136-
reader.read_buf(buf.unfilled())?;
136+
let result = reader.read_buf(buf.unfilled());
137137

138138
self.pos = 0;
139139
self.filled = buf.len();
140140
self.initialized = buf.init_len();
141+
142+
result?;
141143
}
142144
Ok(self.buffer())
143145
}

0 commit comments

Comments
 (0)