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.
14 #[warn(clippy::string_add)]
15 #[allow(clippy::string_add_assign)]
16 fn add_only() { // 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 // no warning, because this cannot be written as a byte string literal:
63 let ubs = "☃".as_bytes();
65 let strify = stringify!(foobar).as_bytes();
73 // the add is only caught for `String`