From e058e240574053c900129bcfae2c18016ab61563 Mon Sep 17 00:00:00 2001 From: Zanie Date: Tue, 11 Jul 2023 23:24:09 -0500 Subject: [PATCH] Replace `expect` with a `debug_assert` --- crates/ruff/src/rules/ruff/rules/invalid_index_type.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs b/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs index 5b05517322939..399a77dbabd50 100644 --- a/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs +++ b/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs @@ -73,8 +73,10 @@ pub(crate) fn invalid_index_type(checker: &mut Checker, expr: &ExprSubscript) { } // The value types supported by this rule should always be checkable - let value_type = CheckableExprType::try_from(value) - .expect("Expected indexed expression to be a checkable type."); + let Some(value_type) = CheckableExprType::try_from(value) else { + debug_assert!(false, "Index value must be a checkable type to generate a violation message."); + return; + }; // If the index is not a checkable type then we can't easily determine if there is a violation let Some(index_type) = CheckableExprType::try_from(index) else {