summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/unused_result_ok.rs
blob: 117d64c4cec6039b22f5f82c6970305a80dbe30e (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
37
38
39
40
//@aux-build:proc_macros.rs
#![warn(clippy::unused_result_ok)]
#![allow(dead_code)]

#[macro_use]
extern crate proc_macros;

fn bad_style(x: &str) {
    x.parse::<u32>().ok();
}

fn good_style(x: &str) -> Option<u32> {
    x.parse::<u32>().ok()
}

#[rustfmt::skip]
fn strange_parse(x: &str) {
    x   .   parse::<i32>()   .   ok   ();
}

macro_rules! v {
    () => {
        Ok::<(), ()>(())
    };
}

macro_rules! w {
    () => {
        Ok::<(), ()>(()).ok();
    };
}

fn main() {
    v!().ok();
    w!();

    external! {
        Ok::<(),()>(()).ok();
    };
}