Skip to content

Commit b2bdff4

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

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/ui/drop_forget_ref.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,44 @@ 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+
72+
produce_half_owl_error().map_err(|_| ())?;
73+
produce_half_owl_ok().map(|_| ())?;
74+
// the following should not be linted,
75+
// we should not force users to use toilet closures
76+
// to produce owl results when drop is more convenient
77+
produce_half_owl_error().map_err(drop)?;
78+
produce_half_owl_ok().map_err(drop)?;
79+
Ok(())
80+
}
81+
82+
83+
#[allow(dead_code)]
84+
fn test_owl_result_2() -> Result<u8, ()> {
85+
#[derive(Copy, Clone)]
86+
pub struct Error;
87+
fn produce_result() -> Result<(), Error> {
88+
Ok(())
89+
}
90+
produce_half_owl_error().map_err(|_| ())?;
91+
produce_half_owl_ok().map(|_| ())?;
92+
// the following should not be linted,
93+
// we should not force users to use toilet closures
94+
// to produce owl results when drop is more convenient
95+
produce_half_owl_error().map_err(drop)?;
96+
produce_half_owl_ok().map(drop)?;
97+
Ok(1)
98+
}

0 commit comments

Comments
 (0)