diff options
| author | The rustc-josh-sync Cronjob Bot <github-actions@github.com> | 2025-08-25 04:13:22 +0000 |
|---|---|---|
| committer | The rustc-josh-sync Cronjob Bot <github-actions@github.com> | 2025-08-25 04:13:22 +0000 |
| commit | 721337b92a2ea898a21ea01e420d80e2e33213d2 (patch) | |
| tree | b92935283dc39332d14862c9227eda4b865a507b /compiler/rustc_pattern_analysis/src | |
| parent | c4cd29b7fbe3a924f248ea76d5e534b4e8f9b24c (diff) | |
| parent | a1dbb443527bd126452875eb5d5860c1d001d761 (diff) | |
| download | rust-721337b92a2ea898a21ea01e420d80e2e33213d2.tar.gz rust-721337b92a2ea898a21ea01e420d80e2e33213d2.zip | |
Merge ref 'a1dbb443527b' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: a1dbb443527bd126452875eb5d5860c1d001d761 Filtered ref: c2339048a82c55166f9b9ee83fd618be252a6e23 This merge was created using https://github.com/rust-lang/josh-sync.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/rustc/print.rs | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/compiler/rustc_pattern_analysis/src/rustc/print.rs b/compiler/rustc_pattern_analysis/src/rustc/print.rs index 7649f72f868..cdf62c2553d 100644 --- a/compiler/rustc_pattern_analysis/src/rustc/print.rs +++ b/compiler/rustc_pattern_analysis/src/rustc/print.rs @@ -101,23 +101,11 @@ pub(crate) fn write_struct_like<'tcx>( let num_fields = variant_and_name.as_ref().map_or(subpatterns.len(), |(v, _)| v.fields.len()); if num_fields != 0 || variant_and_name.is_none() { write!(f, "(")?; - for i in 0..num_fields { - write!(f, "{}", start_or_comma())?; - - // Common case: the field is where we expect it. - if let Some(p) = subpatterns.get(i) { - if p.field.index() == i { - write!(f, "{}", p.pattern)?; - continue; - } - } - - // Otherwise, we have to go looking for it. - if let Some(p) = subpatterns.iter().find(|p| p.field.index() == i) { - write!(f, "{}", p.pattern)?; - } else { - write!(f, "_")?; - } + for FieldPat { pattern, .. } in subpatterns { + write!(f, "{}{pattern}", start_or_comma())?; + } + if matches!(ty.kind(), ty::Tuple(..)) && num_fields == 1 { + write!(f, ",")?; } write!(f, ")")?; } |
