-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Summary
There is usually no way for extern code to convert a &Vec<u8> to a &[u8] as the layout of the latter is unspecified.
Why this is bad
Requiring the argument to be of the specific size makes the function less useful for no benefit;
The benefit is that it can be used from extern code.
Lint Name
ptr_arg
Reproducer
I tried this code:
#[no_mangle]
pub extern "C" fn read_buffer(buffer: &Vec<u8>, len: usize) {
}I saw this happen:
|
2 | pub extern "C" fn read_buffer(buffer: &Vec<u8>, len: usize) {
| ^^^^^^^^ help: change this to: `&[u8]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
= note: `#[warn(clippy::ptr_arg)]` on by default
I expected to see this happen:
No warning.
Version
Playground
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy