From 6892fcd690fe252062ffc8621e2878069a1ee3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 12 Dec 2023 18:42:37 +0100 Subject: [PATCH 1/2] simplify merging of two vecs --- compiler/rustc_pattern_analysis/src/constructor.rs | 2 +- compiler/rustc_resolve/src/late/diagnostics.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 716ccdd4dcd00..02039679517ca 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -979,7 +979,7 @@ impl ConstructorSet { && !(pcx.is_top_level && matches!(self, Self::NoConstructors)) { // Treat all missing constructors as nonempty. - missing.extend(missing_empty.drain(..)); + missing.append(&mut missing_empty); } SplitConstructorSet { present, missing, missing_empty } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index df30c185c6062..ded1408b990df 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2178,7 +2178,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { let (span, text) = match path.segments.first() { Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => { // a special case for #117894 - let name = name.strip_prefix("_").unwrap_or(name); + let name = name.strip_prefix('_').unwrap_or(name); (ident_span, format!("let {name}")) } _ => (ident_span.shrink_to_lo(), "let ".to_string()), From 2a1acc26a0533b82faa5ab18b56cff032e6ca3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 12 Dec 2023 21:12:19 +0100 Subject: [PATCH 2/2] Update compiler/rustc_pattern_analysis/src/constructor.rs add note that `missing_empty` is cleared now Co-authored-by: Nadrieril --- compiler/rustc_pattern_analysis/src/constructor.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 02039679517ca..3bca7894a2921 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -979,6 +979,7 @@ impl ConstructorSet { && !(pcx.is_top_level && matches!(self, Self::NoConstructors)) { // Treat all missing constructors as nonempty. + // This clears `missing_empty`. missing.append(&mut missing_empty); }