rust-clippy/tests/ui/string_lit_as_bytes.rs
Jens Hausdorf 6d1aaac6c3 Avoid reporting string_lit_as_bytes for long strings
Port of @jens1o code ([b76f939][jens1o_commit])

Fixes #1208

[jens1o_commit]: b76f939ac2

Co-authored-by: Thiago Arrais <thiago.arrais@gmail.com>
2019-07-08 13:13:01 -03:00

20 lines
521 B
Rust

// run-rustfix
#![allow(dead_code, unused_variables)]
#![warn(clippy::string_lit_as_bytes)]
fn str_lit_as_bytes() {
let bs = "hello there".as_bytes();
let bs = r###"raw string with 3# plus " ""###.as_bytes();
// no warning, because these cannot be written as byte string literals:
let ubs = "".as_bytes();
let ubs = "hello there! this is a very long string".as_bytes();
let strify = stringify!(foobar).as_bytes();
let includestr = include_str!("entry.rs").as_bytes();
}
fn main() {}