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

chore: simplify a couple of enum variants #7025

Merged
merged 1 commit into from
Jan 10, 2025
Merged
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
14 changes: 7 additions & 7 deletions compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl<'brillig> Context<'brillig> {
);

match evaluation_result {
EvaluationResult::NotABrilligCall | EvaluationResult::CannotEvaluate(_) => None,
EvaluationResult::NotABrilligCall | EvaluationResult::CannotEvaluate => None,
EvaluationResult::Evaluated(memory_values) => {
let mut memory_index = 0;
let new_results = vecmap(old_results, |old_result| {
Expand Down Expand Up @@ -601,14 +601,14 @@ impl<'brillig> Context<'brillig> {
};

if !arguments.iter().all(|argument| dfg.is_constant(*argument)) {
return EvaluationResult::CannotEvaluate(*func_id);
return EvaluationResult::CannotEvaluate;
}

let mut brillig_arguments = Vec::new();
for argument in arguments {
let typ = dfg.type_of_value(*argument);
let Some(parameter) = type_to_brillig_parameter(&typ) else {
return EvaluationResult::CannotEvaluate(*func_id);
return EvaluationResult::CannotEvaluate;
};
brillig_arguments.push(parameter);
}
Expand All @@ -617,12 +617,12 @@ impl<'brillig> Context<'brillig> {
for return_id in func.returns().iter() {
let typ = func.dfg.type_of_value(*return_id);
if type_to_brillig_parameter(&typ).is_none() {
return EvaluationResult::CannotEvaluate(*func_id);
return EvaluationResult::CannotEvaluate;
}
}

let Ok(generated_brillig) = gen_brillig_for(func, brillig_arguments, brillig) else {
return EvaluationResult::CannotEvaluate(*func_id);
return EvaluationResult::CannotEvaluate;
};

let mut calldata = Vec::new();
Expand All @@ -639,7 +639,7 @@ impl<'brillig> Context<'brillig> {
VM::new(calldata, bytecode, foreign_call_results, &black_box_solver, profiling_active);
let vm_status: VMStatus<_> = vm.process_opcodes();
let VMStatus::Finished { return_data_offset, return_data_size } = vm_status else {
return EvaluationResult::CannotEvaluate(*func_id);
return EvaluationResult::CannotEvaluate;
};

let memory =
Expand Down Expand Up @@ -771,7 +771,7 @@ enum EvaluationResult {
NotABrilligCall,
/// The instruction was a call to a brillig function, but we couldn't evaluate it.
/// This can occur in the situation where the brillig function reaches a "trap" or a foreign call opcode.
CannotEvaluate(FunctionId),
CannotEvaluate,
/// The instruction was a call to a brillig function and we were able to evaluate it,
/// returning evaluation memory values.
Evaluated(Vec<MemoryValue<FieldElement>>),
Expand Down
10 changes: 4 additions & 6 deletions compiler/noirc_frontend/src/elaborator/path_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct Turbofish {
/// Any item that can appear before the last segment in a path.
#[derive(Debug)]
enum IntermediatePathResolutionItem {
Module(ModuleId),
Module,
Struct(StructId, Option<Turbofish>),
TypeAlias(TypeAliasId, Option<Turbofish>),
Trait(TraitId, Option<Turbofish>),
Expand Down Expand Up @@ -180,7 +180,7 @@ impl<'context> Elaborator<'context> {
let mut current_module_id = starting_module;
let mut current_module = self.get_module(starting_module);

let mut intermediate_item = IntermediatePathResolutionItem::Module(current_module_id);
let mut intermediate_item = IntermediatePathResolutionItem::Module;

let first_segment =
&path.segments.first().expect("ice: could not fetch first segment").ident;
Expand Down Expand Up @@ -222,7 +222,7 @@ impl<'context> Elaborator<'context> {
});
}

(id, false, IntermediatePathResolutionItem::Module(id))
(id, false, IntermediatePathResolutionItem::Module)
}
ModuleDefId::TypeId(id) => (
id.module_id(),
Expand Down Expand Up @@ -460,9 +460,7 @@ fn merge_intermediate_path_resolution_item_with_module_def_id(
ModuleDefId::TraitId(trait_id) => PathResolutionItem::Trait(trait_id),
ModuleDefId::GlobalId(global_id) => PathResolutionItem::Global(global_id),
ModuleDefId::FunctionId(func_id) => match intermediate_item {
IntermediatePathResolutionItem::Module(_) => {
PathResolutionItem::ModuleFunction(func_id)
}
IntermediatePathResolutionItem::Module => PathResolutionItem::ModuleFunction(func_id),
IntermediatePathResolutionItem::Struct(struct_id, generics) => {
PathResolutionItem::StructFunction(struct_id, generics, func_id)
}
Expand Down
Loading