-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Issue
The nightly feature required here:
Lines 608 to 669 in b3d31ba
// this variant requires #![feature(unsized_locals)] | |
#[cfg(nightly)] | |
mod iter_extras { | |
use crate::serialisation::{SerError, TryClone}; | |
/// Additional iterator functions | |
pub trait IterExtras: Iterator { | |
/// Iterate over each item in the iterator and apply a function to it and a clone of the given value `t` | |
/// | |
/// Behaves like `iterator.for_each(|item| f(item, t.clone()))`, except that it avoids cloning | |
/// in the case where the iterator contains a single item or for the last item in a larger iterator. | |
/// | |
/// Use this when cloning `T` is relatively expensive compared to `f`. | |
fn for_each_with<T, F>(mut self, t: T, mut f: F) | |
where | |
T: Clone, | |
F: FnMut(Self::Item, T), | |
{ | |
let mut current: Option<Self::Item> = self.next(); | |
let mut next: Option<Self::Item> = self.next(); | |
while next.is_some() { | |
let item = current.take().unwrap(); | |
f(item, t.clone()); | |
current = next; | |
next = self.next(); | |
} | |
if let Some(item) = current.take() { | |
f(item, t) | |
} | |
} | |
/// Iterate over each item in the iterator and apply a function to it and a clone of the given value `t` | |
/// if such a clone can be created | |
/// | |
/// Behaves like `iterator.for_each(|item| f(item, t.try_clone()))`, except that it avoids cloning | |
/// in the case where the iterator contains a single item or for the last item in a larger iterator. | |
/// It also shortcircuits on cloning errors. | |
/// | |
/// Use this when trying to clone `T` is relatively expensive compared to `f`. | |
fn for_each_try_with<T, F>(mut self, t: T, mut f: F) -> Result<(), SerError> | |
where | |
T: TryClone, | |
F: FnMut(Self::Item, T), | |
{ | |
let mut current: Option<Self::Item> = self.next(); | |
let mut next: Option<Self::Item> = self.next(); | |
while next.is_some() { | |
let item = current.take().unwrap(); | |
let cloned = t.try_clone()?; | |
f(item, cloned); | |
current = next; | |
next = self.next(); | |
} | |
if let Some(item) = current.take() { | |
f(item, t) | |
} | |
Ok(()) | |
} | |
} | |
impl<T: ?Sized> IterExtras for T where T: Iterator {} | |
} |
And turned on optionally there:
core/src/lib.rs
74:#![cfg_attr(nightly, feature(unsized_locals))]
breaks with nightly 2020-10-29 because of rust-lang/rust#78152
feature(unsized_locals)
was split into two disjoint features:
- the
feature(unsized_locals)
which is marked as incomplete feature(unsized_fn_params)
which isn't, and which is what Kompact is actually using here.
So post nightly 2020-10-29, Kompact is not activating the feature it actually needs.
Steps to reproduce
cargo +nightly-2020-10-29-x86_64-unknown-linux-gnu check
possibly preceded by a rustup install
to install the nightly in question.
Witness the following output:
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> /home/huitseeker/.cargo/git/checkouts/kompact-8e3803f644d2dc0c/b3d31ba/core/src/utils.rs:621:32
|
621 | fn for_each_with<T, F>(mut self, t: T, mut f: F)
| ^^^^^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
624 | F: FnMut(Self::Item, T), Self: Sized
| ^^^^^^^^^^^^^
help: function arguments must have a statically known size, borrowed types always have a known size
|
621 | fn for_each_with<T, F>(&mut self, t: T, mut f: F)
| ^
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> /home/huitseeker/.cargo/git/checkouts/kompact-8e3803f644d2dc0c/b3d31ba/core/src/utils.rs:647:36
|
647 | fn for_each_try_with<T, F>(mut self, t: T, mut f: F) -> Result<(), SerError>
| ^^^^^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
650 | F: FnMut(Self::Item, T), Self: Sized
| ^^^^^^^^^^^^^
help: function arguments must have a statically known size, borrowed types always have a known size
|
647 | fn for_each_try_with<T, F>(&mut self, t: T, mut f: F) -> Result<(), SerError>
| ^
error: aborting due to 2 previous errors
Workaround
One simple way to upgrade is to update the activation of the unsized_locals
feature to target unsized_fn_params
. Except this is not backwards-compatible (feature gate errors are fatal and this triggers E0635) and will break every nightly below 2020-10-29.
That includes most nightlies in interactive (human-facing) use since rustfmt has not compiled on nightly since 2020-10-25 or so. It's advised not to merge until the "main" components are available in a post 10-29 nightly here :
https://rust-lang.github.io/rustup-components-history/