From 7e00810c59e31d8bf2514ea6771beee4e2445c20 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Sun, 25 Feb 2024 20:43:17 +0000 Subject: [PATCH] Ignore error of flush in Drop of CodedOutputStream https://github.com/stepancheg/rust-protobuf/issues/714 --- protobuf/src/coded_output_stream/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protobuf/src/coded_output_stream/mod.rs b/protobuf/src/coded_output_stream/mod.rs index 5010df96f..26293399f 100644 --- a/protobuf/src/coded_output_stream/mod.rs +++ b/protobuf/src/coded_output_stream/mod.rs @@ -1010,8 +1010,9 @@ impl<'a> Write for CodedOutputStream<'a> { impl<'a> Drop for CodedOutputStream<'a> { fn drop(&mut self) { - // This may panic - CodedOutputStream::flush(self).expect("failed to flush"); + // User must call `flush` to guarantee that the data is written. + // Rust should have a lint to enforce `flush` call before drop. + let _ignore = CodedOutputStream::flush(self); } }