Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambiguous associated type usage on top of 0.20 #109

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/tour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ are dominant."
println!("{:?}", bs.domain());
println!("Show the bits in memory");
for elt in bs.domain() {
println!("{:0w$b} ", elt, w = T::Mem::BITS as usize);
println!("{:0w$b} ", elt, w = <T::Mem as BitMemory>::BITS as usize);
}
println!();
}
Expand Down
4 changes: 2 additions & 2 deletions src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
let mut boxed = ManuallyDrop::new(boxed);

BitPtr::from_mut_slice(&mut boxed[..])
.span(boxed.len() * T::Mem::BITS as usize)
.span(boxed.len() * <T::Mem as BitMemory>::BITS as usize)
.map(|bitspan| Self { bitspan })
.map_err(|_| ManuallyDrop::into_inner(boxed))
}
Expand Down Expand Up @@ -438,7 +438,7 @@ where
let (_, head, bits) = bp.raw_parts();
let head = head.value() as usize;
let tail = head + bits;
let full = crate::mem::elts::<T::Mem>(tail) * T::Mem::BITS as usize;
let full = crate::mem::elts::<T::Mem>(tail) * <T::Mem as BitMemory>::BITS as usize;
unsafe {
bp.set_head(BitIdx::ZERO);
bp.set_len(full);
Expand Down
8 changes: 4 additions & 4 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ macro_rules! bit_domain {
let bitspan = slice.as_bitspan();
let h = bitspan.head();
let (e, t) = h.span(bitspan.len());
let w = T::Mem::BITS;
let w = <T::Mem as BitMemory>::BITS;

match (h.value(), e, t.value()) {
(_, 0, _) => Self::empty(),
Expand All @@ -258,7 +258,7 @@ macro_rules! bit_domain {
) -> Self {
let (head, rest) = bit_domain!(split $($m)?
slice,
(T::Mem::BITS - head.value()) as usize,
(<T::Mem as BitMemory>::BITS - head.value()) as usize,
);
let (body, tail) = bit_domain!(split $($m)?
rest,
Expand Down Expand Up @@ -289,7 +289,7 @@ macro_rules! bit_domain {
) -> Self {
let (head, rest) = bit_domain!(split $($m)?
slice,
(T::Mem::BITS - head.value()) as usize,
(<T::Mem as BitMemory>::BITS - head.value()) as usize,
);
let (head, body) = (
bit_domain!(retype $($m)? head),
Expand Down Expand Up @@ -537,7 +537,7 @@ macro_rules! domain {
let head = bitspan.head();
let elts = bitspan.elements();
let tail = bitspan.tail();
let bits = T::Mem::BITS;
let bits = <T::Mem as BitMemory>::BITS;
let base = bitspan.address().to_const() as *const _;
match (head.value(), elts, tail.value()) {
(_, 0, _) => Self::empty(),
Expand Down
56 changes: 28 additions & 28 deletions src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ where T: BitStore
As a const-expression, this branch folds at compile-time to
conditionally remove or retain the instruction.
*/
if M::BITS > T::Mem::BITS {
accum <<= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
accum <<= <T::Mem as BitMemory>::BITS;
}
accum |= resize::<T::Mem, M>(elem);
}
Expand Down Expand Up @@ -780,8 +780,8 @@ where T: BitStore
}

for elem in body.iter().map(BitStore::load_value) {
if M::BITS > T::Mem::BITS {
accum <<= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
accum <<= <T::Mem as BitMemory>::BITS;
}
accum |= resize::<T::Mem, M>(elem);
}
Expand Down Expand Up @@ -840,8 +840,8 @@ where T: BitStore

for elem in body.iter_mut() {
elem.store_value(resize(value));
if M::BITS > T::Mem::BITS {
value >>= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
value >>= <T::Mem as BitMemory>::BITS;
}
}

Expand Down Expand Up @@ -895,8 +895,8 @@ where T: BitStore

for elem in body.iter_mut().rev() {
elem.store_value(resize(value));
if M::BITS > T::Mem::BITS {
value >>= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
value >>= <T::Mem as BitMemory>::BITS;
}
}

Expand Down Expand Up @@ -969,7 +969,7 @@ where T: BitStore
Domain::Enclave { head, elem, tail } => get::<T, M>(
elem,
Msb0::mask(head, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
),
Domain::Region { head, body, tail } => {
let mut accum = M::ZERO;
Expand All @@ -978,19 +978,19 @@ where T: BitStore
accum = get::<T, M>(
elem,
Msb0::mask(None, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
);
}

for elem in body.iter().rev().map(BitStore::load_value) {
if M::BITS > T::Mem::BITS {
accum <<= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
accum <<= <T::Mem as BitMemory>::BITS;
}
accum |= resize::<T::Mem, M>(elem);
}

if let Some((head, elem)) = head {
accum <<= T::Mem::BITS - head.value();
accum <<= <T::Mem as BitMemory>::BITS - head.value();
accum |= get::<T, M>(elem, Msb0::mask(head, None), 0);
}

Expand Down Expand Up @@ -1052,7 +1052,7 @@ where T: BitStore
Domain::Enclave { head, elem, tail } => get::<T, M>(
elem,
Msb0::mask(head, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
),
Domain::Region { head, body, tail } => {
let mut accum = M::ZERO;
Expand All @@ -1062,8 +1062,8 @@ where T: BitStore
}

for elem in body.iter().map(BitStore::load_value) {
if M::BITS > T::Mem::BITS {
accum <<= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
accum <<= <T::Mem as BitMemory>::BITS;
}
accum |= resize::<T::Mem, M>(elem);
}
Expand All @@ -1074,7 +1074,7 @@ where T: BitStore
accum |= get::<T, M>(
elem,
Msb0::mask(None, tail),
T::Mem::BITS - width,
<T::Mem as BitMemory>::BITS - width,
);
}

Expand Down Expand Up @@ -1117,18 +1117,18 @@ where T: BitStore
elem,
value,
Msb0::mask(head, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
),
DomainMut::Region { head, body, tail } => {
if let Some((head, elem)) = head {
set::<T, M>(elem, value, Msb0::mask(head, None), 0);
value >>= T::Mem::BITS - head.value();
value >>= <T::Mem as BitMemory>::BITS - head.value();
}

for elem in body.iter_mut() {
elem.store_value(resize(value));
if M::BITS > T::Mem::BITS {
value >>= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
value >>= <T::Mem as BitMemory>::BITS;
}
}

Expand All @@ -1137,7 +1137,7 @@ where T: BitStore
elem,
value,
Msb0::mask(None, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
);
}
},
Expand Down Expand Up @@ -1178,23 +1178,23 @@ where T: BitStore
elem,
value,
Msb0::mask(head, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
),
DomainMut::Region { head, body, tail } => {
if let Some((elem, tail)) = tail {
set::<T, M>(
elem,
value,
Msb0::mask(None, tail),
T::Mem::BITS - tail.value(),
<T::Mem as BitMemory>::BITS - tail.value(),
);
value >>= tail.value();
}

for elem in body.iter_mut().rev() {
elem.store_value(resize(value));
if M::BITS > T::Mem::BITS {
value >>= T::Mem::BITS;
if <M as BitMemory>::BITS > <T::Mem as BitMemory>::BITS {
value >>= <T::Mem as BitMemory>::BITS;
}
}

Expand Down Expand Up @@ -1298,11 +1298,11 @@ where
/// [`M::BITS`]: crate::mem::BitMemory::BITS
fn check<M>(action: &'static str, len: usize)
where M: BitMemory {
if !(1 ..= M::BITS as usize).contains(&len) {
if !(1 ..= <M as BitMemory>::BITS as usize).contains(&len) {
panic!(
"Cannot {} {} bits from a {}-bit region",
action,
M::BITS,
<M as BitMemory>::BITS,
len,
);
}
Expand Down
Loading