From 7d8fa4b6a5e4c600f70a79a95c938552ab373be4 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sun, 23 Jul 2023 22:47:13 +0200 Subject: [PATCH] Fix logic bug in stream::Stream::filter_map doctest --- ...-in-stream-Stream-filter_map-doctest.patch | 28 +++++++++++++++++++ rust-futures0.1.spec | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 0001-Fix-logic-bug-in-stream-Stream-filter_map-doctest.patch diff --git a/0001-Fix-logic-bug-in-stream-Stream-filter_map-doctest.patch b/0001-Fix-logic-bug-in-stream-Stream-filter_map-doctest.patch new file mode 100644 index 0000000..0aa20ba --- /dev/null +++ b/0001-Fix-logic-bug-in-stream-Stream-filter_map-doctest.patch @@ -0,0 +1,28 @@ +From 498252a35dd6e1b4f9c0b596dc52e5aee8fac8c4 Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Sun, 23 Jul 2023 22:32:41 +0200 +Subject: [PATCH] Fix logic bug in stream::Stream::filter_map doctest + +The operator for the modulo and the test were swapped, and using +"modulo zero" is undefined and results in an unconditional panic, +which is now caught with Rust 1.71 (unconditional_panic lint). +--- + src/stream/mod.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/stream/mod.rs b/src/stream/mod.rs +index 2d90362..9ad4eea 100644 +--- a/src/stream/mod.rs ++++ b/src/stream/mod.rs +@@ -399,7 +399,7 @@ pub trait Stream { + /// + /// let (_tx, rx) = mpsc::channel::(1); + /// let evens_plus_one = rx.filter_map(|x| { +- /// if x % 0 == 2 { ++ /// if x % 2 == 0 { + /// Some(x + 1) + /// } else { + /// None +-- +2.41.0 + diff --git a/rust-futures0.1.spec b/rust-futures0.1.spec index 01d4f91..d6badb1 100644 --- a/rust-futures0.1.spec +++ b/rust-futures0.1.spec @@ -13,6 +13,8 @@ Summary: Implementation of futures and streams featuring zero allocations License: MIT OR Apache-2.0 URL: https://crates.io/crates/futures Source: %{crates_source} +# https://github.com/rust-lang/futures-rs/pull/2765 +Patch: 0001-Fix-logic-bug-in-stream-Stream-filter_map-doctest.patch BuildRequires: rust-packaging >= 21