1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
13 #[warn(clippy::string_add)]
14 #[allow(clippy::string_add_assign)]
16 // ignores assignment distinction
17 let mut x = "".to_owned();
23 let y = "".to_owned();
29 #[warn(clippy::string_add_assign)]
30 fn add_assign_only() {
31 let mut x = "".to_owned();
37 let y = "".to_owned();
43 #[warn(clippy::string_add, clippy::string_add_assign)]
45 let mut x = "".to_owned();
51 let y = "".to_owned();
57 #[allow(dead_code, unused_variables)]
58 #[warn(clippy::string_lit_as_bytes)]
59 fn str_lit_as_bytes() {
60 let bs = "hello there".as_bytes();
62 let bs = r###"raw string with three ### in it and some " ""###.as_bytes();
64 // no warning, because this cannot be written as a byte string literal:
65 let ubs = "☃".as_bytes();
67 let strify = stringify!(foobar).as_bytes();
69 let includestr = include_str!("entry.rs").as_bytes();
72 #[allow(clippy::assign_op_pattern)]
78 // the add is only caught for `String`