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: Move templated code for assert_message into the stdlib #4475

Merged
merged 4 commits into from
Mar 6, 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
9 changes: 0 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[workspace]

members = [
# Macros crates for metaprogramming
# Aztec Macro crate for metaprogramming
"aztec_macros",
"noirc_macros",
# Compiler crates
"compiler/noirc_evaluator",
"compiler/noirc_frontend",
Expand Down
1 change: 0 additions & 1 deletion compiler/noirc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ tracing.workspace = true
thiserror.workspace = true

aztec_macros = { path = "../../aztec_macros" }
noirc_macros = { path = "../../noirc_macros" }
7 changes: 2 additions & 5 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,9 @@ pub fn check_crate(
disable_macros: bool,
) -> CompilationResult<()> {
let macros: Vec<&dyn MacroProcessor> = if disable_macros {
vec![&noirc_macros::AssertMessageMacro as &dyn MacroProcessor]
vec![]
} else {
vec![
&aztec_macros::AztecMacro as &dyn MacroProcessor,
&noirc_macros::AssertMessageMacro as &dyn MacroProcessor,
]
vec![&aztec_macros::AztecMacro as &dyn MacroProcessor]
};

let mut errors = vec![];
Expand Down
8 changes: 6 additions & 2 deletions compiler/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,13 +1256,17 @@ impl<'a> Resolver<'a> {
let is_in_stdlib = self.path_resolver.module_id().krate.is_stdlib();
let assert_msg_call_path = if is_in_stdlib {
ExpressionKind::Variable(Path {
segments: vec![Ident::from("resolve_assert_message")],
segments: vec![Ident::from("internal"), Ident::from("resolve_assert_message")],
kind: PathKind::Crate,
span,
})
} else {
ExpressionKind::Variable(Path {
segments: vec![Ident::from("std"), Ident::from("resolve_assert_message")],
segments: vec![
Ident::from("std"),
Ident::from("internal"),
Ident::from("resolve_assert_message"),
],
kind: PathKind::Dep,
span,
})
Expand Down
12 changes: 12 additions & 0 deletions noir_stdlib/src/internal.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file contains functions which should only be used in calls injected by the Noir compiler.
// These functions should not be called manually in user code.
//
// Changes to this file will not be considered breaking.

#[oracle(assert_message)]
unconstrained fn assert_message_oracle<T>(_input: T) {}
unconstrained pub fn resolve_assert_message<T>(input: T, condition: bool) {
if !condition {
assert_message_oracle(input);
}
}
1 change: 1 addition & 0 deletions noir_stdlib/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod default;
mod prelude;
mod uint128;
mod bigint;
mod internal;

// Oracle calls are required to be wrapped in an unconstrained function
// Thus, the only argument to the `println` oracle is expected to always be an ident
Expand Down
14 changes: 0 additions & 14 deletions noirc_macros/Cargo.toml

This file was deleted.

73 changes: 0 additions & 73 deletions noirc_macros/src/lib.rs

This file was deleted.

Loading