diff -Nru rust-easy-parallel-3.3.0/Cargo.toml rust-easy-parallel-3.3.1/Cargo.toml --- rust-easy-parallel-3.3.0/Cargo.toml 2023-04-07 19:05:46.000000000 +0000 +++ rust-easy-parallel-3.3.1/Cargo.toml 2023-09-25 17:19:44.000000000 +0000 @@ -3,10 +3,10 @@ # When publishing a new version: # - Update CHANGELOG.md # - Create "v3.x.y" git tag -version = "3.3.0" +version = "3.3.1" authors = ["Stjepan Glavina "] edition = "2018" -rust-version = "1.35" +rust-version = "1.63" description = "Run closures in parallel" license = "Apache-2.0 OR MIT" repository = "https://github.com/smol-rs/easy-parallel" diff -Nru rust-easy-parallel-3.3.0/CHANGELOG.md rust-easy-parallel-3.3.1/CHANGELOG.md --- rust-easy-parallel-3.3.0/CHANGELOG.md 2023-04-07 19:05:46.000000000 +0000 +++ rust-easy-parallel-3.3.1/CHANGELOG.md 2023-09-25 17:19:44.000000000 +0000 @@ -1,3 +1,7 @@ +# Version 3.3.1 + +- Reimplement using 100% safe code. (#11) + # Version 3.3.0 - Add `Parallel::collect()` and `Parallel::finish_in()` to allow for generic containers. (#9) diff -Nru rust-easy-parallel-3.3.0/debian/changelog rust-easy-parallel-3.3.1/debian/changelog --- rust-easy-parallel-3.3.0/debian/changelog 2023-08-14 11:24:14.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/changelog 2023-10-16 16:40:49.000000000 +0000 @@ -1,3 +1,16 @@ +rust-easy-parallel (3.3.1-1) unstable; urgency=medium + + [ upstream ] + * new release + + [ Jonas Smedegaard ] + * bump project version in virtual packages and autopkgtests + * relax to build-depend unversioned on dh-cargo + * update dh-cargo fork + * update copyright info: update coverage + + -- Jonas Smedegaard Mon, 16 Oct 2023 18:40:49 +0200 + rust-easy-parallel (3.3.0-2) unstable; urgency=medium * update dh-cargo fork; diff -Nru rust-easy-parallel-3.3.0/debian/control rust-easy-parallel-3.3.1/debian/control --- rust-easy-parallel-3.3.0/debian/control 2023-07-16 09:48:58.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/control 2023-10-16 16:39:44.000000000 +0000 @@ -3,7 +3,7 @@ Priority: optional Build-Depends: debhelper-compat (= 13), - dh-cargo (>= 25), + dh-cargo, libstring-shellquote-perl, Maintainer: Jonas Smedegaard Standards-Version: 4.6.2 @@ -21,7 +21,7 @@ librust-easy-parallel-3+default-dev (= ${binary:Version}), librust-easy-parallel-3-dev (= ${binary:Version}), librust-easy-parallel-3.3-dev (= ${binary:Version}), - librust-easy-parallel-3.3.0-dev (= ${binary:Version}), + librust-easy-parallel-3.3.1-dev (= ${binary:Version}), Description: run closures in parallel - Rust source code easy-parallel is a simple primitive for spawning threads in bulk and waiting for them to complete. diff -Nru rust-easy-parallel-3.3.0/debian/copyright rust-easy-parallel-3.3.1/debian/copyright --- rust-easy-parallel-3.3.0/debian/copyright 2023-02-01 14:49:58.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/copyright 2023-10-16 16:40:27.000000000 +0000 @@ -34,7 +34,7 @@ Reference: debian/copyright Files: - debian/debcargo/bin/cargo + debian/dh-cargo/bin/cargo Copyright: 2022 Jonas Smedegaard 2015-2016 Luca Bruno @@ -43,11 +43,13 @@ License: Apache-2.0 or Expat Files: + debian/dh-cargo/bin/dh-cargo-built-using debian/debcargo/lib/* Copyright: 2022-2023 Jonas Smedegaard 2016 Josh Triplett - 2018 Ximin Luo + 2019-2021 Sylvestre Ledru + 2018-2021 Ximin Luo License: Expat License: Apache-2.0 diff -Nru rust-easy-parallel-3.3.0/debian/copyright_hints rust-easy-parallel-3.3.1/debian/copyright_hints --- rust-easy-parallel-3.3.0/debian/copyright_hints 2023-07-16 09:49:48.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/copyright_hints 2023-10-16 16:40:34.000000000 +0000 @@ -33,6 +33,7 @@ Copyright: 2015-2016, Luca Bruno 2016-2019, Ximin Luo 2017-2019, Vasudeva Kamath + 2022, Jonas Smedegaard License: Apache-2.0 FIXME @@ -43,8 +44,16 @@ Files: debian/dh-cargo/lib/Debian/Debhelper/Buildsystem/cargo.pm Copyright: 2016, Josh Triplett - 2018, Ximin Luo + 2018-2021, Ximin Luo + 2019-2021, Sylvestre Ledru 2022-2023, Jonas Smedegaard License: Expat FIXME +Files: debian/dh-cargo/bin/dh-cargo-built-using +Copyright: 2018-2021, Ximin Luo + 2023, Jonas Smedegaard + file +License: Expat + FIXME + diff -Nru rust-easy-parallel-3.3.0/debian/dh-cargo/bin/cargo rust-easy-parallel-3.3.1/debian/dh-cargo/bin/cargo --- rust-easy-parallel-3.3.0/debian/dh-cargo/bin/cargo 2023-08-14 08:58:49.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/dh-cargo/bin/cargo 2023-09-21 13:43:46.000000000 +0000 @@ -2,9 +2,10 @@ """ Wrapper around cargo to have it build using Debian settings. +SPDX-FileCopyrightText: 2022 Jonas Smedegaard SPDX-FileCopyrightText: 2015-2016 Luca Bruno -SPDX-FileCopyrightText: 2016-2019 Ximin Luo SPDX-FileCopyrightText: 2017-2019 Vasudeva Kamath +SPDX-FileCopyrightText: 2016-2019 Ximin Luo SPDX-License-Identifier: Apache-2.0 or MIT @@ -175,9 +176,20 @@ build_profiles = os.getenv("DEB_BUILD_PROFILES", "").split() parallel = [] + lto = 0 for o in build_options: if o.startswith("parallel="): parallel = ["-j" + o[9:]] + elif o.startswith("optimize="): + opt_arg = o[9:] + for arg in opt_arg.split(","): + if opt_arg == "-lto": + lto = -1 + elif opt_arg == "+lto": + lto = 1 + else: + log(f"WARNING: unhandled optimization flag: {opt_arg}") + nodoc = "nodoc" in build_options or "nodoc" in build_profiles nocheck = "nocheck" in build_options or "nocheck" in build_profiles noopt = "noopt" in build_options @@ -190,7 +202,7 @@ host_rust_type = os.getenv("DEB_HOST_RUST_TYPE", "") host_gnu_type = os.getenv("DEB_HOST_GNU_TYPE", "") - log("options, profiles, parallel:", build_options, build_profiles, parallel) + log("options, profiles, parallel, lto:", build_options, build_profiles, parallel, lto) log("rust_type, gnu_type:", ", ".join([host_rust_type, host_gnu_type])) if "RUSTFLAGS" in os.environ: @@ -241,6 +253,11 @@ if nocheck and subcmd in ("test", "bench"): return 0 + if lto == 1: + newargs.append("--config profile.release.lto = \"thin\"") + elif lto == -1: + newargs.append("--config profile.release.lto = false") + if subcmd == "clean": logrun(["env", "RUST_BACKTRACE=1", "/usr/bin/cargo"] + list(newargs), check=True) if os.path.exists(cargo_home): diff -Nru rust-easy-parallel-3.3.0/debian/dh-cargo/bin/dh-cargo-built-using rust-easy-parallel-3.3.1/debian/dh-cargo/bin/dh-cargo-built-using --- rust-easy-parallel-3.3.0/debian/dh-cargo/bin/dh-cargo-built-using 1970-01-01 00:00:00.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/dh-cargo/bin/dh-cargo-built-using 2023-09-21 13:43:46.000000000 +0000 @@ -0,0 +1,179 @@ +#!/bin/sh +# Generates Built-Using after a successful cargo build. +# Run this in the package top-level directory where debian/ is. +# +# SPDX-FileCopyrightText: 2023 Jonas Smedegaard +# SPDX-FileCopyrightText: 2018-2021 Ximin Luo +# +# SPDX-License-Identifier: MIT + +set -e + +CARGO_MANIFEST_DIR="${CARGO_MANIFEST_DIR:-.}" +DEB_HOST_RUST_TYPE="${DEB_HOST_RUST_TYPE:-$(printf "include /usr/share/rustc/architecture.mk\nall:\n\techo \$(DEB_HOST_RUST_TYPE)\n" | make --no-print-directory -sf -)}" +CARGO_REGISTRY="${CARGO_REGISTRY:-debian/cargo_registry}" +CARGO_CHANNEL="${CARGO_CHANNEL:-release}" +# useful for testing: +# CARGO_REGISTRY="$HOME/.cargo/registry/src/github.com-1ecc6299db9ec823" DEB_HOST_RUST_TYPE="." CARGO_CHANNEL=debug + +CARGO_TARGET_DIR="$CARGO_MANIFEST_DIR/target/$DEB_HOST_RUST_TYPE/$CARGO_CHANNEL" +CARGO_TARGET_DIR_ABS="$(readlink -f "$CARGO_TARGET_DIR")" + +CPRIGHT_FORMAT="https://www.debian.org/doc/packaging-manuals/copyright-format/1.0" +SRCLEFT_LICENSES="$(echo GPL LGPL AGPL GFDL MPL CDDL CPL Artistic Perl QPL | tr ' ' '\n')" +pkg_has_srcleft_license() { + local pkg="$1" + local ver="$2" + local f="/usr/share/doc/$pkg/copyright" + if ! sed -nre 's ^Format: (.*) \1 gp' "$f" | grep -qiw "$CPRIGHT_FORMAT"; then + echo >&2 "$0: abort: Not in machine-readable format: $f" + echo 2 + elif sed -nre 's ^X-Binary-Requires-Source: (.*) \1 gp' "$f" | grep -qiw yes; then + echo 1 + elif sed -nre 's ^License: (.*) \1 gp' "$f" | grep -qiwF "$SRCLEFT_LICENSES"; then + echo 1 + else + echo 0 + fi +} + +dep_files_to_pkgs() { + xargs -r dpkg -S \ + | sed -nre 's (.*): .* \1 gp' \ + | xargs -r dpkg-query --show \ + | while read pkg ver; do echo "$pkg $ver $(pkg_has_srcleft_license "${pkg%:*}" "$ver")"; done + # pkg_has_srcleft_license should be accurate for all rust crates, no need to give a $containing_crate + # this is due to nature of crate copyright info, and the debian rust packaging policy +} + +rust_dep_files() { + cat "$CARGO_TARGET_DIR/deps"/*.d \ + | sed -nre 's ^\S*/('"$CARGO_REGISTRY"'/[^/]*)/.* '"$(readlink -f "$PWD")/"'\1 gp' \ + | sort -u \ + | xargs -r readlink -f +} + +rust_libs() { + { which rustc; rust_dep_files; } | dep_files_to_pkgs +} + +gcc_default_searchdirs() { + gcc -print-search-dirs \ + | sed -nre 's ^libraries: (.*) \1 gp' \ + | tr ':' '\n' \ + | sed -e 's ^= '"$(gcc -print-sysroot)"' g' \ + | xargs readlink -m 2>/dev/null # suppress errors caused by early pipe closure +} + +rust_search_lib() { + local lib="$1" + { + cat + # rust does not actually search normal paths when linking static libs + # - see https://github.com/rust-lang/rust/issues/43118 + # - see also `fn link_rlib` in back/link.rs which calls + # `pub fn find_library` in back/archive.rs which generates the error message + #gcc_default_searchdirs + } | while read searchdir; do + #echo >&2 "searching $searchdir for static lib $lib" + local f="$(readlink -m "$searchdir/lib${lib}.a")" + if test -f "$f"; then + printf "%s\n" "$f" + break + fi + done +} + +native_libs() { + ls -1d "$CARGO_TARGET_DIR/build"/*/output 2>/dev/null | while read output; do + sed -nre 's ^cargo:rustc-link-lib=static=(.*) \1 '"$output"' gp' "$output" + done | while read lib output; do + local containing_crate="$(basename "$(dirname "$output")")" + test -n "$lib" || continue + local libfile="$(sed -nre 's ^cargo:rustc-link-search=native=(.*) \1 gp' "$output" | rust_search_lib "$lib")" + local srcleft="" + test -n "$libfile" || { echo >&2 "$0: abort: could not find static lib '$lib'; rustc should have failed already?"; exit 1; } + echo >&2 "$0: found static lib $lib at $libfile" + if [ "${libfile#$CARGO_TARGET_DIR_ABS/}" != "$libfile" ]; then + # static library source code embedded in crate + local srcstat="$(sed -nre 's ^dh-cargo:deb-built-using='"$lib"'=([01]=.*) \1 gp' "$output")" + case "$srcstat" in + 0=*|1=*) + srcleft="${srcstat%%=*}" + libfile="${srcstat#*=}" + if [ "$(readlink -f "$libfile")" = "$(readlink -f "$PWD")" ]; then + # Note that this exception only applies in the case that where you are building + # the Debian package for $containing_crate itself. In the case where you are + # building a Debian package for crate X depending on $containing_crate, the + # latter still has to output the dh-cargo:deb-built-using in their build.rs so + # that the Debian package for crate X can correctly set Built-Using themselves. + echo >&2 "$0: static library derived from $libfile which is the top-level crate being built, no need to add Built-Using" + continue + fi + ;; + *) + echo >&2 "$0: abort: could not determine source-distribution conditions of ${libfile#$CARGO_TARGET_DIR_ABS/}." + echo >&2 "You must patch build.rs of ${containing_crate%-*} to output 'println!(\"dh-cargo:deb-built-using=$lib=\$s={}\", env::var(\"CARGO_MANIFEST_DIR\").unwrap());' where:" + echo >&2 "- \$s is 1 if the license(s) of the included static libs require source distribution alongside binaries, otherwise 0" + exit 1 + ;; + esac + fi + local wpkg="$(dpkg -S "$(readlink -f "$libfile")")" + test -n "$wpkg" || { echo >&2 "$0: abort: could not find Debian package for file $libfile"; exit 1; } + local pkgstat="$(echo "$wpkg" | sed -nre 's (.*): .* \1 gp' | xargs -r dpkg-query --show)" + local pkg="$(echo "$pkgstat" | cut -f1)" + local ver="$(echo "$pkgstat" | cut -f2)" + # static library source code embedded in crate (from earlier) + if [ -n "$srcleft" ]; then + echo "$pkg $ver $srcleft" + # static libraries from another Debian package + elif sed -nre 's ^dh-cargo:deb-built-using='"$lib"'=0~=(.*) \1 gp' "$output" | { echo "${pkg%:*} $ver" | grep -qExf /dev/fd/3; } 3<&0; then + echo "$pkg $ver 0" + elif sed -nre 's ^dh-cargo:deb-built-using='"$lib"'=1~=(.*) \1 gp' "$output" | { echo "${pkg%:*} $ver" | grep -qExf /dev/fd/3; } 3<&0; then + echo "$pkg $ver 1" + else + # guess the conditions based on the whole d/copyright file + # this loses granularity, e.g. gcc is mostly distributed as GPL-3 but the libbacktrace portion is BSD-3 + # to retain granularity the crate package maintainer should patch build.rs as suggested + echo >&2 "$0: warning: guessing source-distribution conditions of $libfile, this may be inaccurate." + echo >&2 "$0: warning: patch build.rs to suppress the above warning" + srcleft="$(pkg_has_srcleft_license "${pkg%:*}" "$ver")" + if [ "$srcleft" -gt 1 ]; then + echo >&2 "You must patch build.rs of ${containing_crate%-*} to output 'dh-cargo:deb-built-using=$lib=\$s~=\$PAT' where:" + echo >&2 "- \$s is 1 if the license(s) of the included static libs require source distribution alongside binaries, otherwise 0" + echo >&2 "- \$PAT is an egrep pattern matching the \"\$pkg \$ver\" combinations that satisfy \$s" + echo >&2 " for example '$pkg .*' matches the currently-relevant package, $pkg $ver" + exit 1 + fi + echo "$pkg $ver $srcleft" + fi + done +} + +output() { + local binpkg="$1" + if [ -z "$binpkg" ]; then + cat + else + local built_using="" + local built_using_x="" + while read pkg ver srcleft; do + local src="$(dpkg-query -f '${source:Package}' --show "$pkg")" + local srcver="$(dpkg-query -f '${source:Version}' --show "$pkg")" + case "$srcleft" in + 2) exit 1;; + 1) built_using="${built_using}$src (= $srcver), ";; + esac + built_using_x="${built_using_x}$src (= $srcver), " + done + echo "cargo:Built-Using=${built_using%, }" >> "debian/$binpkg.substvars" + echo "cargo:X-Cargo-Built-Using=${built_using_x%, }" >> "debian/$binpkg.substvars" + fi +} + +native_libs="$(native_libs)" # capture output outside of pipe so set -e works +{ +rust_libs +test -z "$native_libs" || echo "$native_libs" +} | LC_ALL=C.utf-8 sort -u | output "$@" diff -Nru rust-easy-parallel-3.3.0/debian/dh-cargo/lib/Debian/Debhelper/Buildsystem/cargo.pm rust-easy-parallel-3.3.1/debian/dh-cargo/lib/Debian/Debhelper/Buildsystem/cargo.pm --- rust-easy-parallel-3.3.0/debian/dh-cargo/lib/Debian/Debhelper/Buildsystem/cargo.pm 2023-08-14 08:58:49.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/dh-cargo/lib/Debian/Debhelper/Buildsystem/cargo.pm 2023-09-21 13:43:46.000000000 +0000 @@ -1,8 +1,9 @@ # debhelper buildsystem for Rust crates using Cargo # -# SPDX-FileCopyrightText: 2016 Josh Triplett -# SPDX-FileCopyrightText: 2018 Ximin Luo # SPDX-FileCopyrightText: 2022-2023 Jonas Smedegaard +# SPDX-FileCopyrightText: 2016 Josh Triplett +# SPDX-FileCopyrightText: 2019-2021 Sylvestre Ledru +# SPDX-FileCopyrightText: 2018-2021 Ximin Luo # # SPDX-License-Identifier: MIT # @@ -37,7 +38,7 @@ use String::ShellQuote qw( shell_quote ); use base 'Debian::Debhelper::Buildsystem'; -use constant CARGO_SYSTEM_REGISTRY => '/usr/share/cargo/registry/'; +use constant CARGO_SYSTEM_REGISTRY => '/usr/share/cargo/registry'; sub DESCRIPTION { "Rust Cargo" @@ -75,6 +76,11 @@ $crates{_default} //= \%object if $key->{name} eq $default; } + # resolve amount of local dependencies + # TODO: use Graph to compute an always reliable order instead + for my $key ( @{ $manifest->{packages} } ) { + $crates{ $key->{name} =~ tr/_/-/r }{depcount} = grep { exists $crates{ $_->{name} =~ tr/_/-/r } } @{ $key->{dependencies} }; + } return \%crates; } @@ -248,7 +254,7 @@ "--remap-path-prefix", "$_->{cratespec}=$_->{systempath}", )} map { @{ $this->{libpkg}{$_}{crates} } } sort keys %{ $this->{libpkg} }; - push @rustflags, "--remap-path-prefix", "$registry_path=" . CARGO_SYSTEM_REGISTRY; + push @rustflags, "--remap-path-prefix", "$registry_path=" . CARGO_SYSTEM_REGISTRY . '/'; my $rustflags = shell_quote(@rustflags); $rustflags .= " $ENV{RUSTFLAGS}" if $ENV{RUSTFLAGS}; @@ -260,8 +266,9 @@ if ( -d 'debian/vendorlibs' ) { complex_doit( qw(find debian/cargo_registry -lname '../vendorlibs/*' -delete)); + # force to favor this crate over a dependency pulled from system complex_doit( - qw(ln --symbolic --relative --target-directory=debian/cargo_registry debian/vendorlibs/*)); + qw(ln --symbolic --force --relative --target-directory=debian/cargo_registry debian/vendorlibs/*)); } $this->doit_in_sourcedir(qw(cargo update)) if -f $cargo_lock; } @@ -283,17 +290,22 @@ $this->doit_in_sourcedir($this->{cargo_command}, "test", @_); # test generating Built-Using fields my $channel = get_buildoption("noopt") ? 'debug' : 'release'; - doit("env", "CARGO_CHANNEL=$channel", "/usr/share/cargo/bin/dh-cargo-built-using"); + doit("env", + "CARGO_MANIFEST_DIR=" . $this->get_sourcedir(), + "CARGO_CHANNEL=$channel", + "debian/dh-cargo/bin/dh-cargo-built-using"); } sub install { my $this=shift; my $destdir=shift; - foreach my $crate ( map { @{ $_->{crates} } } sort values %{ $this->{libpkg} } ) { + foreach my $crate ( sort { $a->{depcount} cmp $b->{depcount} } map { @{ $_->{crates} } } sort values %{ $this->{libpkg} } ) { my $target = tmpdir( $crate->{libpkg}{name} ) . $crate->{systempath}; install_dir($target); - $this->doit_in_sourcedir( - qw(cargo package --offline --allow-dirty --no-verify --package), $crate->{pkgid} ); + $this->doit_in_somedir( + $crate->{sourcepath}, + qw(cargo package --offline --allow-dirty --no-verify), + '--target-dir', cwd . '/target', '--package', $crate->{pkgid} ); $this->doit_in_somedir( "$target/..", 'tar', map( { ( '--exclude', $_ ) } qw(debian/* debian Cargo.toml.orig Cargo.lock COPYING* LICENSE*) ), '-xvf', @@ -306,6 +318,11 @@ ">", "$target/.cargo-checksum.json"); # prevent an ftpmaster auto-reject regarding files with old dates. doit("touch", "-d@" . $ENV{SOURCE_DATE_EPOCH}, "$target/Cargo.toml"); + # add crate to local registry, needed by some multi-crate workspaces + # maybe related: + # force to favor this crate over a dependency pulled from system + complex_doit( + qw(ln --symbolic --force --relative --target-directory=debian/cargo_registry), $target ); } foreach my $featurepkg (@{$this->{featurepkg}}) { my $target = tmpdir( $featurepkg->{name} ) . "/usr/share/doc"; @@ -319,7 +336,9 @@ $this->doit_in_sourcedir("env", "DESTDIR=$destdir", "DEB_CARGO_CRATE=$crate->{cratespec}", $this->{cargo_command}, "install", @path_opts, @_); # generate Built-Using fields - doit("env", "/usr/share/cargo/bin/dh-cargo-built-using", $crate->{binpkg}{name}); + doit("env", + "CARGO_MANIFEST_DIR=" . $this->get_sourcedir(), + "debian/dh-cargo/bin/dh-cargo-built-using", $crate->{binpkg}{name}); } } diff -Nru rust-easy-parallel-3.3.0/debian/dh-cargo/README.md rust-easy-parallel-3.3.1/debian/dh-cargo/README.md --- rust-easy-parallel-3.3.0/debian/dh-cargo/README.md 2023-08-14 08:58:49.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/dh-cargo/README.md 2023-09-21 13:43:46.000000000 +0000 @@ -25,10 +25,11 @@ (not confusingly only dh_auto_test) Also included is a slight fork of related [cargo] wrapper script, -based on git commit e4072cb -(included with version 0.63.1-1 released 2022-11-16), +based on git commit bac0ad2d +(expected to be included with the version succeeding 0.66.0+ds1-1), with these functional changes: + * support CARGO_MANIFEST_DIR=${debhelper_sourcedirectory} * support --remap-path-prefix option sets in RUSTFLAGS by omitting that (not fail) when DEB_CARGO_CRATE is not set * support documented shorter CARGO_HOME path @@ -62,4 +63,4 @@ ``` - -- Jonas Smedegaard Mon, 14 Aug 2023 10:43:00 +0200 + -- Jonas Smedegaard Sun, 17 Sep 2023 07:36:27 +0200 diff -Nru rust-easy-parallel-3.3.0/debian/tests/control rust-easy-parallel-3.3.1/debian/tests/control --- rust-easy-parallel-3.3.0/debian/tests/control 2023-07-16 09:49:04.000000000 +0000 +++ rust-easy-parallel-3.3.1/debian/tests/control 2023-10-16 16:39:25.000000000 +0000 @@ -1,4 +1,4 @@ -Test-Command: /usr/share/cargo/bin/cargo-auto-test easy-parallel 3.3.0 +Test-Command: /usr/share/cargo/bin/cargo-auto-test easy-parallel 3.3.1 --all-targets --all-features Features: test-name=rust-easy-parallel-3:@ Depends: @@ -6,7 +6,7 @@ librust-easy-parallel-3-dev, Restrictions: allow-stderr -Test-Command: /usr/share/cargo/bin/cargo-auto-test easy-parallel 3.3.0 +Test-Command: /usr/share/cargo/bin/cargo-auto-test easy-parallel 3.3.1 --all-targets --no-default-features Features: test-name=rust-easy-parallel-3: Depends: @@ -14,7 +14,7 @@ librust-easy-parallel-3-dev, Restrictions: allow-stderr -Test-Command: /usr/share/cargo/bin/cargo-auto-test easy-parallel 3.3.0 +Test-Command: /usr/share/cargo/bin/cargo-auto-test easy-parallel 3.3.1 --all-targets Features: test-name=rust-easy-parallel-3:default Depends: diff -Nru rust-easy-parallel-3.3.0/.github/workflows/ci.yml rust-easy-parallel-3.3.1/.github/workflows/ci.yml --- rust-easy-parallel-3.3.0/.github/workflows/ci.yml 2023-04-07 19:05:46.000000000 +0000 +++ rust-easy-parallel-3.3.1/.github/workflows/ci.yml 2023-09-25 17:19:44.000000000 +0000 @@ -1,5 +1,8 @@ name: CI +permissions: + contents: read + on: pull_request: push: @@ -10,6 +13,7 @@ env: CARGO_INCREMENTAL: 0 + CARGO_NET_GIT_FETCH_WITH_CLI: true CARGO_NET_RETRY: 10 CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 @@ -30,7 +34,7 @@ os: [ubuntu-latest] rust: [nightly, beta, stable] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rust run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }} - run: cargo build --all --all-features --all-targets @@ -45,9 +49,9 @@ matrix: # When updating this, the reminder to update the minimum supported # Rust version in Cargo.toml. - rust: ['1.35'] + rust: ['1.63'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rust run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }} - run: cargo build @@ -55,7 +59,7 @@ clippy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rust run: rustup update stable - run: cargo clippy --all-features --all-targets @@ -63,7 +67,7 @@ fmt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rust run: rustup update stable - run: cargo fmt --all --check @@ -71,7 +75,7 @@ miri: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rust run: rustup toolchain install nightly --component miri && rustup default nightly - run: cargo miri test @@ -80,9 +84,13 @@ RUSTFLAGS: ${{ env.RUSTFLAGS }} -Z randomize-layout security_audit: + permissions: + checks: write + contents: read + issues: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # https://github.com/rustsec/audit-check/issues/2 - uses: rustsec/audit-check@master with: diff -Nru rust-easy-parallel-3.3.0/.github/workflows/release.yml rust-easy-parallel-3.3.1/.github/workflows/release.yml --- rust-easy-parallel-3.3.0/.github/workflows/release.yml 2023-04-07 19:05:46.000000000 +0000 +++ rust-easy-parallel-3.3.1/.github/workflows/release.yml 2023-09-25 17:19:44.000000000 +0000 @@ -1,5 +1,8 @@ name: Release +permissions: + contents: write + on: push: tags: @@ -10,7 +13,7 @@ if: github.repository_owner == 'smol-rs' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: taiki-e/create-gh-release-action@v1 with: changelog: CHANGELOG.md diff -Nru rust-easy-parallel-3.3.0/src/lib.rs rust-easy-parallel-3.3.1/src/lib.rs --- rust-easy-parallel-3.3.0/src/lib.rs 2023-04-07 19:05:46.000000000 +0000 +++ rust-easy-parallel-3.3.1/src/lib.rs 2023-09-25 17:19:44.000000000 +0000 @@ -57,12 +57,17 @@ //! ``` #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] +#![forbid(unsafe_code)] +#![doc( + html_favicon_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" +)] +#![doc( + html_logo_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" +)] use std::fmt; use std::iter::{self, FromIterator}; -use std::mem; use std::panic; -use std::process; use std::sync::mpsc; use std::thread; @@ -256,58 +261,50 @@ T: Send + 'a, C: FromIterator, { - // Set up a guard that aborts on panic. - let guard = NoPanic; - - // Join handles for spawned threads. - let mut handles = Vec::new(); - - // Channels to collect results from spawned threads. - let mut receivers = Vec::new(); - - // Spawn a thread for each closure after the first one. - for f in self.closures.into_iter() { - // Wrap into a closure that sends the result back. - let (sender, receiver) = mpsc::channel(); - let f = move || sender.send(f()).unwrap(); - - // Erase the `'a` lifetime. - let f: Box = Box::new(f); - let f: Box = unsafe { mem::transmute(f) }; - - // Spawn a thread for the closure. - handles.push(thread::spawn(f)); - receivers.push(receiver); - } + // Set up a new thread scope. + thread::scope(|scope| { + // Join handles for spawned threads. + let mut handles = Vec::new(); + + // Channels to collect results from spawned threads. + let mut receivers = Vec::new(); + + for f in self.closures.into_iter() { + // Wrap into a closure that sends the result back. + let (sender, receiver) = mpsc::channel(); + let f = move || sender.send(f()).unwrap(); + + // Spawn it on the scope. + handles.push(scope.spawn(f)); + receivers.push(receiver); + } - let mut last_err = None; + let mut last_err = None; - // Run the main closure on the main thread. - let res = panic::catch_unwind(panic::AssertUnwindSafe(f)); + // Run the main closure on the main thread. + let res = panic::catch_unwind(panic::AssertUnwindSafe(f)); - // Join threads and save the last panic if there was one. - for h in handles { - if let Err(err) = h.join() { - last_err = Some(err); + // Join threads and save the last panic if there was one. + for h in handles { + if let Err(err) = h.join() { + last_err = Some(err); + } } - } - // Drop the guard because we may resume a panic now. - drop(guard); - - // If a thread has panicked, resume the last collected panic. - if let Some(err) = last_err { - panic::resume_unwind(err); - } + // If a thread has panicked, resume the last collected panic. + if let Some(err) = last_err { + panic::resume_unwind(err); + } - // Collect the results from threads. - let results = receivers.into_iter().map(|r| r.recv().unwrap()).collect(); + // Collect the results from threads. + let results = receivers.into_iter().map(|r| r.recv().unwrap()).collect(); - // If the main closure panicked, resume its panic. - match res { - Ok(r) => (results, r), - Err(err) => panic::resume_unwind(err), - } + // If the main closure panicked, resume its panic. + match res { + Ok(r) => (results, r), + Err(err) => panic::resume_unwind(err), + } + }) } } @@ -324,14 +321,3 @@ Self::new() } } - -/// Aborts the process if dropped while panicking. -struct NoPanic; - -impl Drop for NoPanic { - fn drop(&mut self) { - if thread::panicking() { - process::abort(); - } - } -} diff -Nru rust-easy-parallel-3.3.0/tests/smoke.rs rust-easy-parallel-3.3.1/tests/smoke.rs --- rust-easy-parallel-3.3.0/tests/smoke.rs 2023-04-07 19:05:46.000000000 +0000 +++ rust-easy-parallel-3.3.1/tests/smoke.rs 2023-09-25 17:19:44.000000000 +0000 @@ -5,7 +5,7 @@ #[test] fn smoke() { let m = Mutex::new(0); - let v = vec![2, 3, 5, 7, 11]; + let v = [2, 3, 5, 7, 11]; Parallel::new() .add(|| *m.lock().unwrap() += 10) @@ -18,7 +18,7 @@ #[test] fn squares() { - let v = vec![10, 20, 30]; + let v = [10, 20, 30]; let squares = Parallel::new().each(0..v.len(), |i| v[i] * v[i]).run(); @@ -27,7 +27,7 @@ #[test] fn finish() { - let v = vec![10, 20, 30]; + let v = [10, 20, 30]; let (squares, len) = Parallel::new() .each(0..v.len(), |i| v[i] * v[i])