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: remove curly braces with fmt #4529

2 changes: 1 addition & 1 deletion noir_stdlib/src/array.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::cmp::{Ord};
use crate::cmp::Ord;

// TODO: Once we fully move to the new SSA pass this module can be removed and replaced
// by the methods in the `slice` module
Expand Down
9 changes: 8 additions & 1 deletion tooling/nargo_fmt/src/rewrite/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ impl UseTree {

let mut iter = self.path.iter().peekable();
while let Some(segment) = iter.next() {
let segment_str = segment.rewrite(visitor, shape);
let mut segment_str = segment.rewrite(visitor, shape);
if segment_str.contains('{')
&& !segment_str.contains(',')
&& !segment_str.contains("::")
{
let empty = "";
segment_str = segment_str.replace(['{', '}'], empty);
}
result.push_str(&segment_str);

if iter.peek().is_some() {
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_fmt/tests/expected/contract.nr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract Benchmarking {
context::Context, note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader},
log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet},
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN},
types::address::{AztecAddress}
types::address::AztecAddress
};

struct Storage {
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_fmt/tests/expected/import_braces.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use dep::std::hash::sha256;
2 changes: 1 addition & 1 deletion tooling/nargo_fmt/tests/input/contract.nr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract Benchmarking {
context::Context, note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader},
log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet},
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN},
types::address::{AztecAddress}
types::address::AztecAddress
jfecher marked this conversation as resolved.
Show resolved Hide resolved
};

struct Storage {
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_fmt/tests/input/import_braces.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use dep::std::hash::{sha256};
Loading