Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clippy_lints/src/strlen_on_c_strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ declare_clippy_lint! {
/// and suggest calling `as_bytes().len()` or `to_bytes().len()` respectively instead.
///
/// ### Why is this bad?
/// This avoids calling an unsafe `libc` function.
/// Currently, it also avoids calculating the length.
/// `libc::strlen` requires an unsafe block, which we don't really need if all
/// we want to know is the length of the string.
Comment on lines -17 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think phrase it more confidently as removing a call to an unsafe function rather than potentially removing an unsafe block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alexendoo how does something like this sound?

libc::strlen is an unsafe function, which we don't need to call if all we want to know is the length of the c-string.

///
/// ### Example
/// ```rust, ignore
Expand Down