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

feat: Sync from aztec-packages #4444

Merged
merged 3 commits into from
Feb 28, 2024
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
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e69b58660ff843350e1e098d8f1a84f4ce3d3c34
9e246c1289fa40c35c4b28d2f0081dfdc2aa9d19
8 changes: 5 additions & 3 deletions aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@

// Abstract return types such that they get added to the kernel's return_values
if let Some(return_values) = abstract_return_values(func) {
// In case we are pushing return values to the context, we remove the statement that originated it
// This avoids running duplicate code, since blocks like if/else can be value returning statements
func.def.body.0.pop();
// Add the new return statement
func.def.body.0.push(return_values);
}

Expand Down Expand Up @@ -1255,13 +1259,11 @@
/// Any primitive type that can be cast will be casted to a field and pushed to the context.
fn abstract_return_values(func: &NoirFunction) -> Option<Statement> {
let current_return_type = func.return_type().typ;
let len = func.def.body.len();
let last_statement = &func.def.body.0[len - 1];
let last_statement = func.def.body.0.last()?;

// TODO: (length, type) => We can limit the size of the array returned to be limited by kernel size
// Doesn't need done until we have settled on a kernel size
// TODO: support tuples here and in inputs -> convert into an issue

// Check if the return type is an expression, if it is, we can handle it
match last_statement {
Statement { kind: StatementKind::Expression(expression), .. } => {
Expand Down Expand Up @@ -1656,8 +1658,8 @@
// If compute_note_hash_and_nullifier is already defined by the user, we skip auto-generation in order to provide an
// escape hatch for this mechanism.
// TODO(#4647): improve this diagnosis and error messaging.
if collected_functions.iter().any(|coll_funcs_data| {

Check warning on line 1661 in aztec_macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (funcs)
check_for_compute_note_hash_and_nullifier_definition(&coll_funcs_data.functions, module_id)

Check warning on line 1662 in aztec_macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (funcs)
}) {
return Ok(());
}
Expand Down Expand Up @@ -1711,7 +1713,7 @@
unresolved_traits_impls: &[UnresolvedTraitImpl],
trait_name: &str,
) -> Vec<String> {
let mut struct_typenames: Vec<String> = Vec::new();

Check warning on line 1716 in aztec_macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typenames)

// These structs can be declared in either external crates or the current one. External crates that contain
// dependencies have already been processed and resolved, but are available here via the NodeInterner. Note that
Expand All @@ -1721,7 +1723,7 @@

if trait_impl.borrow().ident.0.contents == *trait_name {
if let Type::Struct(s, _) = &trait_impl.borrow().typ {
struct_typenames.push(s.borrow().name.0.contents.clone());

Check warning on line 1726 in aztec_macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typenames)
} else {
panic!("Found impl for {} on non-Struct", trait_name);
}
Expand All @@ -1729,7 +1731,7 @@
}

// This crate's traits and impls have not yet been resolved, so we look for impls in unresolved_trait_impls.
struct_typenames.extend(

Check warning on line 1734 in aztec_macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typenames)
unresolved_traits_impls
.iter()
.filter(|trait_impl| {
Expand All @@ -1750,7 +1752,7 @@
}),
);

struct_typenames

Check warning on line 1755 in aztec_macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typenames)
}

fn generate_compute_note_hash_and_nullifier(note_types: &Vec<String>) -> NoirFunction {
Expand Down
Loading