Skip to content

Commit 38e7bd2

Browse files
committed
Don't nudge people towards toilet closures when producing owl results
1 parent c3e9136 commit 38e7bd2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/ui/drop_forget_ref.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,38 @@ fn test_similarly_named_function() {
5555
forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name
5656
std::mem::forget(&SomeStruct);
5757
}
58+
59+
#[derive(Copy, Clone)]
60+
pub struct Error;
61+
fn produce_half_owl_error() -> Result<(), Error> {
62+
Ok(())
63+
}
64+
65+
fn produce_half_owl_ok() -> Result<bool, ()> {
66+
Ok(true)
67+
}
68+
69+
#[allow(dead_code)]
70+
fn test_owl_result() -> Result<(), ()> {
71+
produce_half_owl_error().map_err(|_| ())?;
72+
produce_half_owl_ok().map(|_| ())?;
73+
// the following should not be linted,
74+
// we should not force users to use toilet closures
75+
// to produce owl results when drop is more convenient
76+
produce_half_owl_error().map_err(drop)?;
77+
produce_half_owl_ok().map_err(drop)?;
78+
Ok(())
79+
}
80+
81+
82+
#[allow(dead_code)]
83+
fn test_owl_result_2() -> Result<u8, ()> {
84+
produce_half_owl_error().map_err(|_| ())?;
85+
produce_half_owl_ok().map(|_| ())?;
86+
// the following should not be linted,
87+
// we should not force users to use toilet closures
88+
// to produce owl results when drop is more convenient
89+
produce_half_owl_error().map_err(drop)?;
90+
produce_half_owl_ok().map(drop)?;
91+
Ok(1)
92+
}

0 commit comments

Comments
 (0)