Skip to content

Commit ee0be42

Browse files
committed
Mark .remove_alias() as unsafe fn
1 parent 544964f commit ee0be42

6 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/field/io.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ where
9191
{
9292
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
9393
let mut idx = 0;
94-
for (slot, byte) in self
95-
.chunks_exact_mut(8)
96-
.remove_alias()
94+
for (slot, byte) in unsafe { self.chunks_exact_mut(8).remove_alias() }
9795
.zip(buf.iter().copied())
9896
{
9997
slot.store_be(byte);

src/slice.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,8 @@ where
12481248
}
12491249
}
12501250
else {
1251-
for (to, from) in
1252-
self.iter_mut().remove_alias().zip(src.iter().copied())
1251+
for (to, from) in unsafe { self.iter_mut().remove_alias() }
1252+
.zip(src.iter().copied())
12531253
{
12541254
to.set(from);
12551255
}
@@ -1425,8 +1425,8 @@ where
14251425
this.sp_copy_from_bitslice(that);
14261426
}
14271427
else {
1428-
for (to, from) in
1429-
self.iter_mut().remove_alias().zip(src.iter().copied())
1428+
for (to, from) in unsafe { self.iter_mut().remove_alias() }
1429+
.zip(src.iter().copied())
14301430
{
14311431
to.set(from);
14321432
}

src/slice/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ where
21692169
// write into it.
21702170
let mut out = BitVec::repeat(false, total);
21712171

2172-
for chunk in out.chunks_exact_mut(len).remove_alias() {
2172+
for chunk in unsafe { out.chunks_exact_mut(len).remove_alias() } {
21732173
// TODO(myrrlyn): Specialize for `BitField` access
21742174
chunk.clone_from_bitslice(self);
21752175
}

src/slice/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ macro_rules! noalias {
26362636
///
26372637
/// [`T::Alias`]: crate::store::BitStore::Alias
26382638
/// [`T::Mem`]: crate::store::BitStore::Mem
2639-
pub fn remove_alias(self) -> $to <'a, O, T $( , $p )? > {
2639+
pub unsafe fn remove_alias(self) -> $to <'a, O, T $( , $p )? > {
26402640
$to ::new(self)
26412641
}
26422642
}

src/slice/specialization.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ where T: BitStore
4343
);
4444

4545
let chunk_size = <usize as BitMemory>::BITS as usize;
46-
for (to, from) in self
47-
.chunks_mut(chunk_size)
48-
.remove_alias()
46+
for (to, from) in unsafe { self.chunks_mut(chunk_size).remove_alias() }
4947
.zip(src.chunks(chunk_size))
5048
{
5149
to.store_le::<usize>(from.load_le::<usize>())
@@ -139,9 +137,7 @@ where T: BitStore
139137
);
140138

141139
let chunk_size = <usize as BitMemory>::BITS as usize;
142-
for (to, from) in self
143-
.chunks_mut(chunk_size)
144-
.remove_alias()
140+
for (to, from) in unsafe { self.chunks_mut(chunk_size).remove_alias() }
145141
.zip(src.chunks(chunk_size))
146142
{
147143
to.store_be::<usize>(from.load_be::<usize>())

src/vec/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ where
5959
let new = unsafe { self.get_unchecked_mut(len .. new_len) };
6060
let mut pulled = 0;
6161
for (slot, bit) in
62-
new.iter_mut().remove_alias().zip(iter.by_ref())
62+
unsafe { new.iter_mut().remove_alias() }.zip(iter.by_ref())
6363
{
6464
slot.set(bit);
6565
pulled += 1;

0 commit comments

Comments
 (0)