Repository: rust-lang/rustfmt (rust)

Issue:
@ binding reformatted strangely on rustfmt from rustc 1.41.0-beta.4
The following line is formatting differently and in an undesirable way with rustfmt from rustc beta (1.41.0-beta.4):

https://github.com/yeslogic/allsorts/blob/c78fb470ca2a575570543918cfbf15422b0377b2/tests/woff2.rs#L236

The diff looks like this:

```diff
Diff in /home/travis/build/yeslogic/allsorts/tests/woff2.rs at line 233:
             .iter()
             .map(|glyph| match glyph {
                 GlyfRecord::Parsed(
-                    found @ Glyph {
+                    found
+                    @
+                    Glyph {
                         data: GlyphData::Composite { .. },
                         ..
                     },
```

Pull request:
backport fix for newline width calcs
1.x backport of #4123 that resolved #4031

Patch:
diff --git a/src/comment.rs b/src/comment.rs
index 0f8118a4..62b624ac 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -184,7 +184,7 @@ pub(crate) fn combine_strs_with_missing_comments(
     let missing_comment = rewrite_missing_comment(span, shape, context)?;
 
     if missing_comment.is_empty() {
-        if allow_extend && prev_str.len() + first_sep.len() + next_str.len() <= shape.width {
+        if allow_extend && one_line_width <= shape.width {
             result.push_str(first_sep);
         } else if !prev_str.is_empty() {
             result.push_str(&indent.to_string_with_newline(config))


Test patch:
diff --git a/tests/target/issue_4031.rs b/tests/target/issue_4031.rs
new file mode 100644
index 00000000..065d5395
--- /dev/null
+++ b/tests/target/issue_4031.rs
@@ -0,0 +1,21 @@
+fn foo() {
+    with_woff2_glyf_table("tests/fonts/woff2/SFNT-TTF-Composite.woff2", |glyf| {
+        let actual = glyf
+            .records
+            .iter()
+            .map(|glyph| match glyph {
+                GlyfRecord::Parsed(
+                    found @ Glyph {
+                        data: GlyphData::Composite { .. },
+                        ..
+                    },
+                ) => Some(found),
+                _ => None,
+            })
+            .find(|candidate| candidate.is_some())
+            .unwrap()
+            .unwrap();
+
+        assert_eq!(*actual, expected)
+    });
+}
diff --git a/tests/target/issue_4110.rs b/tests/target/issue_4110.rs
new file mode 100644
index 00000000..4a58c394
--- /dev/null
+++ b/tests/target/issue_4110.rs
@@ -0,0 +1,55 @@
+fn bindings() {
+    let err = match (place_desc, explanation) {
+        (
+            Some(ref name),
+            BorrowExplanation::MustBeValidFor {
+                category:
+                    category @ (ConstraintCategory::Return
+                    | ConstraintCategory::CallArgument
+                    | ConstraintCategory::OpaqueType),
+                from_closure: false,
+                ref region_name,
+                span,
+                ..
+            },
+        ) if borrow_spans.for_generator() | borrow_spans.for_closure() => self
+            .report_escaping_closure_capture(
+                borrow_spans,
+                borrow_span,
+                region_name,
+                category,
+                span,
+                &format!("`{}`", name),
+            ),
+        (
+            ref name,
+            BorrowExplanation::MustBeValidFor {
+                category: ConstraintCategory::Assignment,
+                from_closure: false,
+                region_name:
+                    RegionName {
+                        source: RegionNameSource::AnonRegionFromUpvar(upvar_span, ref upvar_name),
+                        ..
+                    },
+                span,
+                ..
+            },
+        ) => self.report_escaping_data(borrow_span, name, upvar_span, upvar_name, span),
+        (Some(name), explanation) => self.report_local_value_does_not_live_long_enough(
+            location,
+            &name,
+            &borrow,
+            drop_span,
+            borrow_spans,
+            explanation,
+        ),
+        (None, explanation) => self.report_temporary_value_does_not_live_long_enough(
+            location,
+            &borrow,
+            drop_span,
+            borrow_spans,
+            proper_span,
+            explanation,
+        ),
+    };
+}