about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/string_add.rs
blob: 5c7d13ebcd58b6271a743354554a660082a7ff43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//@aux-build:proc_macros.rs
//@no-rustfix
extern crate proc_macros;
use proc_macros::external;

#[warn(clippy::string_add)]
#[allow(clippy::assign_op_pattern, clippy::string_add_assign, unused)]
fn main() {
    // ignores assignment distinction
    let mut x = String::new();

    for _ in 1..3 {
        x = x + ".";
        //~^ string_add
    }

    let y = String::new();
    let z = y + "...";
    //~^ string_add

    assert_eq!(&x, &z);

    let mut x = 1;
    x = x + 1;
    assert_eq!(2, x);

    external!({
        let y = "".to_owned();
        let z = y + "...";
    });
}