about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/string_to_string.rs
blob: 7c5bd8a897baa3b742e8e6e616623fc236929f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#![warn(clippy::string_to_string)]
#![allow(clippy::redundant_clone, clippy::unnecessary_literal_unwrap)]

fn main() {
    let mut message = String::from("Hello");
    let mut v = message.to_string();
    //~^ string_to_string

    let variable1 = String::new();
    let v = &variable1;
    let variable2 = Some(v);
    let _ = variable2.map(|x| {
        println!();
        x.to_string()
    });
    //~^^ string_to_string

    let x = Some(String::new());
    let _ = x.unwrap_or_else(|| v.to_string());
    //~^ string_to_string
}