Skip to contentSkip to conversation

rust: fix formatting expressions

PATCH Applied Tamir Duberstein 5 participants 7 messages Jan 4 – Jan 14 Rust

lore
Share & tools
lore

Tamir Duberstein

author reviewer
#0 lore raw

PATCH 1/1 rust: fix formatting expressions

From: Tamir Duberstein <[email protected]>

Allow usage like pr_info!("one + 1 = {}", one + 1) to compile by ensuring that a reference is taken to the entire expression.

---

---
 rust/macros/fmt.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/macros/fmt.rs +1 -1
index 2f4b9f6e2211..8354abd54502 100644
@@ -67,7 +67,7 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream {
                     }
                     (None, acc)
                 })();
-                args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs)));
+                args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs))));
             }
         };
 

---
base-commit: f8f9c1f4d0c7a64600e2ca312dec824a0bc2f1da
change-id: 20260104-fmt-paren-e92eb804a4aa

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Tamir Duberstein

From: Tamir Duberstein <[email protected]>

Allow usage like pr_info!("one + 1 = {}", one + 1) to compile by ensuring that a reference is taken to the entire expression.

---

#2 lore raw
In reply to Tamir Duberstein
Quoted 4 lines · Tamir Duberstein

---

Thanks Tamir, I will pick it into rust-fixes alongside a bunch of other pending fixes.

Quick note in case you want to double-check your scripts: somehow you ended up with two --- lines and thus the SoB outside (no need to resend).

Cheers,
Miguel

author reviewer
#3 lore raw
Quoted 10 lines · Miguel Ojeda
Quoted 4 lines · Tamir Duberstein

---

Thanks Tamir, I will pick it into rust-fixes alongside a bunch of other pending fixes.

Quoted 6 lines

Quick note in case you want to double-check your scripts: somehow you ended up with two --- lines and thus the SoB outside (no need to resend).

Cheers,
Miguel

Ah thanks for calling out - I think I just forgot to SoB the commit and so this came from the (empty) cover letter.

Thanks!
Tamir

Tested-by Reviewed-by on v1 1/1
#4 lore raw
In reply to Tamir Duberstein
Quoted 19 lines · Tamir Duberstein

From: Tamir Duberstein <[email protected]>

Allow usage like pr_info!("one + 1 = {}", one + 1) to compile by ensuring that a reference is taken to the entire expression.

---

---
 rust/macros/fmt.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/macros/fmt.rs +0 -0
index 2f4b9f6e2211..8354abd54502 100644

rust/macros/fmt.rs pub(crate) fn fmt(input: TokenStream) -> TokenStream { · line 73

Quoted 8 lines
rust/macros/fmt.rs +1 -1
@@ -67,7 +67,7 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream {
                     }
                     (None, acc)
                 })();
-                args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs)));
+                args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs))));
             }
         };
 

thanks, this fixes the trivial example I added to rust_minimal.rs and all out-of-tree use in the asahi driver where I discovered the issue.

Janne

Applied
#5 lore raw
In reply to Tamir Duberstein
Quoted 11 lines · Tamir Duberstein

From: Tamir Duberstein <[email protected]>

Allow usage like pr_info!("one + 1 = {}", one + 1) to compile by ensuring that a reference is taken to the entire expression.

---

Applied to rust-fixes -- thanks everyone!

[ Added Signed-off-by back. Reworded title. - Miguel ]

Cheers,
Miguel

reviewer Tested-by on v1 1/1
#6 lore raw
In reply to Tamir Duberstein
Quoted 10 lines · Tamir Duberstein

From: Tamir Duberstein <[email protected]>

Allow usage like pr_info!("one + 1 = {}", one + 1) to compile by ensuring that a reference is taken to the entire expression.

---

Best regards,
Andreas Hindborg