diff --git a/tokio/src/fs/mocks.rs b/tokio/src/fs/mocks.rs index 5343fb90b..3a8ac2bdd 100644 --- a/tokio/src/fs/mocks.rs +++ b/tokio/src/fs/mocks.rs @@ -56,6 +56,13 @@ mock! { impl Read for MockFile { fn read(&mut self, dst: &mut [u8]) -> io::Result { + // Placate Miri. Tokio will call this method with an uninitialized + // buffer, which is ok because std::io::Read::read implementations don't usually read + // from their input buffers. But Mockall 0.12-0.13 will try to Debug::fmt the + // buffer, even if there is no failure, triggering an uninitialized data access alert from + // Miri. Initialize the data here just to prevent those Miri alerts. + // This can be removed after upgrading to Mockall 0.14. + dst.fill(0); self.inner_read(dst) } }