Auto merge of #127946 - tgross35:fmt-builders-set-result, r=cuviper · model-checking/verify-rust-std@a66bc79 (original) (raw)

Original file line number Diff line number Diff line change
@@ -402,6 +402,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
402 402 }
403 403 }
404 404
405 +/// A helper used to print list-like items with no special formatting.
405 406 struct DebugInner<'a, 'b: 'a> {
406 407 fmt: &'a mut fmt::Formatter<'b>,
407 408 result: fmt::Result,
@@ -578,7 +579,8 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
578 579 /// ```
579 580 #[stable(feature = "debug_builders", since = "1.2.0")]
580 581 pub fn finish(&mut self) -> fmt::Result {
581 -self.inner.result.and_then(|_
582 +self.inner.result = self.inner.result.and_then(|_
583 +self.inner.result
582 584 }
583 585 }
584 586
@@ -721,7 +723,8 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
721 723 /// ```
722 724 #[stable(feature = "debug_builders", since = "1.2.0")]
723 725 pub fn finish(&mut self) -> fmt::Result {
724 -self.inner.result.and_then(|_
726 +self.inner.result = self.inner.result.and_then(|_
727 +self.inner.result
725 728 }
726 729 }
727 730
@@ -1002,11 +1005,12 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
1002 1005 /// ```
1003 1006 #[stable(feature = "debug_builders", since = "1.2.0")]
1004 1007 pub fn finish(&mut self) -> fmt::Result {
1005 -self.result.and_then(|_
1008 +self.result = self.result.and_then(|_
1006 1009 assert!(!self.has_key, "attempted to finish a map with a partial entry");
1007 1010
1008 1011 self.fmt.write_str("}")
1009 -})
1012 +});
1013 +self.result
1010 1014 }
1011 1015
1012 1016 fn is_pretty(&self) -> bool {