From 9169107c1cf15bc955bb15a06d83a1ebf011e9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=A1=E5=94=AF=E5=AE=87?= Date: Thu, 6 Apr 2023 11:48:16 +0800 Subject: [PATCH] Remove an unnecessary `mut` in `BufWriter::into_parts`. `ptr::read` takes `*const T` so `&mut` is not necessary. --- library/std/src/io/buffered/bufwriter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/std/src/io/buffered/bufwriter.rs index 6acb937e784..14c455d4fa3 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/std/src/io/buffered/bufwriter.rs @@ -339,7 +339,7 @@ impl BufWriter { let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) }; // SAFETY: forget(self) prevents double dropping inner - let inner = unsafe { ptr::read(&mut self.inner) }; + let inner = unsafe { ptr::read(&self.inner) }; mem::forget(self); (inner, buf)