]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/let_underscore_untyped.rs
New upstream version 1.72.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / let_underscore_untyped.rs
1 //@aux-build: proc_macros.rs:proc-macro
2
3 #![allow(unused)]
4 #![warn(clippy::let_underscore_untyped)]
5
6 extern crate proc_macros;
7 use proc_macros::with_span;
8
9 use clippy_utils::is_from_proc_macro;
10 use std::future::Future;
11 use std::{boxed::Box, fmt::Display};
12
13 fn a() -> u32 {
14 1
15 }
16
17 fn b<T>(x: T) -> T {
18 x
19 }
20
21 fn c() -> impl Display {
22 1
23 }
24
25 fn d(x: &u32) -> &u32 {
26 x
27 }
28
29 fn e() -> Result<u32, ()> {
30 Ok(1)
31 }
32
33 fn f() -> Box<dyn Display> {
34 Box::new(1)
35 }
36
37 fn g() -> impl Fn() {
38 || {}
39 }
40
41 with_span!(
42 span
43
44 fn dont_lint_proc_macro() {
45 let _ = a();
46 }
47 );
48
49 fn main() {
50 let _ = a();
51 let _ = b(1);
52 let _ = c();
53 let _ = d(&1);
54 let _ = e();
55 let _ = f();
56 let _ = g();
57 let closure = || {};
58
59 _ = a();
60 _ = b(1);
61 _ = c();
62 _ = d(&1);
63 _ = e();
64 _ = f();
65
66 let _: u32 = a();
67 let _: u32 = b(1);
68 let _: &u32 = d(&1);
69 let _: Result<_, _> = e();
70 let _: Box<_> = f();
71
72 #[allow(clippy::let_underscore_untyped)]
73 let _ = a();
74 }