Skip to content

Commit b3ae0ef

Browse files
committed
Format asm! macro calls
1 parent 5c558e2 commit b3ae0ef

35 files changed

+3409
-12
lines changed

Configurations.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,38 @@ macro_rules! foo {
10041004

10051005
See also [`format_macro_matchers`](#format_macro_matchers).
10061006

1007+
## `format_asm_macro`
1008+
1009+
Format ``asm!`` macro calls.
1010+
1011+
- **Default value**: `false`
1012+
- **Possible values**: `true`, `false`
1013+
- **Stable**: No (tracking issue: [#5210](https://github.com/rust-lang/rustfmt/issues/5210))
1014+
1015+
#### `false` (default):
1016+
1017+
```rust
1018+
fn main() {
1019+
let x: u64;
1020+
unsafe {
1021+
asm!("mov {}, 5", out(reg) x);
1022+
}
1023+
}
1024+
```
1025+
1026+
#### `true`:
1027+
1028+
```rust
1029+
fn main() {
1030+
let x: u64;
1031+
unsafe {
1032+
asm!(
1033+
"mov {}, 5",
1034+
out(reg) x
1035+
);
1036+
}
1037+
}
1038+
```
10071039

10081040
## `format_strings`
10091041

src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ create_config! {
6565
normalize_doc_attributes: bool, false, false, "Normalize doc attributes as doc comments";
6666
license_template_path: String, String::default(), false,
6767
"Beginning of file must match license template";
68+
format_asm_macro: bool, false, false, "Format asm! macro calls";
6869
format_strings: bool, false, false, "Format string literals where necessary";
6970
format_macro_matchers: bool, false, false,
7071
"Format the metavariable matching patterns in macros";
@@ -567,6 +568,7 @@ comment_width = 80
567568
normalize_comments = false
568569
normalize_doc_attributes = false
569570
license_template_path = ""
571+
format_asm_macro = false
570572
format_strings = false
571573
format_macro_matchers = false
572574
format_macro_bodies = true

src/expr.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,11 +1859,9 @@ pub(crate) enum RhsAssignKind<'ast> {
18591859

18601860
impl<'ast> RhsAssignKind<'ast> {
18611861
// TODO(calebcartwright)
1862-
// Preemptive addition for handling RHS with chains, not yet utilized.
18631862
// It may make more sense to construct the chain first and then check
18641863
// whether there are actually chain elements.
1865-
#[allow(dead_code)]
1866-
fn is_chain(&self) -> bool {
1864+
pub(crate) fn is_chain(&self) -> bool {
18671865
match self {
18681866
RhsAssignKind::Expr(kind, _) => {
18691867
matches!(

0 commit comments

Comments
 (0)