]> git.proxmox.com Git - rustc.git/blame - src/test/ui/lint/must_use-in-stdlib-traits.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / lint / must_use-in-stdlib-traits.rs
CommitLineData
0731742a 1#![deny(unused_must_use)]
48663c56 2#![feature(arbitrary_self_types)]
0731742a
XL
3
4use std::iter::Iterator;
5use std::future::Future;
6
532ac7d7 7use std::task::{Context, Poll};
0731742a
XL
8use std::pin::Pin;
9use std::unimplemented;
10
11struct MyFuture;
12
13impl Future for MyFuture {
14 type Output = u32;
15
532ac7d7 16 fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<u32> {
0731742a
XL
17 Poll::Pending
18 }
19}
20
21fn iterator() -> impl Iterator {
22 std::iter::empty::<u32>()
23}
24
25fn future() -> impl Future {
26 MyFuture
27}
28
29fn square_fn_once() -> impl FnOnce(u32) -> u32 {
30 |x| x * x
31}
32
33fn square_fn_mut() -> impl FnMut(u32) -> u32 {
34 |x| x * x
35}
36
37fn square_fn() -> impl Fn(u32) -> u32 {
38 |x| x * x
39}
40
41fn main() {
1b1a35ee
XL
42 iterator(); //~ ERROR unused implementer of `Iterator` that must be used
43 future(); //~ ERROR unused implementer of `Future` that must be used
44 square_fn_once(); //~ ERROR unused implementer of `FnOnce` that must be used
45 square_fn_mut(); //~ ERROR unused implementer of `FnMut` that must be used
46 square_fn(); //~ ERROR unused implementer of `Fn` that must be used
0731742a 47}