feat: v2 support for nested tuples w/o spaces

This commit is contained in:
Caleb Cartwright 2020-10-30 00:03:03 -05:00 committed by Caleb Cartwright
parent 278e8da33b
commit 15854e5fd3
5 changed files with 38 additions and 2 deletions

View file

@ -62,7 +62,7 @@ use rustc_ast::{ast, ptr};
use rustc_span::{symbol, BytePos, Span};
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
use crate::config::IndentStyle;
use crate::config::{IndentStyle, Version};
use crate::expr::rewrite_call;
use crate::lists::extract_pre_comment;
use crate::macros::convert_try_mac;
@ -200,7 +200,11 @@ impl Rewrite for ChainItem {
ChainItemKind::StructField(ident) => format!(".{}", rewrite_ident(context, ident)),
ChainItemKind::TupleField(ident, nested) => format!(
"{}.{}",
if nested { " " } else { "" },
if nested && context.config.version() == Version::One {
" "
} else {
""
},
rewrite_ident(context, ident)
),
ChainItemKind::Await => ".await".to_owned(),

View file

@ -50,3 +50,14 @@ fn issue1725() {
bench_antialiased_lines!(bench_draw_antialiased_line_segment_diagonal, (10, 10), (450, 450));
bench_antialiased_lines!(bench_draw_antialiased_line_segment_shallow, (10, 10), (450, 80));
}
fn issue_4355() {
let _ = ((1,),).0.0;
}
// https://github.com/rust-lang/rustfmt/issues/4410
impl Drop for LockGuard {
fn drop(&mut self) {
LockMap::unlock(&self.0.0, &self.0.1);
}
}

5
tests/source/tuple_v2.rs Normal file
View file

@ -0,0 +1,5 @@
// rustfmt-version: Two
fn issue_4355() {
let _ = ((1,),).0 .0;
}

View file

@ -87,3 +87,14 @@ fn issue1725() {
(450, 80)
);
}
fn issue_4355() {
let _ = ((1,),).0 .0;
}
// https://github.com/rust-lang/rustfmt/issues/4410
impl Drop for LockGuard {
fn drop(&mut self) {
LockMap::unlock(&self.0 .0, &self.0 .1);
}
}

5
tests/target/tuple_v2.rs Normal file
View file

@ -0,0 +1,5 @@
// rustfmt-version: Two
fn issue_4355() {
let _ = ((1,),).0.0;
}