diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-31 08:38:08 -0700 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-31 09:10:34 -0700 |
| commit | 38e7bd20f29bfb6693f32fe7347ace0b95c7e7eb (patch) | |
| tree | 9d49f027d4c3d0c99d1b2caa5b276333ace28c00 | |
| parent | c3e913650e9850ccbb605ddc0d1a612fa70947d2 (diff) | |
| download | rust-38e7bd20f29bfb6693f32fe7347ace0b95c7e7eb.tar.gz rust-38e7bd20f29bfb6693f32fe7347ace0b95c7e7eb.zip | |
Don't nudge people towards toilet closures when producing owl results
| -rw-r--r-- | tests/ui/drop_forget_ref.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/drop_forget_ref.rs b/tests/ui/drop_forget_ref.rs index b3c75bc5764..b60f373e75e 100644 --- a/tests/ui/drop_forget_ref.rs +++ b/tests/ui/drop_forget_ref.rs @@ -55,3 +55,38 @@ fn test_similarly_named_function() { forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name std::mem::forget(&SomeStruct); } + +#[derive(Copy, Clone)] +pub struct Error; +fn produce_half_owl_error() -> Result<(), Error> { + Ok(()) +} + +fn produce_half_owl_ok() -> Result<bool, ()> { + Ok(true) +} + +#[allow(dead_code)] +fn test_owl_result() -> Result<(), ()> { + produce_half_owl_error().map_err(|_| ())?; + produce_half_owl_ok().map(|_| ())?; + // the following should not be linted, + // we should not force users to use toilet closures + // to produce owl results when drop is more convenient + produce_half_owl_error().map_err(drop)?; + produce_half_owl_ok().map_err(drop)?; + Ok(()) +} + + +#[allow(dead_code)] +fn test_owl_result_2() -> Result<u8, ()> { + produce_half_owl_error().map_err(|_| ())?; + produce_half_owl_ok().map(|_| ())?; + // the following should not be linted, + // we should not force users to use toilet closures + // to produce owl results when drop is more convenient + produce_half_owl_error().map_err(drop)?; + produce_half_owl_ok().map(drop)?; + Ok(1) +} |
