Skip to content

Commit 85f81ba

Browse files
committed
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 <rust-lang/rust#87335> for more information Rewrite backwards, per <https://rust-lang.github.io/rfcs/3137-let-else.html>. libgrust/ * libformat_parser/generic_format_parser/src/lib.rs: Work around 'error[E0658]: `let...else` statements are unstable'.
1 parent 5cdd78b commit 85f81ba

File tree

1 file changed

+5
-2
lines changed
  • libgrust/libformat_parser/generic_format_parser/src

1 file changed

+5
-2
lines changed

libgrust/libformat_parser/generic_format_parser/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,11 @@ fn find_width_map_from_snippet(
991991
// If we only trimmed it off the input, `format!("\n")` would cause a mismatch as here we they actually match up.
992992
// Alternatively, we could just count the trailing newlines and only trim one from the input if they don't match up.
993993
let input_no_nl = input.trim_end_matches('\n');
994-
let Some(unescaped) = unescape_string(snippet) else {
995-
return InputStringKind::NotALiteral;
994+
let unescaped = match unescape_string(snippet) {
995+
Some(unescaped) => unescaped,
996+
_ => {
997+
return InputStringKind::NotALiteral;
998+
}
996999
};
9971000

9981001
let unescaped_no_nl = unescaped.trim_end_matches('\n');

0 commit comments

Comments
 (0)