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.
10 #[warn(clippy::string_add)]
11 #[allow(clippy::string_add_assign)]
13 // ignores assignment distinction
14 let mut x = "".to_owned();
20 let y = "".to_owned();
26 #[warn(clippy::string_add_assign)]
27 fn add_assign_only() {
28 let mut x = "".to_owned();
34 let y = "".to_owned();
40 #[warn(clippy::string_add, clippy::string_add_assign)]
42 let mut x = "".to_owned();
48 let y = "".to_owned();
54 #[allow(dead_code, unused_variables)]
55 #[warn(clippy::string_lit_as_bytes)]
56 fn str_lit_as_bytes() {
57 let bs = "hello there".as_bytes();
59 let bs = r###"raw string with three ### in it and some " ""###.as_bytes();
61 // no warning, because this cannot be written as a byte string literal:
62 let ubs = "☃".as_bytes();
64 let strify = stringify!(foobar).as_bytes();
66 let includestr = include_str!("entry.rs").as_bytes();
69 #[allow(clippy::assign_op_pattern)]
75 // the add is only caught for `String`