summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/let_underscore_untyped.rs
blob: bd94a3ada18b94b069e0a15cdb116160f22569ae (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//@aux-build: proc_macros.rs

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

extern crate proc_macros;
use proc_macros::with_span;

use clippy_utils::is_from_proc_macro;
use std::boxed::Box;
use std::fmt::Display;
use std::future::Future;

fn a() -> u32 {
    1
}

fn b<T>(x: T) -> T {
    x
}

fn c() -> impl Display {
    1
}

fn d(x: &u32) -> &u32 {
    x
}

fn e() -> Result<u32, ()> {
    Ok(1)
}

fn f() -> Box<dyn Display> {
    Box::new(1)
}

fn g() -> impl Fn() {
    || {}
}

with_span!(
    span

    fn dont_lint_proc_macro() {
        let _ = a();
    }
);

fn main() {
    let _ = a();
    let _ = b(1);
    let _ = c();
    let _ = d(&1);
    let _ = e();
    let _ = f();
    let _ = g();
    let closure = || {};

    _ = a();
    _ = b(1);
    _ = c();
    _ = d(&1);
    _ = e();
    _ = f();

    let _: u32 = a();
    let _: u32 = b(1);
    let _: &u32 = d(&1);
    let _: Result<_, _> = e();
    let _: Box<_> = f();

    #[allow(clippy::let_underscore_untyped)]
    let _ = a();
}