Skip to content

Commit

Permalink
🥢 Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Philogy committed Oct 19, 2024
1 parent a20a79c commit 157d193
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crates/analysis/src/label_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ impl<'a> LabelStack<'a, ()> {
self.insert(label, ());
}
}

impl<'a, V> Default for LabelStack<'a, V> {
fn default() -> Self {
Self::new()
}
}
12 changes: 9 additions & 3 deletions crates/analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn analyze_entry_point<'src, 'ast: 'src, E: FnMut(AnalysisError<'ast, 'src>)
) {
let mut analyzed_macros: BTreeSet<&str> = BTreeSet::new();
let mut invoke_stack: Vec<(&'ast Macro<'src>, &'ast Invoke<'src>)> = Vec::with_capacity(32);
let mut label_stack: LabelStack<'src, ()> = LabelStack::new();
let mut label_stack = LabelStack::default();

analyze_macro(
global_defs,
Expand Down Expand Up @@ -147,14 +147,20 @@ fn analyze_macro<'ast: 'src, 'src, E: FnMut(AnalysisError<'ast, 'src>)>(
m.body.iter().for_each(|stmt| match stmt {
MacroStatement::LabelDefinition(_) => {}
MacroStatement::Instruction(instruction) => {
analyze_instruction(instruction, label_stack).map(|err| emit_error(err));
if let Some(err) = analyze_instruction(instruction, label_stack) {
emit_error(err);
}
}
MacroStatement::Invoke(invoke) => match invoke {
Invoke::Macro { name, args } => {
// Check the arguments in the invocatino.
args.iter()
.filter_map(|arg| analyze_instruction(arg, label_stack))
.for_each(|err| emit_error(err));
.for_each(
// Not actually redundant so making clippy stfu here.
#[allow(clippy::redundant_closure)]
|err| emit_error(err),
);
// Emit error if we don't find at least 1 macro by the given name.
if !global_exists!(global_defs, name.ident(), Definition::Macro(_)) {
emit_error(AnalysisError::DefinitionNotFound {
Expand Down

0 comments on commit 157d193

Please sign in to comment.