Skip to content

Commit 85c06c6

Browse files
emilkclaude
andcommitted
feat: enable clippy::fallible_impl_from
Catches `From` implementations that can panic, where `TryFrom` would be the honest signature. All three existing hits would need a breaking API change to fix, so they get `#[expect]` for now. Two of them (`Constraint`) panic on a protobuf message with an unset `constraint_mode`, i.e. on malformed input. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent a7b89ec commit 85c06c6

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ empty_enum_variants_with_brackets = "warn"
227227
empty_enums = "warn"
228228
exit = "warn"
229229
expl_impl_clone_on_copy = "warn"
230+
# Catches `From` impls that can panic
231+
fallible_impl_from = "warn"
230232
flat_map_option = "warn"
231233
fn_params_excessive_bools = "warn"
232234
fn_to_numeric_cast_any = "warn"

‎datafusion/common/src/scalar/mod.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5353,6 +5353,10 @@ impl From<Option<&str>> for ScalarValue {
53535353
}
53545354

53555355
/// Wrapper to create ScalarValue::Struct for convenience
5356+
#[expect(
5357+
clippy::fallible_impl_from,
5358+
reason = "Making this fallible would be a breaking API change"
5359+
)]
53565360
impl From<Vec<(&str, ScalarValue)>> for ScalarValue {
53575361
fn from(value: Vec<(&str, ScalarValue)>) -> Self {
53585362
value

‎datafusion/proto-common/src/from_proto/mod.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,10 @@ impl From<protobuf::Constraints> for Constraints {
750750
}
751751
}
752752

753+
#[expect(
754+
clippy::fallible_impl_from,
755+
reason = "Making this fallible would be a breaking API change"
756+
)]
753757
impl From<protobuf::Constraint> for Constraint {
754758
fn from(value: protobuf::Constraint) -> Self {
755759
match value.constraint_mode.unwrap() {
@@ -882,6 +886,10 @@ impl From<protobuf::JoinSide> for JoinSide {
882886
}
883887
}
884888

889+
#[expect(
890+
clippy::fallible_impl_from,
891+
reason = "Making this fallible would be a breaking API change"
892+
)]
885893
impl From<&protobuf::Constraint> for Constraint {
886894
fn from(value: &protobuf::Constraint) -> Self {
887895
match &value.constraint_mode {

0 commit comments

Comments
 (0)