Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clippy suggestions
Browse files Browse the repository at this point in the history
zslayton committed Jan 9, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c493eba commit 67d3db7
Showing 3 changed files with 6 additions and 22 deletions.
10 changes: 2 additions & 8 deletions src/lazy/expanded/macro_evaluator.rs
Original file line number Diff line number Diff line change
@@ -943,10 +943,7 @@ impl<'top, D: Decoder> StackedMacroEvaluator<'top, D> {
/// current encoding context and push the resulting `MacroExpansion` onto the stack.
pub fn push(&mut self, invocation: impl Into<MacroExpr<'top, D>>) -> IonResult<()> {
let macro_expr = invocation.into();
let expansion = match macro_expr.expand() {
Ok(expansion) => expansion,
Err(e) => return Err(e),
};
let expansion = macro_expr.expand()?;
self.macro_stack.push(expansion);
Ok(())
}
@@ -989,10 +986,7 @@ impl<'top, D: Decoder> StackedMacroEvaluator<'top, D> {
Some(expansion) => expansion,
};
// Ask that expansion to continue its evaluation by one step.
let step = match current_expansion.next_step() {
Ok(step) => step,
Err(e) => return Err(e),
};
let step = current_expansion.next_step()?;
current_expansion.is_complete = step.is_final();
use ValueExpr::*;
let maybe_output_value = match step.value_expr() {
16 changes: 3 additions & 13 deletions src/lazy/expanded/mod.rs
Original file line number Diff line number Diff line change
@@ -558,10 +558,7 @@ impl<Encoding: Decoder, Input: IonInput> ExpandingReader<Encoding, Input> {
// It's another macro invocation, we'll add it to the evaluator so it will be evaluated
// on the next call and then we'll return the e-expression itself.
EExp(e_exp) => {
let resolved_e_exp = match e_exp.resolve(context_ref) {
Ok(resolved) => resolved,
Err(e) => return Err(e),
};
let resolved_e_exp = e_exp.resolve(context_ref)?;

// Get the current evaluator or make a new one
let evaluator = match self.evaluator_ptr.get() {
@@ -639,10 +636,7 @@ impl<Encoding: Decoder, Input: IonInput> ExpandingReader<Encoding, Input> {
}
// It's another macro invocation, we'll start evaluating it.
EExp(e_exp) => {
let resolved_e_exp = match e_exp.resolve(context_ref) {
Ok(resolved) => resolved,
Err(e) => return Err(e),
};
let resolved_e_exp = e_exp.resolve(context_ref)?;

// If this e-expression invokes a template with a non-system, singleton expansion, we can use the
// e-expression to back a LazyExpandedValue. It will only be evaluated if the user calls `read()`.
@@ -664,11 +658,7 @@ impl<Encoding: Decoder, Input: IonInput> ExpandingReader<Encoding, Input> {
};

// Try to get a value by starting to evaluate the e-expression.
let next_value = match evaluator.next() {
Ok(value) => value,
Err(e) => return Err(e),
};
if let Some(value) = next_value {
if let Some(value) = evaluator.next()? {
// If we get a value and the evaluator isn't empty yet, save its pointer
// so we can try to get more out of it when `next_at_or_above_depth` is called again.
if !evaluator.is_empty() {
2 changes: 1 addition & 1 deletion src/lazy/expanded/struct.rs
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ impl<'top, D: Decoder> LazyExpandedField<'top, D> {
self.name
}

pub fn to_field_expr(&self) -> FieldExpr<'top, D> {
pub fn to_field_expr(self) -> FieldExpr<'top, D> {
FieldExpr::NameValue(self.name(), self.value())
}
}

0 comments on commit 67d3db7

Please sign in to comment.