diff options
| author | bors <bors@rust-lang.org> | 2024-09-03 18:29:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-03 18:29:20 +0000 |
| commit | f2ef26d239efbe2a229ad663d4ea8b4411f65b2b (patch) | |
| tree | 0b67ddf24982ef65fcea0edb1746010888eb190d | |
| parent | e8ba5d1f7146e5b634b7ea34a02a0c30f0f56da9 (diff) | |
| parent | a5e3a3f9b6bd85611fa098dab8948ecdcac98acc (diff) | |
| download | rust-f2ef26d239efbe2a229ad663d4ea8b4411f65b2b.tar.gz rust-f2ef26d239efbe2a229ad663d4ea8b4411f65b2b.zip | |
Auto merge of #13263 - y21:warn_manual_c_str_literals, r=Centri3
move `manual_c_str_literals` to complexity IMO the suggestion to use `c""` literals over a hardcoded `\0` byte string literal has some fairly strong upsides (no need to manually null-terminate it and the compiler checks for intermediary null bytes) that this should just be enabled by default. It's also written slightly conservatively to only emit a warning when we can be reasonably confident that the lint is *actually* applicable (that is, lint on e.g. `b"foo\0".as_ptr()` but not `b"foo\0"`. The latter looks like a c-string but its type is `&[u8; _]`, and if it's used in a context where a byte slice is needed then you have no nice way to convert to it from a `c"foo"` literal of type `&CStr`). changelog: move [`manual_c_str_literals`] to complexity (now warn-by-default)
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index e1f1df4eecb..6e1951f7fba 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -4036,7 +4036,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.78.0"] pub MANUAL_C_STR_LITERALS, - pedantic, + complexity, r#"creating a `CStr` through functions when `c""` literals can be used"# } |
