]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/result_unit_error.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / result_unit_error.rs
1 #![warn(clippy::result_unit_err)]
2
3 pub fn returns_unit_error() -> Result<u32, ()> {
4 Err(())
5 }
6
7 fn private_unit_errors() -> Result<String, ()> {
8 Err(())
9 }
10
11 pub trait HasUnitError {
12 fn get_that_error(&self) -> Result<bool, ()>;
13
14 fn get_this_one_too(&self) -> Result<bool, ()> {
15 Err(())
16 }
17 }
18
19 impl HasUnitError for () {
20 fn get_that_error(&self) -> Result<bool, ()> {
21 Ok(true)
22 }
23 }
24
25 trait PrivateUnitError {
26 fn no_problem(&self) -> Result<usize, ()>;
27 }
28
29 pub struct UnitErrorHolder;
30
31 impl UnitErrorHolder {
32 pub fn unit_error(&self) -> Result<usize, ()> {
33 Ok(0)
34 }
35 }
36
37 // https://github.com/rust-lang/rust-clippy/issues/6546
38 pub mod issue_6546 {
39 type ResInv<A, B> = Result<B, A>;
40
41 pub fn should_lint() -> ResInv<(), usize> {
42 Ok(0)
43 }
44
45 pub fn should_not_lint() -> ResInv<usize, ()> {
46 Ok(())
47 }
48
49 type MyRes<A, B> = Result<(A, B), Box<dyn std::error::Error>>;
50
51 pub fn should_not_lint2(x: i32) -> MyRes<i32, ()> {
52 Ok((x, ()))
53 }
54 }
55
56 fn main() {}