Skip to content
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
3 changes: 1 addition & 2 deletions noir_stdlib/src/collections/umap.nr
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ impl<K, V, B> UHashMap<K, V, B> {
{
// docs:end:contains_key
/// Safety: unconstrained context
unsafe { self.get(key) }
.is_some()
unsafe { self.get(key) }.is_some()
}

// Returns true if the map contains no elements.
Expand Down
22 changes: 22 additions & 0 deletions tooling/nargo_fmt/src/formatter/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> {

// Now write any leading comment respecting multiple newlines after them
group.leading_comment(self.chunk(|formatter| {
// Doc comments for a let statement could come before a potential non-doc comment
if formatter.token.kind() == TokenKind::OuterDocComment {
formatter.format_outer_doc_comments();
}

formatter.skip_comments_and_whitespace_writing_multiple_lines_if_found();

// Or doc comments could come after a potential non-doc comment
if formatter.token.kind() == TokenKind::OuterDocComment {
formatter.format_outer_doc_comments();
}
}));

ignore_next |= self.ignore_next;
Expand Down Expand Up @@ -390,6 +397,21 @@ mod tests {
assert_format(src, expected);
}

#[test]
fn format_let_statement_with_unsafe_and_comment_before_it() {
let src = " fn foo() {
// Some comment
/// Safety: some doc
let x = unsafe { 1 } ; } ";
let expected = "fn foo() {
// Some comment
/// Safety: some doc
let x = unsafe { 1 };
}
";
assert_format(src, expected);
}

#[test]
fn format_assign() {
let src = " fn foo() { x = 2 ; } ";
Expand Down