Skip to content

Commit

Permalink
Refactor CTL Handling (#1629)
Browse files Browse the repository at this point in the history
* refactor

* fmt

* fmt

* sync target version

* fix

* fix clippy

* fix clippy
  • Loading branch information
sai-deng authored Oct 9, 2024
1 parent 27a972f commit 7959bd2
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 186 deletions.
4 changes: 2 additions & 2 deletions plonky2/src/iop/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,13 @@ impl<'a, F: Field> PartitionWitness<'a, F> {
}
}

impl<'a, F: Field> WitnessWrite<F> for PartitionWitness<'a, F> {
impl<F: Field> WitnessWrite<F> for PartitionWitness<'_, F> {
fn set_target(&mut self, target: Target, value: F) -> Result<()> {
self.set_target_returning_rep(target, value).map(|_| ())
}
}

impl<'a, F: Field> Witness<F> for PartitionWitness<'a, F> {
impl<F: Field> Witness<F> for PartitionWitness<'_, F> {
fn try_get_target(&self, target: Target) -> Option<F> {
let rep_index = self.representative_map[self.target_index(target)];
self.values[rep_index]
Expand Down
10 changes: 5 additions & 5 deletions plonky2/src/plonk/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct EvaluationVarsBasePacked<'a, P: PackedField> {
pub public_inputs_hash: &'a HashOut<P::Scalar>,
}

impl<'a, F: RichField + Extendable<D>, const D: usize> EvaluationVars<'a, F, D> {
impl<F: RichField + Extendable<D>, const D: usize> EvaluationVars<'_, F, D> {
pub fn get_local_ext_algebra(
&self,
wire_range: Range<usize>,
Expand Down Expand Up @@ -120,7 +120,7 @@ impl<'a, F: Field> EvaluationVarsBaseBatch<'a, F> {
}
}

impl<'a, F: Field> EvaluationVarsBase<'a, F> {
impl<F: Field> EvaluationVarsBase<'_, F> {
pub fn get_local_ext<const D: usize>(&self, wire_range: Range<usize>) -> F::Extension
where
F: RichField + Extendable<D>,
Expand Down Expand Up @@ -209,13 +209,13 @@ impl<'a, P: PackedField> Iterator for EvaluationVarsBaseBatchIterPacked<'a, P> {
}
}

impl<'a, P: PackedField> ExactSizeIterator for EvaluationVarsBaseBatchIterPacked<'a, P> {
impl<P: PackedField> ExactSizeIterator for EvaluationVarsBaseBatchIterPacked<'_, P> {
fn len(&self) -> usize {
(self.vars_batch.len() - self.i) / P::WIDTH
}
}

impl<'a, const D: usize> EvaluationTargets<'a, D> {
impl<const D: usize> EvaluationTargets<'_, D> {
pub fn remove_prefix(&mut self, num_selectors: usize) {
self.local_constants = &self.local_constants[num_selectors..];
}
Expand All @@ -228,7 +228,7 @@ pub struct EvaluationTargets<'a, const D: usize> {
pub public_inputs_hash: &'a HashOutTarget,
}

impl<'a, const D: usize> EvaluationTargets<'a, D> {
impl<const D: usize> EvaluationTargets<'_, D> {
pub fn get_local_ext_algebra(&self, wire_range: Range<usize>) -> ExtensionAlgebraTarget<D> {
debug_assert_eq!(wire_range.len(), D);
let arr = self.local_wires[wire_range].try_into().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions plonky2/src/util/serialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,13 +2196,13 @@ impl<'a> Buffer<'a> {
}
}

impl<'a> Remaining for Buffer<'a> {
impl Remaining for Buffer<'_> {
fn remaining(&self) -> usize {
self.bytes.len() - self.pos()
}
}

impl<'a> Read for Buffer<'a> {
impl Read for Buffer<'_> {
#[inline]
fn read_exact(&mut self, bytes: &mut [u8]) -> IoResult<()> {
let n = bytes.len();
Expand Down
18 changes: 9 additions & 9 deletions plonky2/src/util/strided_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'a, P: PackedField> PackedStridedView<'a, P> {
}
}

impl<'a, P: PackedField> Index<usize> for PackedStridedView<'a, P> {
impl<P: PackedField> Index<usize> for PackedStridedView<'_, P> {
type Output = P;
#[inline]
fn index(&self, index: usize) -> &Self::Output {
Expand Down Expand Up @@ -182,7 +182,7 @@ pub struct PackedStridedViewIter<'a, P: PackedField> {
_phantom: PhantomData<&'a [P::Scalar]>,
}

impl<'a, P: PackedField> PackedStridedViewIter<'a, P> {
impl<P: PackedField> PackedStridedViewIter<'_, P> {
pub(self) const fn new(start: *const P::Scalar, end: *const P::Scalar, stride: usize) -> Self {
Self {
start,
Expand Down Expand Up @@ -215,7 +215,7 @@ impl<'a, P: PackedField> Iterator for PackedStridedViewIter<'a, P> {
}
}

impl<'a, P: PackedField> DoubleEndedIterator for PackedStridedViewIter<'a, P> {
impl<P: PackedField> DoubleEndedIterator for PackedStridedViewIter<'_, P> {
fn next_back(&mut self) -> Option<Self::Item> {
debug_assert_eq!(
(self.end as usize).wrapping_sub(self.start as usize)
Expand All @@ -241,7 +241,7 @@ pub trait Viewable<F> {
fn view(&self, index: F) -> Self::View;
}

impl<'a, P: PackedField> Viewable<Range<usize>> for PackedStridedView<'a, P> {
impl<P: PackedField> Viewable<Range<usize>> for PackedStridedView<'_, P> {
type View = Self;
fn view(&self, range: Range<usize>) -> Self::View {
assert!(range.start <= self.len(), "Invalid access");
Expand All @@ -257,7 +257,7 @@ impl<'a, P: PackedField> Viewable<Range<usize>> for PackedStridedView<'a, P> {
}
}

impl<'a, P: PackedField> Viewable<RangeFrom<usize>> for PackedStridedView<'a, P> {
impl<P: PackedField> Viewable<RangeFrom<usize>> for PackedStridedView<'_, P> {
type View = Self;
fn view(&self, range: RangeFrom<usize>) -> Self::View {
assert!(range.start <= self.len(), "Invalid access");
Expand All @@ -272,14 +272,14 @@ impl<'a, P: PackedField> Viewable<RangeFrom<usize>> for PackedStridedView<'a, P>
}
}

impl<'a, P: PackedField> Viewable<RangeFull> for PackedStridedView<'a, P> {
impl<P: PackedField> Viewable<RangeFull> for PackedStridedView<'_, P> {
type View = Self;
fn view(&self, _range: RangeFull) -> Self::View {
*self
}
}

impl<'a, P: PackedField> Viewable<RangeInclusive<usize>> for PackedStridedView<'a, P> {
impl<P: PackedField> Viewable<RangeInclusive<usize>> for PackedStridedView<'_, P> {
type View = Self;
fn view(&self, range: RangeInclusive<usize>) -> Self::View {
assert!(*range.start() <= self.len(), "Invalid access");
Expand All @@ -295,7 +295,7 @@ impl<'a, P: PackedField> Viewable<RangeInclusive<usize>> for PackedStridedView<'
}
}

impl<'a, P: PackedField> Viewable<RangeTo<usize>> for PackedStridedView<'a, P> {
impl<P: PackedField> Viewable<RangeTo<usize>> for PackedStridedView<'_, P> {
type View = Self;
fn view(&self, range: RangeTo<usize>) -> Self::View {
assert!(range.end <= self.len(), "Invalid access");
Expand All @@ -308,7 +308,7 @@ impl<'a, P: PackedField> Viewable<RangeTo<usize>> for PackedStridedView<'a, P> {
}
}

impl<'a, P: PackedField> Viewable<RangeToInclusive<usize>> for PackedStridedView<'a, P> {
impl<P: PackedField> Viewable<RangeToInclusive<usize>> for PackedStridedView<'_, P> {
type View = Self;
fn view(&self, range: RangeToInclusive<usize>) -> Self::View {
assert!(range.end < self.len(), "Invalid access");
Expand Down
Loading

0 comments on commit 7959bd2

Please sign in to comment.