Skip to content

Commit 8acf029

Browse files
committed
Merge branch 'master' into tf/break-up-traits
* master: fix(experimental elaborator): Avoid calling `add_generics` twice on trait methods (#5108) fix(experimental elaborator): Fix duplicate `resolve_type` on self type and don't leak a trait impl's generics (#5102) feat: replace stdlib poseidon implementation with optimized version (#5122) fix(experimental elaborator): Only call `add_generics` once (#5091) fix(experimental elaborator): Fix panic in the elaborator (#5082) chore: move `is_native_field` up into `noirc_frontend` (#5119)
2 parents c463f2c + 7d8c0a3 commit 8acf029

File tree

25 files changed

+25504
-556
lines changed

25 files changed

+25504
-556
lines changed

Cargo.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acvm-repo/acir_field/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ repository.workspace = true
1616
hex.workspace = true
1717
num-bigint.workspace = true
1818
serde.workspace = true
19-
num-traits.workspace = true
2019

2120
ark-bn254 = { version = "^0.4.0", default-features = false, features = ["curve"] }
2221
ark-bls12-381 = { version = "^0.4.0", optional = true, default-features = false, features = ["curve"] }

acvm-repo/acir_field/src/lib.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#![warn(clippy::semicolon_if_nothing_returned)]
44
#![cfg_attr(not(test), warn(unused_crate_dependencies, unused_extern_crates))]
55

6-
use num_bigint::BigUint;
7-
use num_traits::Num;
8-
96
mod field_element;
107
mod generic_ark;
118

@@ -17,40 +14,11 @@ pub use field_element::FieldElement as GenericFieldElement;
1714
cfg_if::cfg_if! {
1815
if #[cfg(feature = "bls12_381")] {
1916
pub type FieldElement = field_element::FieldElement<ark_bls12_381::Fr>;
20-
pub const CHOSEN_FIELD : FieldOptions = FieldOptions::BLS12_381;
2117
} else {
2218
pub type FieldElement = field_element::FieldElement<ark_bn254::Fr>;
23-
pub const CHOSEN_FIELD : FieldOptions = FieldOptions::BN254;
2419
}
2520
}
2621

27-
#[derive(Debug, PartialEq, Eq)]
28-
pub enum FieldOptions {
29-
BN254,
30-
BLS12_381,
31-
}
32-
33-
impl FieldOptions {
34-
pub fn to_string(&self) -> &str {
35-
match self {
36-
FieldOptions::BN254 => "bn254",
37-
FieldOptions::BLS12_381 => "bls12_381",
38-
}
39-
}
40-
41-
pub fn is_native_field(str: &str) -> bool {
42-
let big_num = if let Some(hex) = str.strip_prefix("0x") {
43-
BigUint::from_str_radix(hex, 16)
44-
} else {
45-
BigUint::from_str_radix(str, 10)
46-
};
47-
if let Ok(big_num) = big_num {
48-
big_num == FieldElement::modulus()
49-
} else {
50-
CHOSEN_FIELD.to_string() == str
51-
}
52-
}
53-
}
5422
// This is needed because features are additive through the dependency graph; if a dependency turns on the bn254, then it
5523
// will be turned on in all crates that depend on it
5624
#[macro_export]

compiler/noirc_frontend/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ smol_str.workspace = true
2121
im.workspace = true
2222
serde_json.workspace = true
2323
serde.workspace = true
24+
num-bigint.workspace = true
25+
num-traits.workspace = true
2426
rustc-hash = "1.1.0"
2527
small-ord-set = "0.1.3"
2628
regex = "1.9.1"
29+
cfg-if = "1.0.0"
2730
tracing.workspace = true
2831
petgraph = "0.6"
2932
lalrpop-util = { version = "0.20.2", features = ["lexer"] }
3033

34+
3135
[dev-dependencies]
3236
base64.workspace = true
3337
strum = "0.24"
@@ -39,3 +43,5 @@ lalrpop = "0.20.2"
3943

4044
[features]
4145
experimental_parser = []
46+
bn254 = []
47+
bls12_381 = []

compiler/noirc_frontend/src/elaborator/expressions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use crate::{
1515
hir_def::{
1616
expr::{
1717
HirArrayLiteral, HirBinaryOp, HirBlockExpression, HirCallExpression, HirCastExpression,
18-
HirConstructorExpression, HirIdent, HirIfExpression, HirIndexExpression,
19-
HirInfixExpression, HirLambda, HirMemberAccess, HirMethodCallExpression,
20-
HirMethodReference, HirPrefixExpression,
18+
HirConstructorExpression, HirIfExpression, HirIndexExpression, HirInfixExpression,
19+
HirLambda, HirMemberAccess, HirMethodCallExpression, HirMethodReference,
20+
HirPrefixExpression,
2121
},
2222
traits::TraitConstraint,
2323
},
@@ -84,10 +84,10 @@ impl<'context> Elaborator<'context> {
8484
expr_type: inner_expr_type.clone(),
8585
expr_span: span,
8686
});
87+
}
8788

88-
if i + 1 == statements.len() {
89-
block_type = stmt_type;
90-
}
89+
if i + 1 == statements.len() {
90+
block_type = stmt_type;
9191
}
9292
}
9393

0 commit comments

Comments
 (0)