Skip to content

Commit edbbb10

Browse files
committed
make uninit_mask a unit test
1 parent 6b7f6b9 commit edbbb10

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

compiler/rustc_middle/src/mir/interpret/allocation.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
33
mod init_mask;
44
mod provenance_map;
5+
#[cfg(test)]
6+
mod tests;
57

68
use std::borrow::Cow;
79
use std::fmt;

compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl InitMask {
150150
}
151151

152152
#[inline]
153-
fn get(&self, i: Size) -> bool {
153+
pub fn get(&self, i: Size) -> bool {
154154
let (block, bit) = Self::bit_index(i);
155155
(self.blocks[block] & (1 << bit)) != 0
156156
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use super::*;
2+
3+
#[test]
4+
fn uninit_mask() {
5+
let mut mask = InitMask::new(Size::from_bytes(500), false);
6+
assert!(!mask.get(Size::from_bytes(499)));
7+
mask.set_range(alloc_range(Size::from_bytes(499), Size::from_bytes(1)), true);
8+
assert!(mask.get(Size::from_bytes(499)));
9+
mask.set_range((100..256).into(), true);
10+
for i in 0..100 {
11+
assert!(!mask.get(Size::from_bytes(i)), "{i} should not be set");
12+
}
13+
for i in 100..256 {
14+
assert!(mask.get(Size::from_bytes(i)), "{i} should be set");
15+
}
16+
for i in 256..499 {
17+
assert!(!mask.get(Size::from_bytes(i)), "{i} should not be set");
18+
}
19+
}

src/test/ui-fulldeps/uninit_mask.rs

-28
This file was deleted.

0 commit comments

Comments
 (0)