about summary refs log tree commit diff
diff options
context:
space:
mode:
authorrChaser53 <tayoshizawa29@gmail.com>2019-07-30 14:32:38 +0900
committerSeiichi Uchida <seuchida@gmail.com>2019-07-30 14:32:38 +0900
commitfe05e8883150ede9cd8efcff47374b5894d74eb7 (patch)
tree65799ff6ed2f40b9de3e7bf696e18fededab613a
parent365461349d83e5b39bd3dcc704356f0822de0f65 (diff)
fix to build with rustc 1.38.0-nightly (4560cb830 2019-07-28) (#3712)
-rw-r--r--Cargo.lock86
-rw-r--r--Cargo.toml6
-rw-r--r--src/patterns.rs121
-rw-r--r--tests/source/pattern.rs18
-rw-r--r--tests/target/issue-1021.rs2
-rw-r--r--tests/target/issue-2936.rs2
-rw-r--r--tests/target/issue-3711.rs6
-rw-r--r--tests/target/pattern.rs16
8 files changed, 120 insertions, 137 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d40380dbd68..dfaef1a7faa 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -691,21 +691,21 @@ dependencies = [
 
 [[package]]
 name = "rustc-ap-arena"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rustc-ap-rustc_data_structures 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-ap-graphviz"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "rustc-ap-rustc_data_structures"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -716,8 +716,8 @@ dependencies = [
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-graphviz 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-graphviz 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-rayon-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -727,27 +727,27 @@ dependencies = [
 
 [[package]]
 name = "rustc-ap-rustc_errors"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-ap-rustc_lexer"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "rustc-ap-rustc_macros"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -759,19 +759,19 @@ dependencies = [
 
 [[package]]
 name = "rustc-ap-rustc_target"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-ap-serialize"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -780,33 +780,33 @@ dependencies = [
 
 [[package]]
 name = "rustc-ap-syntax"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_errors 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_lexer 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_macros 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_target 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_errors 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_lexer 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_macros 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_target 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-ap-syntax_pos"
-version = "541.0.0"
+version = "542.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-arena 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_macros 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-arena 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_macros 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -886,9 +886,9 @@ dependencies = [
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_target 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_target 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-workspace-hack 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustfmt-config_proc_macro 0.1.2",
  "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1238,16 +1238,16 @@ dependencies = [
 "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828"
 "checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc"
 "checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c"
-"checksum rustc-ap-arena 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4999a492d178380404acf4db84a5f963308abc6517c9d7e1c365b8a3f71b9c76"
-"checksum rustc-ap-graphviz 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec0487de365719ea61197aba6ff7d8ddbcbc7f405efabe45779531006eea8af2"
-"checksum rustc-ap-rustc_data_structures 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73123645a853dfe21d834e68a9794b7102dd8f853de1f4fb3afb6ab157a391f3"
-"checksum rustc-ap-rustc_errors 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0054a08e965f4139a5b506b5c2ffeba0c8675e2644f6de8598b46430adbc31b5"
-"checksum rustc-ap-rustc_lexer 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dee482133f8d62afa26c5fc1bb0e5058fe20f2d8f4fd62e0b19b8573b79d46da"
-"checksum rustc-ap-rustc_macros 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "19a6a47f58ec7b082c706fa45d000bb32b68f69be4144d321346c5fcdf553e78"
-"checksum rustc-ap-rustc_target 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e6906ce7105780a97c9b3b0a8ca8d5fca098fa9ad63ff8d76db4196977991ed8"
-"checksum rustc-ap-serialize 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ae328d35a0fe825d87e3a9d758aa7be6351da0da95a900b67bc725a2ff353f4"
-"checksum rustc-ap-syntax 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8386699c409cc149144e2e97eb4afa6bc2443d8c32a2fb6815d31642c6b5ee97"
-"checksum rustc-ap-syntax_pos 541.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b0155cbc5e3cf2291da98d2dd7a0614595e3363cfde39c719c17c50a1a06668"
+"checksum rustc-ap-arena 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60ae3caf12a5dfa3181e12e813b090b0b41d43b91b193759ba9084520aeb2459"
+"checksum rustc-ap-graphviz 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0113b8888a3f0a68825ed0dea6d3a1aa71b5d0cd6ff16854252c4faea253cf9b"
+"checksum rustc-ap-rustc_data_structures 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bd9eec8c9fbdac20e631f995861c5c854b3f8b2347955614854571457117e51"
+"checksum rustc-ap-rustc_errors 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f55baa0fa4a42a8b354f02015755e7db5619125ad3e625923865f6f1f5688753"
+"checksum rustc-ap-rustc_lexer 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2875181a7886d83b727b1d08291ee430728c2d94c9a7e3f4359df2a14e6c462b"
+"checksum rustc-ap-rustc_macros 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d3cadcc9dd4fc3c94c89e103e91f8792f19a1466e0a127d9fb29a2c0ee069389"
+"checksum rustc-ap-rustc_target 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4bdcce1900404a6907785dd31a152ddd723766dfbe29bed6bcca255e7347abdd"
+"checksum rustc-ap-serialize 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "550e295fa077784f7145ba77591aff952fad2279f3ce23a53cf8750fb366c622"
+"checksum rustc-ap-syntax 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "594006d7e68bcff9b5356517667c4e9dd5ec925a2a08660d129b705d0b741ad7"
+"checksum rustc-ap-syntax_pos 542.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ae6751bf44d949b430b151c81772b585686f0ff31e328b68eaa7d406590f848"
 "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
 "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
 "checksum rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2e07e19601f21c59aad953c2632172ba70cb27e685771514ea66e4062b3363"
diff --git a/Cargo.toml b/Cargo.toml
index 5ca4f765690..2754fcf838e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,9 +48,9 @@ env_logger = "0.6"
 getopts = "0.2"
 derive-new = "0.5"
 cargo_metadata = "0.8"
-rustc-ap-rustc_target = "541.0.0"
-rustc-ap-syntax = "541.0.0"
-rustc-ap-syntax_pos = "541.0.0"
+rustc-ap-rustc_target = "542.0.0"
+rustc-ap-syntax = "542.0.0"
+rustc-ap-syntax_pos = "542.0.0"
 failure = "0.1.3"
 bytecount = "0.5"
 unicode-width = "0.1.5"
diff --git a/src/patterns.rs b/src/patterns.rs
index c26451f6d69..e7b7f8adbb2 100644
--- a/src/patterns.rs
+++ b/src/patterns.rs
@@ -37,15 +37,15 @@ pub(crate) fn is_short_pattern(pat: &ast::Pat, pat_str: &str) -> bool {
 
 fn is_short_pattern_inner(pat: &ast::Pat) -> bool {
     match pat.node {
-        ast::PatKind::Wild | ast::PatKind::Lit(_) => true,
+        ast::PatKind::Rest | ast::PatKind::Wild | ast::PatKind::Lit(_) => true,
         ast::PatKind::Ident(_, _, ref pat) => pat.is_none(),
         ast::PatKind::Struct(..)
         | ast::PatKind::Mac(..)
         | ast::PatKind::Slice(..)
         | ast::PatKind::Path(..)
         | ast::PatKind::Range(..) => false,
-        ast::PatKind::Tuple(ref subpats, _) => subpats.len() <= 1,
-        ast::PatKind::TupleStruct(ref path, ref subpats, _) => {
+        ast::PatKind::Tuple(ref subpats) => subpats.len() <= 1,
+        ast::PatKind::TupleStruct(ref path, ref subpats) => {
             path.segments.len() <= 1 && subpats.len() <= 1
         }
         ast::PatKind::Box(ref p) | ast::PatKind::Ref(ref p, _) | ast::PatKind::Paren(ref p) => {
@@ -88,6 +88,13 @@ impl Rewrite for Pat {
                     None
                 }
             }
+            PatKind::Rest => {
+                if 1 <= shape.width {
+                    Some("..".to_owned())
+                } else {
+                    None
+                }
+            }
             PatKind::Range(ref lhs, ref rhs, ref end_kind) => {
                 let infix = match end_kind.node {
                     RangeEnd::Included(RangeSyntax::DotDotDot) => "...",
@@ -112,42 +119,27 @@ impl Rewrite for Pat {
                 let prefix = format!("&{}", format_mutability(mutability));
                 rewrite_unary_prefix(context, &prefix, &**pat, shape)
             }
-            PatKind::Tuple(ref items, dotdot_pos) => {
-                rewrite_tuple_pat(items, dotdot_pos, None, self.span, context, shape)
-            }
+            PatKind::Tuple(ref items) => rewrite_tuple_pat(items, None, self.span, context, shape),
             PatKind::Path(ref q_self, ref path) => {
                 rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)
             }
-            PatKind::TupleStruct(ref path, ref pat_vec, dotdot_pos) => {
+            PatKind::TupleStruct(ref path, ref pat_vec) => {
                 let path_str = rewrite_path(context, PathContext::Expr, None, path, shape)?;
-                rewrite_tuple_pat(
-                    pat_vec,
-                    dotdot_pos,
-                    Some(path_str),
-                    self.span,
-                    context,
-                    shape,
-                )
+                rewrite_tuple_pat(pat_vec, Some(path_str), self.span, context, shape)
             }
             PatKind::Lit(ref expr) => expr.rewrite(context, shape),
-            PatKind::Slice(ref prefix, ref slice_pat, ref suffix) => {
-                // Rewrite all the sub-patterns.
-                let prefix = prefix.iter().map(|p| p.rewrite(context, shape));
-                let slice_pat = slice_pat
-                    .as_ref()
-                    .and_then(|p| p.rewrite(context, shape))
-                    .map(|rw| Some(format!("{}..", if rw == "_" { "" } else { &rw })));
-                let suffix = suffix.iter().map(|p| p.rewrite(context, shape));
-
-                // Munge them together.
-                let pats: Option<Vec<String>> =
-                    prefix.chain(slice_pat.into_iter()).chain(suffix).collect();
-
-                // Check that all the rewrites succeeded, and if not return `None`.
-                let pats = pats?;
-
-                // Unwrap all the sub-strings and join them with commas.
-                Some(format!("[{}]", pats.join(", ")))
+            PatKind::Slice(ref slice_pat) => {
+                let rw: Vec<String> = slice_pat
+                    .iter()
+                    .map(|p| {
+                        if let Some(rw) = p.rewrite(context, shape) {
+                            format!("{}", if rw == "_" { "" } else { &rw })
+                        } else {
+                            format!("{}", context.snippet(p.span))
+                        }
+                    })
+                    .collect();
+                Some(format!("[{}]", rw.join(", ")))
             }
             PatKind::Struct(ref path, ref fields, ellipsis) => {
                 rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape)
@@ -303,7 +295,6 @@ pub(crate) fn can_be_overflowed_pat(
 
 fn rewrite_tuple_pat(
     pats: &[ptr::P<ast::Pat>],
-    dotdot_pos: Option<usize>,
     path_str: Option<String>,
     span: Span,
     context: &RewriteContext<'_>,
@@ -311,52 +302,26 @@ fn rewrite_tuple_pat(
 ) -> Option<String> {
     let mut pat_vec: Vec<_> = pats.iter().map(|x| TuplePatField::Pat(x)).collect();
 
-    if let Some(pos) = dotdot_pos {
-        let prev = if pos == 0 {
-            span.lo()
-        } else {
-            pats[pos - 1].span().hi()
-        };
-        let next = if pos + 1 >= pats.len() {
-            span.hi()
-        } else {
-            pats[pos + 1].span().lo()
-        };
-        let dot_span = mk_sp(prev, next);
-        let snippet = context.snippet(dot_span);
-        let lo = dot_span.lo() + BytePos(snippet.find_uncommented("..").unwrap() as u32);
-        let dotdot = TuplePatField::Dotdot(Span::new(
-            lo,
-            // 2 == "..".len()
-            lo + BytePos(2),
-            source_map::NO_EXPANSION,
-        ));
-        pat_vec.insert(pos, dotdot);
-    }
     if pat_vec.is_empty() {
         return Some(format!("{}()", path_str.unwrap_or_default()));
     }
     let wildcard_suffix_len = count_wildcard_suffix_len(context, &pat_vec, span, shape);
-    let (pat_vec, span, condensed) =
-        if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2 {
-            let new_item_count = 1 + pat_vec.len() - wildcard_suffix_len;
-            let sp = pat_vec[new_item_count - 1].span();
-            let snippet = context.snippet(sp);
-            let lo = sp.lo() + BytePos(snippet.find_uncommented("_").unwrap() as u32);
-            pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
-            (
-                &pat_vec[..new_item_count],
-                mk_sp(span.lo(), lo + BytePos(1)),
-                true,
-            )
-        } else {
-            (&pat_vec[..], span, false)
-        };
+    let (pat_vec, span) = if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2
+    {
+        let new_item_count = 1 + pat_vec.len() - wildcard_suffix_len;
+        let sp = pat_vec[new_item_count - 1].span();
+        let snippet = context.snippet(sp);
+        let lo = sp.lo() + BytePos(snippet.find_uncommented("_").unwrap() as u32);
+        pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1)));
+        (
+            &pat_vec[..new_item_count],
+            mk_sp(span.lo(), lo + BytePos(1)),
+        )
+    } else {
+        (&pat_vec[..], span)
+    };
 
-    // add comma if `(x,)`
-    let add_comma = path_str.is_none() && pat_vec.len() == 1 && dotdot_pos.is_none() && !condensed;
     let path_str = path_str.unwrap_or_default();
-
     overflow::rewrite_with_parens(
         &context,
         &path_str,
@@ -364,13 +329,7 @@ fn rewrite_tuple_pat(
         shape,
         span,
         context.config.max_width(),
-        if dotdot_pos.is_some() {
-            Some(SeparatorTactic::Never)
-        } else if add_comma {
-            Some(SeparatorTactic::Always)
-        } else {
-            None
-        },
+        None,
     )
 }
 
diff --git a/tests/source/pattern.rs b/tests/source/pattern.rs
index 184d23c8137..fc3b1455e0d 100644
--- a/tests/source/pattern.rs
+++ b/tests/source/pattern.rs
@@ -1,4 +1,7 @@
 // rustfmt-normalize_comments: true
+#![feature(exclusive_range_pattern)]
+use core::u8::MAX;
+
 fn main() {
     let z = match x {
         "pat1" => 1,
@@ -16,9 +19,9 @@ fn main() {
     let foo@bar (f) = 42;
     let a::foo ( ..) = 42;
     let [ ] = 42;
-    let [a..,     b,c ] = 42;
-    let [ a,b,c.. ] = 42;
-    let [a,    b, c, d..,e,f,     g] = 42;
+    let [a,     b,c ] = 42;
+    let [ a,b,c ] = 42;
+    let [a,    b, c, d,e,f,     g] = 42;
     let foo {   } = 42;
     let foo {..} = 42;
     let foo { x, y: ref foo,     .. } = 42;
@@ -26,6 +29,13 @@ fn main() {
     let foo { x,       yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,      } = 42;
     let foo { x, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,     .. };
     let foo { x,       yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,      };
+
+    match b"12" {
+        [0,
+        1..MAX
+        ] => {}
+        _ => {}
+    }
 }
 
 impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
@@ -67,7 +77,7 @@ fn combine_patterns() {
 fn slice_patterns() {
     match b"123" {
         [0, ..] => {}
-        [0, foo..] => {}
+        [0, foo] => {}
         _ => {}
     }
 }
diff --git a/tests/target/issue-1021.rs b/tests/target/issue-1021.rs
index ba1029d4e61..94911d1f8ee 100644
--- a/tests/target/issue-1021.rs
+++ b/tests/target/issue-1021.rs
@@ -15,7 +15,7 @@ fn main() {
         (true, ..) => (),
         (.., true) => (),
         (..) => (),
-        (_,) => (),
+        (_) => (),
         (/* .. */ ..) => (),
         (/* .. */ .., true) => (),
     }
diff --git a/tests/target/issue-2936.rs b/tests/target/issue-2936.rs
index 876050a20f4..3d5207597c4 100644
--- a/tests/target/issue-2936.rs
+++ b/tests/target/issue-2936.rs
@@ -10,7 +10,7 @@ impl Something for AStruct {
             ContextualParseError::InvalidMediaRule(ref err) => {
                 let err: &CStr = match err.kind {
                     ParseErrorKind::Custom(StyleParseErrorKind::MediaQueryExpectedFeatureName(
-                        ..
+                        ..,
                     )) => cstr!("PEMQExpectedFeatureName"),
                 };
             }
diff --git a/tests/target/issue-3711.rs b/tests/target/issue-3711.rs
new file mode 100644
index 00000000000..62d986e7734
--- /dev/null
+++ b/tests/target/issue-3711.rs
@@ -0,0 +1,6 @@
+fn main() {
+    println!(
+        "{}", // comment
+        111
+    );
+}
diff --git a/tests/target/pattern.rs b/tests/target/pattern.rs
index 79c8bbb90bf..d8a96d64920 100644
--- a/tests/target/pattern.rs
+++ b/tests/target/pattern.rs
@@ -1,4 +1,7 @@
 // rustfmt-normalize_comments: true
+#![feature(exclusive_range_pattern)]
+use core::u8::MAX;
+
 fn main() {
     let z = match x {
         "pat1" => 1,
@@ -18,9 +21,9 @@ fn main() {
     let foo @ bar(f) = 42;
     let a::foo(..) = 42;
     let [] = 42;
-    let [a.., b, c] = 42;
-    let [a, b, c..] = 42;
-    let [a, b, c, d.., e, f, g] = 42;
+    let [a, b, c] = 42;
+    let [a, b, c] = 42;
+    let [a, b, c, d, e, f, g] = 42;
     let foo {} = 42;
     let foo { .. } = 42;
     let foo { x, y: ref foo, .. } = 42;
@@ -42,6 +45,11 @@ fn main() {
         x,
         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
     };
+
+    match b"12" {
+        [0, 1..MAX] => {}
+        _ => {}
+    }
 }
 
 impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
@@ -79,7 +87,7 @@ fn combine_patterns() {
 fn slice_patterns() {
     match b"123" {
         [0, ..] => {}
-        [0, foo..] => {}
+        [0, foo] => {}
         _ => {}
     }
 }