From 3ee6454f02aa49f2ee451da19f704e280c248dc0 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 11 Mar 2024 09:21:10 +0000 Subject: [PATCH] Switch to `unreachable!` over `panic!` --- .../ruff_python_parser/src/string_token_flags.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/ruff_python_parser/src/string_token_flags.rs b/crates/ruff_python_parser/src/string_token_flags.rs index b7154ab11d24bd..8e15e5fc04dc2b 100644 --- a/crates/ruff_python_parser/src/string_token_flags.rs +++ b/crates/ruff_python_parser/src/string_token_flags.rs @@ -341,8 +341,8 @@ impl From for ruff_python_ast::StringLiteralFlags { new = new.with_triple_quotes(); } let StringPrefix::Regular(prefix) = value.prefix() else { - panic!( - "Attempting to convert {} into a regular string", + unreachable!( + "Should never attempt to convert {} into a regular string", value.prefix() ) }; @@ -360,7 +360,10 @@ impl From for ruff_python_ast::BytesLiteralFlags { new = new.with_triple_quotes(); } let StringPrefix::Bytes(bytestring_prefix) = value.prefix() else { - panic!("Attempting to convert {} into a bytestring", value.prefix()) + unreachable!( + "Should never attempt to convert {} into a bytestring", + value.prefix() + ) }; new.with_prefix(bytestring_prefix) } @@ -376,7 +379,10 @@ impl From for ruff_python_ast::FStringFlags { new = new.with_triple_quotes(); } let StringPrefix::Format(fstring_prefix) = value.prefix() else { - panic!("Attempting to convert {} into an f-string", value.prefix()) + unreachable!( + "Should never attempt to convert {} into an f-string", + value.prefix() + ) }; new.with_prefix(fstring_prefix) }