summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/read_line_without_trim.rs
blob: bdc409a7010652973e8bd0b3b3c9b47f1e949c78 (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
32
33
34
35
36
//@run-rustfix

#![allow(unused)]
#![warn(clippy::read_line_without_trim)]

fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.pop();
    let _x: i32 = input.parse().unwrap(); // don't trigger here, newline character is popped

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let _x: i32 = input.parse().unwrap();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let _x = input.parse::<i32>().unwrap();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let _x = input.parse::<u32>().unwrap();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let _x = input.parse::<f32>().unwrap();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let _x = input.parse::<bool>().unwrap();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    // this is actually ok, so don't lint here
    let _x = input.parse::<String>().unwrap();
}