From 9d71d9814b9967b184956cb949c45e0f23ff0b81 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sat, 3 Aug 2024 16:08:42 +0200 Subject: [PATCH] Rust: Work around 'error[E0658]: `let...else` statements are unstable' Compiling with Debian GNU/Linux 12 (bookworm) packages: $ apt-cache madison cargo rustc cargo | 0.66.0+ds1-1 | http://deb.debian.org/debian bookworm/main ppc64el Packages cargo | 0.66.0+ds1-1 | http://deb.debian.org/debian bookworm/main Sources rustc | 1.63.0+dfsg1-2 | http://deb.debian.org/debian bookworm/main ppc64el Packages rustc | 1.63.0+dfsg1-2 | http://deb.debian.org/debian bookworm/main Sources ..., we run into: Compiling generic_format_parser v0.1.0 ([...]/source-gcc/libgrust/libformat_parser/generic_format_parser) error[E0658]: `let...else` statements are unstable --> generic_format_parser/src/lib.rs:994:5 | 994 | / let Some(unescaped) = unescape_string(snippet) else { 995 | | return InputStringKind::NotALiteral; 996 | | }; | |______^ | = note: see issue #87335 for more information Rewrite backwards, per . libgrust/ * libformat_parser/generic_format_parser/src/lib.rs: Work around 'error[E0658]: `let...else` statements are unstable'. --- libgrust/libformat_parser/generic_format_parser/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libgrust/libformat_parser/generic_format_parser/src/lib.rs b/libgrust/libformat_parser/generic_format_parser/src/lib.rs index 8062bf9e5cec..ed3d8577befa 100644 --- a/libgrust/libformat_parser/generic_format_parser/src/lib.rs +++ b/libgrust/libformat_parser/generic_format_parser/src/lib.rs @@ -991,8 +991,11 @@ fn find_width_map_from_snippet( // If we only trimmed it off the input, `format!("\n")` would cause a mismatch as here we they actually match up. // Alternatively, we could just count the trailing newlines and only trim one from the input if they don't match up. let input_no_nl = input.trim_end_matches('\n'); - let Some(unescaped) = unescape_string(snippet) else { - return InputStringKind::NotALiteral; + let unescaped = match unescape_string(snippet) { + Some(unescaped) => unescaped, + _ => { + return InputStringKind::NotALiteral; + } }; let unescaped_no_nl = unescaped.trim_end_matches('\n'); -- 2.34.1