Skip to content

Commit e011546

Browse files
committed
feat: LSP auto-import completion (noir-lang/noir#5741)
fix: Allow comptime code to use break without also being `unconstrained` (noir-lang/noir#5744) feat: add `Expr::as_any_integer` and `Expr::as_member_access` (noir-lang/noir#5742) chore: clarify Field use (noir-lang/noir#5740) feat: add `Expr::as_binary_op` (noir-lang/noir#5734) chore(docs): expanding solidity verifier chain list (noir-lang/noir#5587) chore: apply some new lints across workspace (noir-lang/noir#5736) feat: suggest trait methods in LSP completion (noir-lang/noir#5735) feat: LSP autocomplete constructor fields (noir-lang/noir#5732) feat: add `Expr::as_unary` (noir-lang/noir#5731) chore: count brillig opcodes in nargo info (noir-lang/noir#5189) feat: suggest tuple fields in LSP completion (noir-lang/noir#5730) feat: add `Expr::as_bool` (noir-lang/noir#5729) feat: add `Expr` methods: `as_tuple`, `as_parenthesized`, `as_index`, `as_if` (noir-lang/noir#5726) feat: LSP signature help (noir-lang/noir#5725) chore: split LSP completion.rs into several files (noir-lang/noir#5723) feat: add `TraitImpl::trait_generic_args` and `TraitImpl::methods` (noir-lang/noir#5722) fix: let LSP autocompletion work in more contexts (noir-lang/noir#5719) fix(frontend): Continue type check if we are missing an unsafe block (noir-lang/noir#5720) feat: add `unsafe` blocks for calling unconstrained code from constrained functions (noir-lang/noir#4429)
2 parents 76e6166 + f988fa7 commit e011546

File tree

70 files changed

+1012
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1012
-144
lines changed

.noir-sync-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e2f7e950c44883228d5e1230b04c83e479de7ed0
1+
cdbb940a883ae32dd84c667ec06b0d155f2d7520

noir/noir-repo/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ rust-version = "1.74.1"
5050
license = "MIT OR Apache-2.0"
5151
repository = "https://github.com/noir-lang/noir/"
5252

53+
[workspace.lints.rust]
54+
trivial_casts = "warn"
55+
trivial_numeric_casts = "warn"
56+
unused_import_braces = "warn"
57+
unused_qualifications = "warn"
58+
5359
[workspace.dependencies]
5460

5561
# ACVM workspace dependencies

noir/noir-repo/acvm-repo/acir/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/acir/src/circuit/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl ErrorSelector {
103103
impl Serialize for ErrorSelector {
104104
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
105105
where
106-
S: serde::Serializer,
106+
S: Serializer,
107107
{
108108
self.0.to_string().serialize(serializer)
109109
}
@@ -112,7 +112,7 @@ impl Serialize for ErrorSelector {
112112
impl<'de> Deserialize<'de> for ErrorSelector {
113113
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
114114
where
115-
D: serde::Deserializer<'de>,
115+
D: Deserializer<'de>,
116116
{
117117
let s: String = Deserialize::deserialize(deserializer)?;
118118
let as_u64 = s.parse().map_err(serde::de::Error::custom)?;
@@ -224,7 +224,7 @@ impl<F> Circuit<F> {
224224
}
225225

226226
impl<F: Serialize> Program<F> {
227-
fn write<W: std::io::Write>(&self, writer: W) -> std::io::Result<()> {
227+
fn write<W: Write>(&self, writer: W) -> std::io::Result<()> {
228228
let buf = bincode::serialize(self).unwrap();
229229
let mut encoder = flate2::write::GzEncoder::new(writer, Compression::default());
230230
encoder.write_all(&buf)?;
@@ -250,7 +250,7 @@ impl<F: Serialize> Program<F> {
250250
}
251251

252252
impl<F: for<'a> Deserialize<'a>> Program<F> {
253-
fn read<R: std::io::Read>(reader: R) -> std::io::Result<Self> {
253+
fn read<R: Read>(reader: R) -> std::io::Result<Self> {
254254
let mut gz_decoder = flate2::read::GzDecoder::new(reader);
255255
let mut buf_d = Vec::new();
256256
gz_decoder.read_to_end(&mut buf_d)?;

noir/noir-repo/acvm-repo/acir_field/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/acir_field/src/field_element.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<F: PrimeField> From<i128> for FieldElement<F> {
115115
}
116116
}
117117

118-
impl<T: ark_ff::PrimeField> Serialize for FieldElement<T> {
118+
impl<T: PrimeField> Serialize for FieldElement<T> {
119119
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
120120
where
121121
S: serde::Serializer,
@@ -124,7 +124,7 @@ impl<T: ark_ff::PrimeField> Serialize for FieldElement<T> {
124124
}
125125
}
126126

127-
impl<'de, T: ark_ff::PrimeField> Deserialize<'de> for FieldElement<T> {
127+
impl<'de, T: PrimeField> Deserialize<'de> for FieldElement<T> {
128128
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
129129
where
130130
D: serde::Deserializer<'de>,

noir/noir-repo/acvm-repo/acir_field/src/generic_ark.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use num_bigint::BigUint;
22

33
/// This trait is extremely unstable and WILL have breaking changes.
44
pub trait AcirField:
5-
std::marker::Sized
5+
Sized
66
+ std::fmt::Display
77
+ std::fmt::Debug
88
+ Default
@@ -24,7 +24,7 @@ pub trait AcirField:
2424
// + From<u8>
2525
+ From<bool>
2626
+ std::hash::Hash
27-
+ std::cmp::Eq
27+
+ Eq
2828
{
2929
fn one() -> Self;
3030
fn zero() -> Self;

noir/noir-repo/acvm-repo/acvm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/acvm_js/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[lib]

noir/noir-repo/acvm-repo/acvm_js/src/js_execution_error.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@ impl JsExecutionError {
5454
None => JsValue::UNDEFINED,
5555
};
5656
let assertion_payload = match assertion_payload {
57-
Some(raw) => <wasm_bindgen::JsValue as JsValueSerdeExt>::from_serde(&raw)
57+
Some(raw) => <JsValue as JsValueSerdeExt>::from_serde(&raw)
5858
.expect("Cannot serialize assertion payload"),
5959
None => JsValue::UNDEFINED,
6060
};
6161

6262
let brillig_function_id = match brillig_function_id {
63-
Some(function_id) => {
64-
<wasm_bindgen::JsValue as JsValueSerdeExt>::from_serde(&function_id)
65-
.expect("Cannot serialize Brillig function id")
66-
}
63+
Some(function_id) => <JsValue as JsValueSerdeExt>::from_serde(&function_id)
64+
.expect("Cannot serialize Brillig function id"),
6765
None => JsValue::UNDEFINED,
6866
};
6967

noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/bn254_blackbox_solver/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/bn254_blackbox_solver/src/generator/generators.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ mod test {
9191
fn test_derive_generators() {
9292
let res = derive_generators("test domain".as_bytes(), 128, 0);
9393

94-
let is_unique = |y: Affine<grumpkin::GrumpkinParameters>, j: usize| -> bool {
94+
let is_unique = |y: Affine<GrumpkinParameters>, j: usize| -> bool {
9595
for (i, res) in res.iter().enumerate() {
9696
if i != j && *res == y {
9797
return false;

noir/noir-repo/acvm-repo/brillig/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/brillig_vm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/aztec_macros/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ rust-version.workspace = true
77
license.workspace = true
88
repository.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1114

1215
[dependencies]

noir/noir-repo/compiler/fm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ edition.workspace = true
66
rust-version.workspace = true
77
license.workspace = true
88

9+
[lints]
10+
workspace = true
11+
912
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1013

1114
[dependencies]

noir/noir-repo/compiler/noirc_arena/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ authors.workspace = true
55
edition.workspace = true
66
rust-version.workspace = true
77
license.workspace = true
8+
9+
[lints]
10+
workspace = true

noir/noir-repo/compiler/noirc_driver/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ edition.workspace = true
66
rust-version.workspace = true
77
license.workspace = true
88

9+
[lints]
10+
workspace = true
11+
912
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1013

1114
[build-dependencies]

noir/noir-repo/compiler/noirc_driver/src/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,8 @@ pub fn check_crate(
274274
crate_id: CrateId,
275275
options: &CompileOptions,
276276
) -> CompilationResult<()> {
277-
let macros: &[&dyn MacroProcessor] = if options.disable_macros {
278-
&[]
279-
} else {
280-
&[&aztec_macros::AztecMacro as &dyn MacroProcessor]
281-
};
277+
let macros: &[&dyn MacroProcessor] =
278+
if options.disable_macros { &[] } else { &[&aztec_macros::AztecMacro] };
282279

283280
let mut errors = vec![];
284281
let diagnostics = CrateDefMap::collect_defs(

noir/noir-repo/compiler/noirc_errors/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ edition.workspace = true
66
rust-version.workspace = true
77
license.workspace = true
88

9+
[lints]
10+
workspace = true
11+
912
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1013

1114
[dependencies]

noir/noir-repo/compiler/noirc_errors/src/position.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Spanned<T> {
1616

1717
/// This is important for tests. Two Spanned objects are equal if their content is equal
1818
/// They may not have the same span. Use into_span to test for Span being equal specifically
19-
impl<T: std::cmp::PartialEq> PartialEq<Spanned<T>> for Spanned<T> {
19+
impl<T: PartialEq> PartialEq<Spanned<T>> for Spanned<T> {
2020
fn eq(&self, other: &Spanned<T>) -> bool {
2121
self.contents == other.contents
2222
}

noir/noir-repo/compiler/noirc_evaluator/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ edition.workspace = true
66
rust-version.workspace = true
77
license.workspace = true
88

9+
[lints]
10+
workspace = true
11+
912
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1013

1114
[dependencies]

noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,7 @@ impl<F: PartialEq> PartialEq for AcirVarData<F> {
20052005
}
20062006

20072007
// TODO: check/test this hash impl
2008-
impl<F> std::hash::Hash for AcirVarData<F> {
2008+
impl<F> Hash for AcirVarData<F> {
20092009
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
20102010
core::mem::discriminant(self).hash(state);
20112011
}

noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl Debug for AcirDynamicArray {
235235
#[derive(Debug, Clone)]
236236
pub(crate) enum AcirValue {
237237
Var(AcirVar, AcirType),
238-
Array(im::Vector<AcirValue>),
238+
Array(Vector<AcirValue>),
239239
DynamicArray(AcirDynamicArray),
240240
}
241241

@@ -1650,7 +1650,7 @@ impl<'a> Context<'a> {
16501650
let read = self.acir_context.read_from_memory(source, &index_var)?;
16511651
Ok::<AcirValue, RuntimeError>(AcirValue::Var(read, AcirType::field()))
16521652
})?;
1653-
let array: im::Vector<AcirValue> = init_values.into();
1653+
let array: Vector<AcirValue> = init_values.into();
16541654
self.initialize_array(destination, array_len, Some(AcirValue::Array(array)))?;
16551655
Ok(())
16561656
}

noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/dfg.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@ impl DataFlowGraph {
171171
ctrl_typevars: Option<Vec<Type>>,
172172
call_stack: CallStack,
173173
) -> InsertInstructionResult {
174-
use InsertInstructionResult::*;
175174
match instruction.simplify(self, block, ctrl_typevars.clone(), &call_stack) {
176-
SimplifyResult::SimplifiedTo(simplification) => SimplifiedTo(simplification),
175+
SimplifyResult::SimplifiedTo(simplification) => {
176+
InsertInstructionResult::SimplifiedTo(simplification)
177+
}
177178
SimplifyResult::SimplifiedToMultiple(simplification) => {
178-
SimplifiedToMultiple(simplification)
179+
InsertInstructionResult::SimplifiedToMultiple(simplification)
179180
}
180-
SimplifyResult::Remove => InstructionRemoved,
181+
SimplifyResult::Remove => InsertInstructionResult::InstructionRemoved,
181182
result @ (SimplifyResult::SimplifiedToInstruction(_)
182183
| SimplifyResult::SimplifiedToInstructionMultiple(_)
183184
| SimplifyResult::None) => {

noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<T> Id<T> {
5050
// Need to manually implement most impls on Id.
5151
// Otherwise rust assumes that Id<T>: Hash only if T: Hash,
5252
// which isn't true since the T is not used internally.
53-
impl<T> std::hash::Hash for Id<T> {
53+
impl<T> Hash for Id<T> {
5454
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
5555
self.index.hash(state);
5656
}

noir/noir-repo/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub(super) struct Loop {
8585
}
8686

8787
/// The queue of functions remaining to compile
88-
type FunctionQueue = Vec<(ast::FuncId, IrFunctionId)>;
88+
type FunctionQueue = Vec<(FuncId, IrFunctionId)>;
8989

9090
impl<'a> FunctionContext<'a> {
9191
/// Create a new FunctionContext to compile the first function in the shared_context's
@@ -1005,14 +1005,14 @@ impl SharedContext {
10051005
}
10061006

10071007
/// Pops the next function from the shared function queue, returning None if the queue is empty.
1008-
pub(super) fn pop_next_function_in_queue(&self) -> Option<(ast::FuncId, IrFunctionId)> {
1008+
pub(super) fn pop_next_function_in_queue(&self) -> Option<(FuncId, IrFunctionId)> {
10091009
self.function_queue.lock().expect("Failed to lock function_queue").pop()
10101010
}
10111011

10121012
/// Return the matching id for the given function if known. If it is not known this
10131013
/// will add the function to the queue of functions to compile, assign it a new id,
10141014
/// and return this new id.
1015-
pub(super) fn get_or_queue_function(&self, id: ast::FuncId) -> IrFunctionId {
1015+
pub(super) fn get_or_queue_function(&self, id: FuncId) -> IrFunctionId {
10161016
// Start a new block to guarantee the destructor for the map lock is released
10171017
// before map needs to be acquired again in self.functions.write() below
10181018
{

noir/noir-repo/compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,11 @@ impl<'a> FunctionContext<'a> {
396396
/// return a reference to each element, for use with the store instruction.
397397
fn codegen_array_index(
398398
&mut self,
399-
array: super::ir::value::ValueId,
400-
index: super::ir::value::ValueId,
399+
array: ValueId,
400+
index: ValueId,
401401
element_type: &ast::Type,
402402
location: Location,
403-
length: Option<super::ir::value::ValueId>,
403+
length: Option<ValueId>,
404404
) -> Result<Values, RuntimeError> {
405405
// base_index = index * type_size
406406
let index = self.make_array_index(index);
@@ -438,11 +438,7 @@ impl<'a> FunctionContext<'a> {
438438
/// Prepare a slice access.
439439
/// Check that the index being used to access a slice element
440440
/// is less than the dynamic slice length.
441-
fn codegen_slice_access_check(
442-
&mut self,
443-
index: super::ir::value::ValueId,
444-
length: Option<super::ir::value::ValueId>,
445-
) {
441+
fn codegen_slice_access_check(&mut self, index: ValueId, length: Option<ValueId>) {
446442
let index = self.make_array_index(index);
447443
// We convert the length as an array index type for comparison
448444
let array_len = self

0 commit comments

Comments
 (0)