Handle the new clippy::manual_c_str_literals lint · Issue #2994 · rust-lang/rust-bindgen (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@nyurik

Description

@nyurik

Clippy 1.83 introduced manual_c_str_literals on this type of generated code:

#[allow(unsafe_code)] pub const VSL_CLASS: &::std::ffi::CStr = unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"Log\0") };

warning: calling `CStr::new` with a byte string literal
   --> .../out/bindings.rs:708:14
    |
708 |     unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"Log\0") };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"Log"`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals
    = note: `#[warn(clippy::manual_c_str_literals)]` on by default

Possible solutions