Skip to content

Commit

Permalink
Switch to unreachable! over panic!
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Mar 11, 2024
1 parent 7a8a214 commit 3ee6454
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/ruff_python_parser/src/string_token_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ impl From<StringKind> 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()
)
};
Expand All @@ -360,7 +360,10 @@ impl From<StringKind> 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)
}
Expand All @@ -376,7 +379,10 @@ impl From<StringKind> 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)
}
Expand Down

0 comments on commit 3ee6454

Please sign in to comment.