Rollup merge of #33639 - petrochenkov:dotdot, r=nmatsakis

cc https://github.com/rust-lang/rust/issues/33627
r? @nikomatsakis

plugin-[breaking-change] cc https://github.com/rust-lang/rust/issues/31645 @Manishearth
This commit is contained in:
Manish Goregaokar
2016-05-27 09:57:00 +05:30
50 changed files with 873 additions and 297 deletions

View File

@@ -2472,17 +2472,23 @@ impl<'a> State<'a> {
None => ()
}
}
PatKind::TupleStruct(ref path, ref args_) => {
PatKind::TupleStruct(ref path, ref elts, ddpos) => {
self.print_path(path, true, 0)?;
match *args_ {
None => word(&mut self.s, "(..)")?,
Some(ref args) => {
self.popen()?;
self.commasep(Inconsistent, &args[..],
|s, p| s.print_pat(&p))?;
self.pclose()?;
self.popen()?;
if let Some(ddpos) = ddpos {
self.commasep(Inconsistent, &elts[..ddpos], |s, p| s.print_pat(&p))?;
if ddpos != 0 {
self.word_space(",")?;
}
word(&mut self.s, "..")?;
if ddpos != elts.len() {
word(&mut self.s, ",")?;
self.commasep(Inconsistent, &elts[ddpos..], |s, p| s.print_pat(&p))?;
}
} else {
self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(&p))?;
}
self.pclose()?;
}
PatKind::Path(ref path) => {
self.print_path(path, true, 0)?;
@@ -2513,13 +2519,23 @@ impl<'a> State<'a> {
space(&mut self.s)?;
word(&mut self.s, "}")?;
}
PatKind::Tup(ref elts) => {
PatKind::Tuple(ref elts, ddpos) => {
self.popen()?;
self.commasep(Inconsistent,
&elts[..],
|s, p| s.print_pat(&p))?;
if elts.len() == 1 {
word(&mut self.s, ",")?;
if let Some(ddpos) = ddpos {
self.commasep(Inconsistent, &elts[..ddpos], |s, p| s.print_pat(&p))?;
if ddpos != 0 {
self.word_space(",")?;
}
word(&mut self.s, "..")?;
if ddpos != elts.len() {
word(&mut self.s, ",")?;
self.commasep(Inconsistent, &elts[ddpos..], |s, p| s.print_pat(&p))?;
}
} else {
self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(&p))?;
if elts.len() == 1 {
word(&mut self.s, ",")?;
}
}
self.pclose()?;
}