Skip to content

Commit ca81aa4

Browse files
committed
a slice fill is now turned into a memset even when using miri
1 parent f463f88 commit ca81aa4

File tree

3 files changed

+2
-41
lines changed

3 files changed

+2
-41
lines changed

zlib-rs/src/deflate.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -804,16 +804,7 @@ fn lm_init(state: &mut State) {
804804
state.window_size = 2 * state.w_size;
805805

806806
// zlib uses CLEAR_HASH here
807-
crate::cfg_select!(
808-
miri => {
809-
// Miri does not turn `.fill(0)` into a memset
810-
// See https://github.com/rust-lang/rust/issues/147271.
811-
unsafe { core::ptr::write_bytes(state.head.as_mut_ptr(), 0u8, 1) };
812-
}
813-
_ => {
814-
state.head.as_mut_slice().fill(0);
815-
}
816-
);
807+
state.head.as_mut_slice().fill(0);
817808

818809
// Set the default configuration parameters:
819810
lm_set_level(state, state.level);

zlib-rs/src/deflate/sym_buf.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,7 @@ impl<'a> SymBuf<'a> {
3636
/// The number of initialized bytes is not changed, and the contents of the buffer are not modified.
3737
#[inline]
3838
pub fn clear(&mut self) {
39-
crate::cfg_select!(
40-
miri => {
41-
// Miri does not turn `.fill(0)` into a memset
42-
// See https://github.com/rust-lang/rust/issues/147271.
43-
unsafe { core::ptr::write_bytes(self.buf.as_mut_ptr(), 0u8, self.buf.len()) };
44-
}
45-
_ => {
46-
self.buf.as_mut_slice().fill(0);
47-
}
48-
);
39+
self.buf.as_mut_slice().fill(0);
4940
self.filled = 0;
5041
}
5142

zlib-rs/src/lib.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,6 @@ macro_rules! trace {
2626
};
2727
}
2828

29-
#[macro_export]
30-
macro_rules! cfg_select {
31-
({ $($tt:tt)* }) => {{
32-
$crate::cfg_select! { $($tt)* }
33-
}};
34-
(_ => { $($output:tt)* }) => {
35-
$($output)*
36-
};
37-
(
38-
$cfg:meta => $output:tt
39-
$($( $rest:tt )+)?
40-
) => {
41-
#[cfg($cfg)]
42-
$crate::cfg_select! { _ => $output }
43-
$(
44-
#[cfg(not($cfg))]
45-
$crate::cfg_select! { $($rest)+ }
46-
)?
47-
}
48-
}
49-
5029
/// Maximum size of the dynamic table. The maximum number of code structures is
5130
/// 1924, which is the sum of 1332 for literal/length codes and 592 for distance
5231
/// codes. These values were found by exhaustive searches using the program

0 commit comments

Comments
 (0)