mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 23:06:23 +00:00
Merge pull request #357 from scyptnex/match-comma-retention
fix for #355 and test cases
This commit is contained in:
commit
56d1a94b5f
@ -151,7 +151,11 @@ impl Rewrite for ast::Expr {
|
||||
rewrite_chain(self, context, width, offset)
|
||||
}
|
||||
ast::Expr_::ExprMac(ref mac) => {
|
||||
rewrite_macro(mac, context, width, offset)
|
||||
// Failure to rewrite a marco should not imply failure to rewrite the Expr
|
||||
rewrite_macro(mac, context, width, offset).or(wrap_str(context.snippet(self.span),
|
||||
context.config.max_width,
|
||||
width,
|
||||
offset))
|
||||
}
|
||||
// We do not format these expressions yet, but they should still
|
||||
// satisfy our width restrictions.
|
||||
|
@ -198,6 +198,57 @@ fn issue339() {
|
||||
}
|
||||
}
|
||||
|
||||
fn issue355() {
|
||||
match mac {
|
||||
a => println!("a", b),
|
||||
b => vec!(1, 2),
|
||||
c => vec!(3; 4),
|
||||
d => {
|
||||
println!("a", b)
|
||||
}
|
||||
e => {
|
||||
vec!(1, 2)
|
||||
}
|
||||
f => {
|
||||
vec!(3; 4)
|
||||
}
|
||||
h => println!("a", b), // h comment
|
||||
i => vec!(1, 2), // i comment
|
||||
j => vec!(3; 4), // j comment
|
||||
// k comment
|
||||
k => println!("a", b),
|
||||
// l comment
|
||||
l => vec!(1, 2),
|
||||
// m comment
|
||||
m => vec!(3; 4),
|
||||
// Rewrite splits macro
|
||||
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => println!("a", b),
|
||||
// Rewrite splits macro
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => vec!(1, 2),
|
||||
// Macro support fails to recognise this macro as splitable
|
||||
// We push the whole expr to a new line, TODO split this macro as well
|
||||
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => vec!(3; 4),
|
||||
// q, r and s: Rewrite splits match arm
|
||||
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq => println!("a", b),
|
||||
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr => vec!(1, 2),
|
||||
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss => vec!(3; 4),
|
||||
// Funky bracketing styles
|
||||
t => println!{"a", b},
|
||||
u => vec!{1, 2},
|
||||
v => vec!{3; 4},
|
||||
w => println!["a", b],
|
||||
x => vec![1, 2],
|
||||
y =>vec![3; 4],
|
||||
// Brackets with comments
|
||||
tc => println!{"a", b}, // comment
|
||||
uc => vec!{1, 2}, // comment
|
||||
vc =>vec!{3; 4}, // comment
|
||||
wc =>println!["a", b], // comment
|
||||
xc => vec![1,2], // comment
|
||||
yc => vec![3; 4], // comment
|
||||
}
|
||||
}
|
||||
|
||||
fn arrays() {
|
||||
let x = [0,
|
||||
1,
|
||||
|
@ -225,6 +225,63 @@ fn issue339() {
|
||||
}
|
||||
}
|
||||
|
||||
fn issue355() {
|
||||
match mac {
|
||||
a => println!("a", b),
|
||||
b => vec!(1, 2),
|
||||
c => vec!(3; 4),
|
||||
d => {
|
||||
println!("a", b)
|
||||
}
|
||||
e => {
|
||||
vec!(1, 2)
|
||||
}
|
||||
f => {
|
||||
vec!(3; 4)
|
||||
}
|
||||
h => println!("a", b), // h comment
|
||||
i => vec!(1, 2), // i comment
|
||||
j => vec!(3; 4), // j comment
|
||||
// k comment
|
||||
k => println!("a", b),
|
||||
// l comment
|
||||
l => vec!(1, 2),
|
||||
// m comment
|
||||
m => vec!(3; 4),
|
||||
// Rewrite splits macro
|
||||
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => println!("a",
|
||||
b),
|
||||
// Rewrite splits macro
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => vec!(1,
|
||||
2),
|
||||
// Macro support fails to recognise this macro as splitable
|
||||
// We push the whole expr to a new line, TODO split this macro as well
|
||||
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp =>
|
||||
vec!(3; 4),
|
||||
// q, r and s: Rewrite splits match arm
|
||||
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq =>
|
||||
println!("a", b),
|
||||
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr =>
|
||||
vec!(1, 2),
|
||||
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss =>
|
||||
vec!(3; 4),
|
||||
// Funky bracketing styles
|
||||
t => println!{"a", b},
|
||||
u => vec!{1, 2},
|
||||
v => vec!{3; 4},
|
||||
w => println!["a", b],
|
||||
x => vec![1, 2],
|
||||
y => vec![3; 4],
|
||||
// Brackets with comments
|
||||
tc => println!{"a", b}, // comment
|
||||
uc => vec!{1, 2}, // comment
|
||||
vc => vec!{3; 4}, // comment
|
||||
wc => println!["a", b], // comment
|
||||
xc => vec![1, 2], // comment
|
||||
yc => vec![3; 4], // comment
|
||||
}
|
||||
}
|
||||
|
||||
fn arrays() {
|
||||
let x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 7, 8, 9, 0, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 0];
|
||||
|
Loading…
Reference in New Issue
Block a user