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

swayfmt: fix indentation after where in fn (#5468) #5578

Merged
merged 5 commits into from
Feb 13, 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
8 changes: 4 additions & 4 deletions sway-lib-std/src/storage/storage_map.sw
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
pub fn insert(self, key: K, value: V)
where
K: Hash,
{
{
let key = sha256((key, self.field_id));
write::<V>(key, 0, value);
}
Expand Down Expand Up @@ -87,7 +87,7 @@ where
pub fn get(self, key: K) -> StorageKey<V>
where
K: Hash,
{
{
StorageKey::<V>::new(
sha256((key, self.field_id)),
0,
Expand Down Expand Up @@ -129,7 +129,7 @@ where
pub fn remove(self, key: K) -> bool
where
K: Hash,
{
{
let key = sha256((key, self.slot));
clear::<V>(key, 0)
}
Expand Down Expand Up @@ -180,7 +180,7 @@ where
pub fn try_insert(self, key: K, value: V) -> Result<V, StorageMapError<V>>
where
K: Hash,
{
{
let key = sha256((key, self.field_id));

let val = read::<V>(key, 0);
Expand Down
3 changes: 2 additions & 1 deletion swayfmt/src/items/item_fn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ impl CurlyBrace for ItemFn {
let open_brace = Delimiter::Brace.as_open_char();
match formatter.shape.code_line.has_where_clause {
true => {
write!(line, "{open_brace}")?;
let indent_str = formatter.indent_to_str()?;
write!(line, "{indent_str}{open_brace}")?;
formatter.shape.code_line.update_where_clause(false);
}
false => {
Expand Down
34 changes: 34 additions & 0 deletions swayfmt/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2903,3 +2903,37 @@ pub fn from_be_bytes(bytes: [u8; 32]) -> Self {
"#,
);
}

#[test]
fn impl_func_where() {
check(
r#"library;

impl<K, V> Foo<Bar<K, V>>
where
K: Hash,
{
pub fn baz(self, _: K, _: V)
where
K: Hash,
{
debug();
}
}
"#,
r#"library;

impl<K, V> Foo<Bar<K, V>>
where
K: Hash,
{
pub fn baz(self, _: K, _: V)
where
K: Hash,
{
debug();
}
}
"#,
);
}
Loading