Skip to content

Commit 15854e5

Browse files
feat: v2 support for nested tuples w/o spaces
1 parent 278e8da commit 15854e5

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

src/chains.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use rustc_ast::{ast, ptr};
6262
use rustc_span::{symbol, BytePos, Span};
6363

6464
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
65-
use crate::config::IndentStyle;
65+
use crate::config::{IndentStyle, Version};
6666
use crate::expr::rewrite_call;
6767
use crate::lists::extract_pre_comment;
6868
use crate::macros::convert_try_mac;
@@ -200,7 +200,11 @@ impl Rewrite for ChainItem {
200200
ChainItemKind::StructField(ident) => format!(".{}", rewrite_ident(context, ident)),
201201
ChainItemKind::TupleField(ident, nested) => format!(
202202
"{}.{}",
203-
if nested { " " } else { "" },
203+
if nested && context.config.version() == Version::One {
204+
" "
205+
} else {
206+
""
207+
},
204208
rewrite_ident(context, ident)
205209
),
206210
ChainItemKind::Await => ".await".to_owned(),

tests/source/tuple.rs

+11
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,14 @@ fn issue1725() {
5050
bench_antialiased_lines!(bench_draw_antialiased_line_segment_diagonal, (10, 10), (450, 450));
5151
bench_antialiased_lines!(bench_draw_antialiased_line_segment_shallow, (10, 10), (450, 80));
5252
}
53+
54+
fn issue_4355() {
55+
let _ = ((1,),).0.0;
56+
}
57+
58+
// https://github.com/rust-lang/rustfmt/issues/4410
59+
impl Drop for LockGuard {
60+
fn drop(&mut self) {
61+
LockMap::unlock(&self.0.0, &self.0.1);
62+
}
63+
}

tests/source/tuple_v2.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// rustfmt-version: Two
2+
3+
fn issue_4355() {
4+
let _ = ((1,),).0 .0;
5+
}

tests/target/tuple.rs

+11
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,14 @@ fn issue1725() {
8787
(450, 80)
8888
);
8989
}
90+
91+
fn issue_4355() {
92+
let _ = ((1,),).0 .0;
93+
}
94+
95+
// https://github.com/rust-lang/rustfmt/issues/4410
96+
impl Drop for LockGuard {
97+
fn drop(&mut self) {
98+
LockMap::unlock(&self.0 .0, &self.0 .1);
99+
}
100+
}

tests/target/tuple_v2.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// rustfmt-version: Two
2+
3+
fn issue_4355() {
4+
let _ = ((1,),).0.0;
5+
}

0 commit comments

Comments
 (0)