diff --git a/src/paths.rs b/src/paths.rs index 0bf9800..eea2f3f 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -43,8 +43,8 @@ pub const SLICE_GET_UNCHECKED_MUT: [&str; 4] = ["core", "slice", "", " pub const PTR_SLICE_FROM_RAW_PARTS: [&str; 3] = ["core", "ptr", "slice_from_raw_parts"]; pub const PTR_SLICE_FROM_RAW_PARTS_MUT: [&str; 3] = ["core", "ptr", "slice_from_raw_parts_mut"]; -pub const SLICE_FROM_RAW_PARTS: [&str; 3] = ["core", "slice", "from_raw_parts"]; -pub const SLICE_FROM_RAW_PARTS_MUT: [&str; 3] = ["core", "slice", "from_raw_parts_mut"]; +pub const SLICE_FROM_RAW_PARTS: [&str; 4] = ["core", "slice", "raw", "from_raw_parts"]; +pub const SLICE_FROM_RAW_PARTS_MUT: [&str; 4] = ["core", "slice", "raw", "from_raw_parts_mut"]; // Generic function call pub const PTR_DROP_IN_PLACE: [&str; 3] = ["core", "ptr", "drop_in_place"]; diff --git a/tests/panic_safety/slice_from_raw.rs b/tests/panic_safety/slice_from_raw.rs new file mode 100644 index 0000000..a120574 --- /dev/null +++ b/tests/panic_safety/slice_from_raw.rs @@ -0,0 +1,14 @@ +/*! +```rudra-test +test_type = "normal" +expected_analyzers = ["UnsafeDataflow"] +``` +!*/ + +pub trait Writer { + fn write_bytes(&mut self, slice: &[u8]) -> Result<(), ()>; + fn write_u8(&mut self, value: u8) -> Result<(), ()> { + let slice = unsafe { std::slice::from_raw_parts(&value, 1) }; + self.write_bytes(slice) + } +} \ No newline at end of file