]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/string_lit_as_bytes.rs
Preparing for merge from rustc
[rust.git] / src / tools / clippy / tests / ui / string_lit_as_bytes.rs
1 // run-rustfix
2
3 #![allow(dead_code, unused_variables)]
4 #![warn(clippy::string_lit_as_bytes)]
5
6 fn str_lit_as_bytes() {
7     let bs = "hello there".as_bytes();
8
9     let bs = r###"raw string with 3# plus " ""###.as_bytes();
10
11     let bs = "lit to string".to_string().into_bytes();
12     let bs = "lit to owned".to_owned().into_bytes();
13
14     // no warning, because these cannot be written as byte string literals:
15     let ubs = "☃".as_bytes();
16     let ubs = "hello there! this is a very long string".as_bytes();
17
18     let ubs = "☃".to_string().into_bytes();
19     let ubs = "this is also too long and shouldn't be fixed".to_string().into_bytes();
20
21     let strify = stringify!(foobar).as_bytes();
22
23     let current_version = env!("CARGO_PKG_VERSION").as_bytes();
24
25     let includestr = include_str!("string_lit_as_bytes.rs").as_bytes();
26
27     let _ = "string with newline\t\n".as_bytes();
28 }
29
30 fn main() {}