Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
95c6866dd4ab3de3b21aa02ca93741c0010836f8
rust/tests/ui/byte_char_slices.rs

14 lines
349 B
Rust
Raw Normal View History

New Lint: `byte_char_slices` This patch adds a new lint that checks for potentially harder to read byte char slices: `&[b'a', b'b']` and suggests to replace them with the easier to read `b"ab"` form. Signed-Off-By: Marcel Müller <m.mueller@ifm.com> Co-authored-by: Matthias Beyer <matthias.beyer@ifm.com> Use iterator to skip validation Signed-off-by: Marcel Müller <m.mueller@ifm.com> Suggested-by: Alex Macleod <alex@macleod.io> Convert quote escapes to proper form Signed-off-by: Marcel Müller <m.mueller@ifm.com> Add more convertable test cases Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2023-01-04 09:31:12 +01:00
#![allow(unused)]
#![warn(clippy::byte_char_slices)]
fn main() {
let bad = &[b'a', b'b', b'c'];
let quotes = &[b'"', b'H', b'i'];
let quotes = &[b'\'', b'S', b'u', b'p'];
let escapes = &[b'\x42', b'E', b's', b'c'];
let good = &[b'a', 0x42];
let good = vec![b'a', b'a'];
let good: u8 = [b'a', b'c'].into_iter().sum();
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 223ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API