File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed
compiler/rustc_serialize/src Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change @@ -131,16 +131,8 @@ impl FileEncoder {
131
131
let buf = unsafe { self . buffer_empty ( ) . first_chunk_mut :: < N > ( ) . unwrap_unchecked ( ) } ;
132
132
let written = visitor ( buf) ;
133
133
// We have to ensure that an errant visitor cannot cause self.buffered to exeed BUF_SIZE.
134
- if written > N {
135
- Self :: panic_invalid_write :: < N > ( written) ;
136
- }
137
- self . buffered += written;
138
- }
139
-
140
- #[ cold]
141
- #[ inline( never) ]
142
- fn panic_invalid_write < const N : usize > ( written : usize ) {
143
- panic ! ( "FileEncoder::write_with::<{N}> cannot be used to write {written} bytes" ) ;
134
+ debug_assert ! ( written <= N ) ;
135
+ self . buffered += written. min ( N ) ;
144
136
}
145
137
146
138
/// Helper for calls where [`FileEncoder::write_with`] always writes the whole array.
You can’t perform that action at this time.
0 commit comments