Coder Social home page Coder Social logo

cargo-equip's Introduction

cargo-equip

CI codecov dependency status Crates.io Crates.io

日本語

A Cargo subcommand to bundle your code into one .rs file for competitive programming.

Recent updates

See CHANGELOG.md or Releases for recent updates.

Features

cargo-equip can

  • bundle multiple crates,
  • bundle only used crates,
  • exclude certain crates (--exclude-{atcoder, codingame}-crates),
  • expand procedural macros,
  • preserve scopes for #[macro_export]ed macros,
  • resolve #[cfg(..)],
  • remove comments and doc comments (--remove),
  • minify code (--minify),
  • and check the output.

Example

Sqrt Mod - Library-Cheker

[package]
name = "library-checker"
version = "0.0.0"
edition = "2018"

[dependencies]
ac-library-rs-parted-modint = { git = "https://github.com/qryxip/ac-library-rs-parted" }
proconio = { version = "0.4.3", features = ["derive"] }
qryxip-competitive-tonelli-shanks = { git = "https://github.com/qryxip/competitive-programming-library" }
# ...
use acl_modint::ModInt;
use proconio::{fastout, input};
use tonelli_shanks::ModIntBaseExt as _;

#[fastout]
fn main() {
    input! {
        yps: [(u32, u32)],
    }

    for (y, p) in yps {
        ModInt::set_modulus(p);
        if let Some(x) = ModInt::new(y).sqrt() {
            println!("{}", x);
        } else {
            println!("-1");
        }
    }
}

mod sub {
    // You can also `use` the crate in submodules.

    #[allow(unused_imports)]
    use proconio::input as _;
}

cargo equip \
>       --remove docs `# Remove doc comments` \
>       --minify libs `# Minify each library` \
>       --bin sqrt_mod `# Specify the bin crate` | xsel -b

Submit Info #59239 - Library-Checker

Works With

Installation

Install a nightly toolchain and cargo-udeps first.

rustup update nightly
cargo install cargo-udeps

From Crates.io

cargo install cargo-equip

From master branch

cargo install cargo-equip --git https://github.com/qryxip/cargo-equip

GitHub Releases

Releases

Usage

Follow these constrants when you writing libraries to bundle.

  1. Set package.edition to "2018".

    "2015" is not supported.

  2. Do not use procedural macros in lib crates.

    You can pub use them, but cannot call.

  3. Use $crate instead of crate in macros.

    cargo-equip replaces $crate in macro_rules! with $crate::extern_crate_name_in_main_crate. crate identifiers in macro_rules! are not modified.

  4. Do not use absolute path as possible.

    cargo-equip replaces crate with crate::extern_crate_name_in_main_crate and pub(crate) with pub(in crate::extern_crate_name_in_main_crate).

    However I cannot ensure this works well. Use self:: and super:: instead of crate::.

    -use crate::foo::Foo;
    +use super::foo::Foo;
  5. If possible, do not use glob import.

    cargo-equip inserts glob imports as substitutes for extern prelude and #[macro_use].

  6. Split into small separate crates as possible.

    cargo-equip does not search "dependencies among items".

    On a website other except AtCoder, Split your library into small crates to fit in 64KiB.

    .
    ├── a
    │   ├── Cargo.toml
    │   └── src
    │       └── lib.rs
    ├── b
    │   ├── Cargo.toml
    │   └── src
    │       └── lib.rs
    

When you finish preparing your library crates, add them to [dependencies] of the bin/example. If you generate packages automatically with a tool, add them to its template.

If you want to use rust-lang-ja/ac-library-rs, use qryxip/ac-library-rs-parted instead.

[dependencies]
ac-library-rs-parted             = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-convolution = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-dsu         = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-fenwicktree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-lazysegtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-math        = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-maxflow     = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-mincostflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-modint      = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-scc         = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-segtree     = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-string      = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-twosat      = { git = "https://github.com/qryxip/ac-library-rs-parted" }

The constraints for bins/examples are:

  1. If you use proc-macro crates, make sure the macro names unique.

    If you have trouble about procedural macro names, you can import them with #[macor_use].

  2. If possible, do not use glob import.

    cargo-equip also inserts glob imports as it does into libraries.

    pub use __cargo_equip::prelude::*;
    
    // ︙
    
    pub mod __cargo_equip {
        pub mod crates {
            // ︙
        }
        // ︙
    
        pub(crate) prelude {
            pub use crate::__cargo_equip::crates::*;
        }
    }
use input::input;
use mic::answer;
use partition_point::RangeBoundsExt as _;

#[answer(join("\n"))]
fn main() -> _ {
    input! {
        a: [u64],
    }
    a.into_iter()
        .map(|a| (1u64..1_000_000_000).partition_point(|ans| ans.pow(2) < a))
}

Then execute cargo-equip.

cargo equip --bin "$name"

Resolving #[cfg(…)]

By default, cargo-equip

  1. Removes #[cfg(always_true_predicate)] (e.g. cfg(feature = "enabled-feature")).
  2. Removes items with #[cfg(always_false_preducate)] (e.g. cfg(test), cfg(feature = "disable-feature")).

Predicates are evaluated according to this rule.

#[allow(dead_code)]
pub mod a {
    pub struct A;

    #[cfg(test)]
    mod tests {
        #[test]
        fn it_works() {
            assert_eq!(2 + 2, 4);
        }
    }
}

#[allow(dead_code)]
pub mod a {
    pub struct A;
}

Checking the output

By default, cargo-equip creates a temporary package that shares the current target directory and execute cargo check before outputting.

    Checking cargo-equip-check-output-6j2i3j3tgtugeaqm v0.1.0 (/tmp/cargo-equip-check-output-6j2i3j3tgtugeaqm)
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s

Expanding procedural macros

cargo-equip can expand procedural macros.

use memoise::memoise;
use proconio_derive::fastout;

#[fastout]
fn main() {
    for i in 0..=10 {
        println!("{}", fib(i));
    }
}

#[memoise(n <= 10)]
fn fib(n: i64) -> i64 {
    if n == 0 || n == 1 {
        return n;
    }
    fib(n - 1) + fib(n - 2)
}
  • proc-macro crates need to be compile with Rust 1.48.0+. If version of the active toolchain is less than 1.48.0, cargo-equip finds an alternative toolchain and uses it for compiling proc-macros.
  • procedural macros re-exported with pub use $name::*; are also able to be expanded.

Options

--remove <REMOVE>...

Removes

  • doc comments (//! .., /// .., /** .. */, #[doc = ".."]) with --remove docs.
  • comments (// .., /* .. */) with --remove comments.
#[allow(dead_code)]
pub mod a {
    //! A.

    /// A.
    pub struct A; // aaaaa
}

#[allow(dead_code)]
pub mod a {
    pub struct A;
}

--minify <MINIFY>

Minifies

  • each expaned library with --minify lib.
  • the whole code with --minify all.

Not that the minification function is incomplete. Unnecessary spaces may be inserted.

--no-resolve-cfgs

Do not resolve #[cfg(…)].

--no-rustfmt

Do not format the output.

--no-check

Do not check the output.

License

Dual-licensed under MIT or Apache-2.0.

cargo-equip's People

Contributors

bors[bot] avatar ichyo avatar qryxip avatar sgthr7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cargo-equip's Issues

`package.authors` will be deprecated

rust-lang/rfcs#3052

The package.authors field could be deprecated and removed in a future

cargo init will stop pre-populating the field when running the command, and it will not include the field at all in the default Cargo.toml. Crate authors will still be able to manually include the field before publishing if they so choose.

Drawbacks

This RFC will make it harder for third-party tools to query the author information of crates published to crates.io.

By design, this RFC discourages adding the metadata allowing to know historical crate authors and makes it harder to retrieve it. In some cases, crate authors may have wanted that information preserved. After this RFC, crate authors who want to display historical authors who are not current crate owners will have to present that information in some other way.

Expand procedural macros with `rust-analyzer(.exe)`

そういえばRAはどうやってproc-macroを扱っているのかと思い調べたら、プロセス間でJSONのRPCをする方法を取っていた。(RAのarchitecture.md) 例えばListMacroは次のようにして呼び出せる。

echo '{"ListMacro":{"lib":"../../target/debug/deps/libfastout-2dbcc333cc21dae5.so"}}' | rust-analyzer proc-macro
{"ListMacro":{"macros":[["fastout","Attr"]]}}

ExpansionMacroについてもproc-macro2から上手くJSONにシリアライズすればいけるはず。これでwattを要求しなくてもよくなる。

Expand multiple libraries

#1 のような場合に複数のライブラリを展開できるようにする。

#[cargo_equip::equip]
use ::{
    __lib1::{a, b, c},
    __lib2::{d, e, f},
};

Memory allocation of 140015098745856 bytes failed

I have followed the basic setup. This is my Cargo.toml file:

[package]
name = "love-story"
version = "0.0.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
proconio = { version = "0.4.3", features = ["derive"] }

I'm on Ubuntu.

The full error message:

memory allocation of 140015098745856 bytes failed
error: could not bundle the code

- `proconio 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::proconio`
- `proconio-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__proconio_derive_0_2_1`


Caused by:
  rust-analyzer error

Caused by:
  server exited

It cant function without allocating 140 Terabytes.

user@user-HP-Laptop-15s-du3xxx:/media/user/Local Disk/Game and others help/Ascendance/Ascendance$ cargo equip --exclude-atcoder-crates
     Running `/home/user/.cargo/bin/rustup run nightly-x86_64-unknown-linux-gnu cargo check --message-format json -p 'ascendance:0.1.0' --lib`
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
       Using `stable-x86_64-unknown-linux-gnu` for compiling `proc-macro` crates
     Running `/home/user/.cargo/bin/rustup run stable-x86_64-unknown-linux-gnu cargo check --message-format json -p 'ascendance:0.1.0' --lib`
    Finished dev [unoptimized + debuginfo] target(s) in 0.45s
memory allocation of 140401238446080 bytes failed
error: could not bundle the code

- `adler 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__adler_1_0_2`
- `adler32 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__adler32_1_2_0`
- `ahash 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__ahash_0_7_6`
- `alsa-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__alsa_sys_0_3_1`
- `approx 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__approx_0_5_1`
- `arrayref 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__arrayref_0_3_6`
- `arrayvec 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__arrayvec_0_5_2`
- `arrayvec 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__arrayvec_0_7_2`
- `ascendance 0.1.0 (path+file:///media/user/Local%20Disk/Game%20and%20others%20help/Ascendance/Ascendance)` as `crate::__cargo_equip::crates::ascendance`
- `atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__atty_0_2_14`
- `base64 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__base64_0_13_0`
- `bit-vec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__bit_vec_0_6_3`
- `bit_field 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__bit_field_0_10_1`
- `bitflags 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__bitflags_1_3_2`
- `bytemuck 1.12.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__bytemuck_1_12_1`
- `byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__byteorder_1_4_3`
- `calloop 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__calloop_0_10_1`
- `cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__cfg_if_0_1_10`
- `cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__cfg_if_1_0_0`
- `clap 3.2.22 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::clap`
- `clap_derive 3.2.18 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__clap_derive_3_2_18`
- `clap_lex 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__clap_lex_0_2_4`
- `color_quant 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__color_quant_1_1_0`
- `copypasta 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__copypasta_0_8_1`
- `crc32fast 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crc32fast_1_3_2`
- `crossbeam 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossbeam_0_8_2`
- `crossbeam-channel 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossbeam_channel_0_5_6`
- `crossbeam-deque 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossbeam_deque_0_8_2`
- `crossbeam-epoch 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossbeam_epoch_0_9_10`
- `crossbeam-queue 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossbeam_queue_0_3_6`
- `crossbeam-utils 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossbeam_utils_0_8_11`
- `crossfont 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__crossfont_0_5_0`
- `cty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__cty_0_2_2`
- `ddsfile 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__ddsfile_0_5_1`
- `dlib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__dlib_0_5_0`
- `downcast-rs 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__downcast_rs_1_2_0`
- `either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__either_1_8_0`
- `enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__enum_primitive_0_1_1`
- `expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__expat_sys_2_1_6`
- `exr 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__exr_1_5_0`
- `filetime 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__filetime_0_2_17`
- `flate2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__flate2_1_0_24`
- `flume 0.10.14 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__flume_0_10_14`
- `fontdue 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fontdue_0_7_2`
- `foreign-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__foreign_types_0_5_0`
- `foreign-types-macros 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__foreign_types_macros_0_2_2`
- `foreign-types-shared 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__foreign_types_shared_0_3_1`
- `freetype-rs 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__freetype_rs_0_26_0`
- `freetype-sys 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__freetype_sys_0_13_1`
- `futures 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_0_3_24`
- `futures-channel 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_channel_0_3_24`
- `futures-core 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_core_0_3_24`
- `futures-executor 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_executor_0_3_24`
- `futures-io 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_io_0_3_24`
- `futures-macro 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_macro_0_3_24`
- `futures-sink 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_sink_0_3_24`
- `futures-task 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_task_0_3_24`
- `futures-util 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__futures_util_0_3_24`
- `fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fxhash_0_2_1`
- `fyrox 0.27.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::fyrox`
- `fyrox-core 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fyrox_core_0_21_0`
- `fyrox-core-derive 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fyrox_core_derive_0_16_0`
- `fyrox-resource 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fyrox_resource_0_5_0`
- `fyrox-sound 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fyrox_sound_0_28_0`
- `fyrox-ui 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__fyrox_ui_0_18_0`
- `getrandom 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__getrandom_0_2_7`
- `gif 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__gif_0_11_4`
- `git-version 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::git_version`
- `git-version-macro 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__git_version_macro_0_3_5`
- `glow 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__glow_0_11_2`
- `glutin 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__glutin_0_29_1`
- `glutin_egl_sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__glutin_egl_sys_0_1_6`
- `glutin_glx_sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__glutin_glx_sys_0_1_8`
- `half 1.8.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__half_1_8_2`
- `hashbrown 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__hashbrown_0_11_2`
- `hashbrown 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__hashbrown_0_12_3`
- `hound 3.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__hound_3_5_0`
- `hrtf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__hrtf_0_8_0`
- `image 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::image`
- `indexmap 1.9.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__indexmap_1_9_1`
- `inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__inflate_0_4_5`
- `inotify 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__inotify_0_7_1`
- `inotify-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__inotify_sys_0_1_5`
- `instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__instant_0_1_12`
- `iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__iovec_0_1_4`
- `jpeg-decoder 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__jpeg_decoder_0_2_6`
- `js-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__js_sys_0_3_60`
- `lazycell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__lazycell_1_3_0`
- `lebe 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__lebe_0_5_2`
- `lewton 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__lewton_0_10_2`
- `libc 0.2.132 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__libc_0_2_132`
- `libloading 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__libloading_0_7_3`
- `libm 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__libm_0_2_5`
- `lock_api 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__lock_api_0_4_8`
- `log 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__log_0_4_17`
- `matrixmultiply 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__matrixmultiply_0_3_2`
- `memchr 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__memchr_2_5_0`
- `memmap2 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__memmap2_0_5_7`
- `memoffset 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__memoffset_0_6_5`
- `minimal-lexical 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__minimal_lexical_0_2_1`
- `miniz_oxide 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__miniz_oxide_0_5_4`
- `mio 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__mio_0_6_23`
- `mio 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__mio_0_8_4`
- `mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__mio_extras_2_0_6`
- `nalgebra 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__nalgebra_0_31_1`
- `nalgebra-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__nalgebra_macros_0_1_0`
- `nanorand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__nanorand_0_7_0`
- `net2 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__net2_0_2_37`
- `nix 0.24.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__nix_0_24_2`
- `nom 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__nom_7_1_1`
- `notify 4.0.17 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__notify_4_0_17`
- `num-complex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_complex_0_4_2`
- `num-derive 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_derive_0_3_3`
- `num-integer 0.1.45 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_integer_0_1_45`
- `num-rational 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_rational_0_4_1`
- `num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_traits_0_1_43`
- `num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_traits_0_2_15`
- `num_cpus 1.13.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__num_cpus_1_13_1`
- `ogg 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__ogg_0_8_0`
- `once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__once_cell_1_14_0`
- `optional 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__optional_0_5_0`
- `os_str_bytes 6.3.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__os_str_bytes_6_3_0`
- `osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__osmesa_sys_0_1_2`
- `parking_lot 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__parking_lot_0_12_1`
- `parking_lot_core 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__parking_lot_core_0_9_3`
- `parry2d 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__parry2d_0_9_0`
- `parry3d 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__parry3d_0_9_0`
- `paste 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__paste_1_0_9`
- `percent-encoding 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__percent_encoding_2_2_0`
- `pin-project 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__pin_project_1_0_12`
- `pin-project-internal 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__pin_project_internal_1_0_12`
- `pin-project-lite 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__pin_project_lite_0_2_9`
- `pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__pin_utils_0_1_0`
- `png 0.17.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__png_0_17_6`
- `ppv-lite86 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__ppv_lite86_0_2_16`
- `primal-check 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__primal_check_0_3_3`
- `proc-macro-hack 0.5.19 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__proc_macro_hack_0_5_19`
- `rand 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::rand`
- `rand_chacha 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rand_chacha_0_3_1`
- `rand_core 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rand_core_0_6_4`
- `rapier2d 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rapier2d_0_14_0`
- `rapier3d 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rapier3d_0_14_0`
- `raw-window-handle 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__raw_window_handle_0_4_3`
- `raw-window-handle 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__raw_window_handle_0_5_0`
- `rawpointer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rawpointer_0_2_1`
- `rayon 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rayon_1_5_3`
- `rayon-core 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rayon_core_1_9_3`
- `realfft 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__realfft_2_0_1`
- `robust 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__robust_0_2_3`
- `ron 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::ron`
- `rubato 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rubato_0_10_1`
- `rustfft 6.0.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__rustfft_6_0_1`
- `safe_arch 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__safe_arch_0_5_2`
- `safe_arch 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__safe_arch_0_6_0`
- `same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__same_file_1_0_6`
- `scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__scoped_tls_1_0_0`
- `scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__scoped_threadpool_0_1_9`
- `scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__scopeguard_1_1_0`
- `sctk-adwaita 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__sctk_adwaita_0_4_2`
- `serde 1.0.144 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::serde`
- `serde_derive 1.0.144 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__serde_derive_1_0_144`
- `servo-fontconfig 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__servo_fontconfig_0_5_1`
- `servo-fontconfig-sys 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__servo_fontconfig_sys_5_1_0`
- `shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__shared_library_0_1_9`
- `simba 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__simba_0_7_2`
- `slab 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__slab_0_4_7`
- `slotmap 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__slotmap_1_0_6`
- `smallvec 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__smallvec_1_9_0`
- `smithay-client-toolkit 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__smithay_client_toolkit_0_16_0`
- `smithay-clipboard 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__smithay_clipboard_0_6_6`
- `spade 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__spade_2_0_0`
- `spin 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__spin_0_9_4`
- `strength_reduce 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__strength_reduce_0_2_3`
- `strsim 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__strsim_0_10_0`
- `strum 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__strum_0_24_1`
- `strum_macros 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__strum_macros_0_24_3`
- `tbc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__tbc_0_3_0`
- `termcolor 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__termcolor_1_1_3`
- `textwrap 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__textwrap_0_15_1`
- `thiserror 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__thiserror_1_0_35`
- `thiserror-impl 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__thiserror_impl_1_0_35`
- `threadpool 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__threadpool_1_8_1`
- `tiff 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__tiff_0_7_3`
- `tiny-skia 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__tiny_skia_0_7_0`
- `tiny-skia-path 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__tiny_skia_path_0_7_0`
- `tinyvec 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__tinyvec_1_6_0`
- `tinyvec_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__tinyvec_macros_0_1_0`
- `transpose 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__transpose_0_2_1`
- `ttf-parser 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__ttf_parser_0_15_2`
- `typenum 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__typenum_1_15_0`
- `uuid 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__uuid_1_1_2`
- `vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__vec_map_0_8_2`
- `walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__walkdir_2_3_2`
- `wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wasm_bindgen_0_2_83`
- `wasm-bindgen-macro 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wasm_bindgen_macro_0_2_83`
- `wayland-client 0.29.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wayland_client_0_29_5`
- `wayland-commons 0.29.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wayland_commons_0_29_5`
- `wayland-cursor 0.29.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wayland_cursor_0_29_5`
- `wayland-egl 0.29.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wayland_egl_0_29_5`
- `wayland-protocols 0.29.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wayland_protocols_0_29_5`
- `wayland-sys 0.29.5 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wayland_sys_0_29_5`
- `web-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__web_sys_0_3_60`
- `weezl 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__weezl_0_1_7`
- `wide 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__wide_0_7_4`
- `winit 0.27.3 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__winit_0_27_3`
- `x11-clipboard 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__x11_clipboard_0_6_1`
- `x11-dl 2.20.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__x11_dl_2_20_0`
- `xcb 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__xcb_1_1_1`
- `xcursor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::__xcursor_0_3_4`


Caused by:
  rust-analyzer error

Caused by:
  server exited

`proconio` クレートがバンドルできない

cargo-equip のバージョン: 0.11.1

proconio 0.3.6 に依存するコードに対して cargo equip を実行すると、spin クレートが見つからない旨のエラーが出て失敗します。

再現手順

新規ディレクトリを作って中に入り、以下のコマンドを実行:

$ cargo init
$ echo 'proconio = "0.3.6"' >> Cargo.toml
$ echo 'extern crate proconio as _; fn main(){}' > src/main.rs
$ cargo equip

すると、以下のエラーが出て失敗します:

error: could not bundle the code

- `lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__lazy_static_1_4_0`
- `proconio 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::proconio`

note: attempted to bundle with the following crate(s), which are available on AtCoder. to exclude them from bundling, run with `--exclude-atcoder-crates`

- `lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)`
- `proconio 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)`


Caused by:
  no external library found which `extern_crate_name` is `spin`

spin クレートは proconio が依存する lazy_static が optional に依存しているようです。

Look into `Expr`s in certain `std` macros

こう、なんかこんな感じで

    fn exprs_in_macros(mac: &Macro) -> Vec<Expr> {
        if [
            parse_quote!(::core::assert),
            parse_quote!(::core::debug_assert),
            parse_quote!(::alloc::assert),
            parse_quote!(::alloc::debug_assert),
            parse_quote!(::std::assert),
            parse_quote!(::std::debug_assert),
        ]
        .contains(&mac.path)
        {
            //
        }
        if [
            parse_quote!(::core::assert_eq),
            parse_quote!(::core::assert_ne),
            parse_quote!(::core::debug_assert_eq),
            parse_quote!(::core::debug_assert_ne),
            parse_quote!(::alloc::assert_eq),
            parse_quote!(::alloc::assert_ne),
            parse_quote!(::alloc::debug_assert_eq),
            parse_quote!(::alloc::debug_assert_ne),
            parse_quote!(::std::assert_eq),
            parse_quote!(::std::assert_ne),
            parse_quote!(::std::debug_assert_eq),
            parse_quote!(::std::debug_assert_ne),
        ]
        .contains(&mac.path)
        {
            //
        }
        if [
            parse_quote!(::core::format_args),
            parse_quote!(::alloc::format_args),
            parse_quote!(::std::format_args),
        ]
        .contains(&mac.path)
        {
            //
        }
        if [
            parse_quote!(::core::matches),
            parse_quote!(::alloc::matches),
            parse_quote!(::std::matches),
        ]
        .contains(&mac.path)
        {
            //
        }
        todo!()
    }

`difference` crate is unmaintained

Crate:         difference
Version:       2.0.0
Warning:       unmaintained
Title:         difference is unmaintained
Date:          2020-12-20
ID:            RUSTSEC-2020-0095
URL:           https://rustsec.org/advisories/RUSTSEC-2020-0095
Dependency tree:
difference 2.0.0
└── cargo-equip 0.9.3

Enable `us`ing `#[macro_export]`ed declarative macros

このようにすればいけるのでは?

use proconio::input;

fn main() {
    input! {
        n: usize,
    }
}

const _: () = {
    #[macro_export]
    macro_rules! __cargo_equip_declarative_macro_proconio_input(($($_:tt)*) => {/*こっちに持ってくる*/};);
};

pub mod proconio {
    pub use crate::__cargo_equip_declarative_macro_proconio_input as input;

    /*#[macro_export]
    macro_rules! input {
        ($($_:tt)*) => {};
    }*/
}

Replace paths with leading `::`

宣言型/手続き型マクロで出力するこれを

extern crate foo as __foo;
use __foo::Foo;

こう書けるようにする。

use ::foo::Foo;

Does not work with Nightly Rust

let preds = {
let rustc_exe = crate::process::cargo_exe()?
.with_file_name("rustc")
.with_extension(env::consts::EXE_EXTENSION);
let preds = crate::process::process(rustc_exe)
.args(&["--print", "cfg"])
.cwd(package.manifest_path.with_file_name(""))
.read(true)?;
cfg_expr::Expression::parse(&format!("all({})", preds.lines().format(",")))?
};

     Running `/home/ryo/.cargo/bin/rustup run nightly cargo udeps --output json -p library-checker --bin sqrt_mod`
    Checking library-checker v0.0.0 (/home/ryo/src/competitive/library-checker)
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
info: Loading save analysis from "/home/ryo/src/competitive/library-checker/target/debug/deps/save-analysis/sqrt_mod-2aea88e752fd2a7f.json"
error: all(debug_assertions,panic="unwind",target_arch="x86_64",target_endian="little",target_env="gnu",target_family="unix",target_feature="fxsr",target_feature="sse",target_feature="sse2",target_has_atomic="16",target_has_atomic="32",target_has_atomic="64",target_has_atomic="8",target_has_atomic="ptr",target_has_atomic_equal_alignment="16",target_has_atomic_equal_alignment="32",target_has_atomic_equal_alignment="64",target_has_atomic_equal_alignment="8",target_has_atomic_equal_alignment="ptr",target_has_atomic_load_store="16",target_has_atomic_load_store="32",target_has_atomic_load_store="64",target_has_atomic_load_store="8",target_has_atomic_load_store="ptr",target_os="linux",target_pointer_width="64",target_thread_local,target_vendor="unknown",unix)
                                                                                                                                                                                       ^^^^^^^^^^^^^^^^^ expected one of `target_arch`, `target_feature`, `target_os`, `target_family`, `target_env`, `target_endian`, `target_pointer_width`, `target_vendor` here

Failed to expand nested mods

Version

> cargo equip -V
cargo-equip 0.19.0

Small Example

https://github.com/SaiYS/dbg-cargo-equip
applying cargo-equip on src/bin/main.rs causes error.

error: could not bundle the code
dbg-cargo-equip 0.1.0 (path+file:///Users/roku/room/cloned/dbg-cargo-equip) as crate::__cargo_equip::crates::dbg_cargo_equip
Caused by:
could not expand dbg_cargo_equip from dbg-cargo-equip 0.1.0 (path+file:///Users/roku/room/cloned/dbg-cargo-equip)
Caused by:
one of ["/Users/roku/room/cloned/dbg-cargo-equip/src/bar.rs", "/Users/roku/room/cloned/dbg-cargo-equip/src/bar/mod.rs"] does not exist

Considerations

It seems to trying to expand not crate::foo::bar but crate::bar. Maybe replacing with_file_name() with join() will works well.

.with_file_name(&ident.to_string())

.with_file_name(&ident.to_string())

マルチバイト文字が含まれる場合の--remove (docs|comments) の挙動が怪しい

--remove docs--remove commentsを指定したときに、展開コード中にマルチバイト文字が含まれている場合にコメントが正常に除去されなかったりエラーで落ちたりすることがありました。

文字コードは全てutf8です(BOMなし)

// a.rs

/// あ,い
pub fn hoge() -> i32 {
    42
}

/// う、え
pub fn b() -> String {
    "aaa".into()
}

// お,か
//b.rs

pub fn fuga() -> String {
    "ほげ".into()
}

#[cfg(test)]
mod test {
    use crate::b::*;
    #[test]
    fn test() {
        assert_eq!(fuga(), "ほげ");
    }
}
// main.rs
#[cfg_attr(cargo_equip, cargo_equip::equip)]
use ::__test_lib::{a::*};

fn main() {
}

a.rsを展開したときの結果(--remove docs)

$ cargo equip --remove docs
    Bundling code
//! # Bundled libraries
//!
//! ## `test_lib` (private)
//!
//! ### Modules
//!
//! - `::__test_lib::a` → `$crate::a`

/*#[cfg_attr(cargo_equip, cargo_equip::equip)]
use ::__test_lib::{a::*};*/

fn main() {
}

// The following code was expanded by `cargo-equip`.

use self :: a :: * ;

pub mod a {
    ,pub fn hoge() -> i32 {
        42
    }

           、え
    pub fn b() -> String {
        "aaa".into()
    }

    // お,か
}

a.rsを展開したときの結果(--remove comments)

$ cargo equip --remove comments
    Bundling code
//! # Bundled libraries
//!
//! ## `test_lib` (private)
//!
//! ### Modules
//!
//! - `::__test_lib::a` → `$crate::a`

/*#[cfg_attr(cargo_equip, cargo_equip::equip)]
use ::__test_lib::{a::*};*/

fn main() {
}

// The following code was expanded by `cargo-equip`.

use self :: a :: * ;

pub mod a {
    /// あ    
    pub fn hoge() -> i32 {
        42
    }

    /// う      
    pub fn b() -> String {
        "aaa".into()
    }

              
}

b.rsを展開したときの結果(--remove docs)
(おそらく正常な出力だと思います)

$ cargo equip --remove docs
    Bundling code
//! # Bundled libraries
//!
//! ## `test_lib` (private)
//!
//! ### Modules
//!
//! - `::__test_lib::b` → `$crate::b`

/*#[cfg_attr(cargo_equip, cargo_equip::equip)]
use ::__test_lib::{b::*};*/

fn main() {
}

// The following code was expanded by `cargo-equip`.

use self :: b :: * ;

pub mod b {
    pub fn fuga() -> String {
        "ほげ".into()
    }

    #[cfg(test)]
    mod test {
        use crate::b::*;
        #[test]
        fn test() {
            assert_eq!(fuga(), "ほげ");
        }
    }
}

b.rsを展開したときの結果(--remove comments)

$ cargo equip --remove comments
    Bundling code
error: failed to erase comments

Caused by:
  invalid utf-8 sequence of 2 bytes from index 153

A `extern crate` can modify a extern prelude

extern crate $name as $renameはルートモジュールで宣言された場合、extern preludeに$renameを追加する。

extern crate alloc as rename;

mod m {
    use rename::vec::Vec as _;
}

このことを完全に失念していた。「extern preludeから名前を解決するな」とREADMEに書いているので問題は無いと言えば無いのだが...

いっそこうやって疑似extern preludeを作ろうか... こういう形にすれば「通常のRustの書き方」で書けるようになるし。

mod lib {
    mod __pseudo_extern_prelude {
        pub(crate) use crate::another_lib;
    }

    use crate::lib::__pseudo_extern_prelude::*;

    use another_lib::A;
}

mod another_lib {
    pub struct A;
}

cargo-equip Incompatible minify results with Rust 2021

https://doc.rust-lang.org/reference/tokens.html#reserved-prefixes

Edition Differences: Starting with the 2021 edition, reserved prefixes are reported as an error by the lexer (in particular, they cannot be passed to macros).

Before the 2021 edition, reserved prefixes are accepted by the lexer and interpreted as multiple tokens (for example, one token for the identifier or keyword, followed by a # token).

Examples accepted in all editions:

macro_rules! lexes {($($_:tt)*) => {}}
lexes!{a #foo}
lexes!{continue 'foo}
lexes!{match "..." {}}
lexes!{r#let#foo}         // three tokens: r#let # foo

Examples accepted before the 2021 edition but rejected later:

macro_rules! lexes {($($_:tt)*) => {}}
lexes!{a#foo}
lexes!{continue'foo}
lexes!{match"..." {}}

--remove comments を指定するとタプル型の内部のカンマが消える

--remove commentsを指定したときにタプル型の2つ目以降のカンマが消えてしまうようです

タプル値では起きないようです

// a.rs

type Hoge = (f64, f64, f64, f64);

pub fn f(_: (i64, i64, i64)) -> (i64, i64, i64) {
    let _ = (1, 2, 3);
    todo!()
}
// main.rs

#[cfg_attr(cargo_equip, cargo_equip::equip)]
use ::__test_lib::{a::*};

fn main() {
}

出力

$ cargo equip --remove  comments 
    Bundling code
//! # Bundled libraries
//!
//! ## `test_lib` (private)
//!
//! ### Modules
//!
//! - `::__test_lib::a` → `$crate::a`

/*#[cfg_attr(cargo_equip, cargo_equip::equip)]
use ::__test_lib::{a::*};*/

fn main() {
}

// The following code was expanded by `cargo-equip`.

use self :: a :: * ;

pub mod a {
    type Hoge = (f64, f64  f64  f64);

    pub fn f(_: (i64, i64  i64)) -> (i64, i64  i64) {
        let _ = (1, 2, 3);
        todo!()
    }
}

segmentation fault: cargo equip --exclude-atcoder-crates --resolve-cfgs --remove docs --minify

I got segmentation fault error.

Result

❯ cargo equip --exclude-atcoder-crates --resolve-cfgs --remove docs --minify libs --rustfmt --check --bin pastbook2022-g
warning: `--resolve-cfgs` is deprecated. `#[cfg(..)]`s are resolved by default
warning: `--rustfmt` is deprecated. the output is formatted by default
warning: `--check` is deprecated. the output is checked by default
     Running `/Users/xxxx/.cargo/bin/rustup run nightly cargo udeps --output json -p pastbook2022 --bin pastbook2022-g`
    Checking pastbook2022 v0.1.0 (/Users/xxxx/xxxx/xxxxxxxx/pastbook2022)
warning: variable `N` should have a snake case name
 --> src/bin/g.rs:6:9
  |
6 |         N: usize,
  |         ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `Q` should have a snake case name
 --> src/bin/g.rs:7:9
  |
7 |         Q: usize,
  |         ^ help: convert the identifier to snake case: `q`

warning: variable `A` should have a snake case name
 --> src/bin/g.rs:8:9
  |
8 |         A: [u64; N],
  |         ^ help: convert the identifier to snake case: `a`

warning: variable `TXY` should have a snake case name
 --> src/bin/g.rs:9:9
  |
9 |         TXY: [(usize, usize, u64); Q],
  |         ^^^ help: convert the identifier to snake case: `txy`

warning: `pastbook2022` (bin "pastbook2022-g") generated 4 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.55s
info: Loading depinfo from "/Users/xxxx/target/debug/deps/pastbook2022_g-aae5a6c66b940542.d"
    Bundling the code
zsh: segmentation fault  cargo equip --exclude-atcoder-crates --resolve-cfgs --remove docs --minify   

Source code

  • g.rs
use proconio::input;
use ac_library::segtree;

fn main() {
    input!{
        N: usize,
        Q: usize,
        A: [u64; N],
        TXY: [(usize, usize, u64); Q],
    }

    let mut segtree = segtree::Segtree::<segtree::Min<u64>>::new(N);
    for i in 0..A.len() {
        segtree.set(i, A[i]);
    }

    let mut anss = vec!{};
    for (t, x, y) in TXY {
        if t == 1 {
            segtree.set(x, y);
        } else if t == 2 {
            let minval = segtree.prod(x as usize..y as usize);
            anss.push(minval);
        }
    }

    for ans in anss {
        println!("{}", ans);
    }
}
  • Cargo.toml
[package]
name = "pastbook2022"
version = "0.1.0"
edition = "2018"

[package.metadata.cargo-compete.bin]
pastbook2022-a = { alias = "a", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_a" }
pastbook2022-b = { alias = "b", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_b" }
pastbook2022-c = { alias = "c", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_c" }
pastbook2022-d = { alias = "d", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_d" }
pastbook2022-e = { alias = "e", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_e" }
pastbook2022-f = { alias = "f", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_f" }
pastbook2022-g = { alias = "g", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_g" }
pastbook2022-h = { alias = "h", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_h" }

[[bin]]
name = "pastbook2022-a"
path = "src/bin/a.rs"

[[bin]]
name = "pastbook2022-b"
path = "src/bin/b.rs"

[[bin]]
name = "pastbook2022-c"
path = "src/bin/c.rs"

[[bin]]
name = "pastbook2022-d"
path = "src/bin/d.rs"

[[bin]]
name = "pastbook2022-e"
path = "src/bin/e.rs"

[[bin]]
name = "pastbook2022-f"
path = "src/bin/f.rs"

[[bin]]
name = "pastbook2022-g"
path = "src/bin/g.rs"

[[bin]]
name = "pastbook2022-h"
path = "src/bin/h.rs"

[dependencies]
num = "=0.2.1"
num-bigint = "=0.2.6"
num-complex = "=0.2.4"
num-integer = "=0.1.42"
num-iter = "=0.1.40"
num-rational = "=0.2.4"
num-traits = "=0.2.11"
num-derive = "=0.3.0"
ndarray = "=0.13.0"
nalgebra = "=0.20.0"
alga = "=0.9.3"
libm = "=0.2.1"
rand = { version = "=0.7.3", features = ["small_rng"] }
getrandom = "=0.1.14"
rand_chacha = "=0.2.2"
rand_core = "=0.5.1"
rand_hc = "=0.2.0"
rand_pcg = "=0.2.1"
rand_distr = "=0.2.2"
petgraph = "=0.5.0"
indexmap = "=1.3.2"
regex = "=1.3.6"
lazy_static = "=1.4.0"
ordered-float = "=1.0.2"
ascii = "=1.0.0"
permutohedron = "=0.2.4"
superslice = "=1.0.0"
itertools = "=0.9.0"
itertools-num = "=0.1.3"
maplit = "=1.0.2"
either = "=1.5.3"
im-rc = "=14.3.0"
fixedbitset = "=0.2.0"
bitset-fixed = "=0.1.0"
proconio = { version = "=0.3.6", features = ["derive"] }
text_io = "=0.1.8"
whiteread = "=0.5.0"
rustc-hash = "=1.1.0"
smallvec = "=1.2.0"
ac-library-rs = { git = "https://github.com/rust-lang-ja/ac-library-rs" }

[dev-dependencies]

Environment

❯ rustup show                                                                                                           
Default host: aarch64-apple-darwin
rustup home:  /Users/xxxx/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin (default)
stable-x86_64-apple-darwin
beta-aarch64-apple-darwin
nightly-aarch64-apple-darwin
1.68.2-aarch64-apple-darwin

active toolchain
----------------

stable-aarch64-apple-darwin (default)
rustc 1.68.2 (9eb3afe9e 2023-03-27)
❯ cargo equip -V
cargo-equip 0.19.0  

Failed to minify Floating-point literals followed by `.`

pub fn test() {
    dbg!(1. ..2.);
}

上のコードをバンドルした結果、minify で壊れました

$ cargo equip --example minify --minify libs --check
error: unexpected token: `...`
  --> examples\cargo-equip-check-output-acjm3glcr0fl7guq.rs:13:91
   |
13 | #[cfg_attr(any(),rustfmt::skip)]#[allow(unused)]pub mod minify_sample{pub fn test(){dbg!(1...2.);}}
   |                                                                                           ^^^
   |
help: use `..` for an exclusive range
   |
13 | #[cfg_attr(any(),rustfmt::skip)]#[allow(unused)]pub mod minify_sample{pub fn test(){dbg!(1..2.);}}
   |                                                                                           ^^
help: or `..=` for an inclusive range
   |
13 | #[cfg_attr(any(),rustfmt::skip)]#[allow(unused)]pub mod minify_sample{pub fn test(){dbg!(1..=2.);}}
   |                                                                                           ^^^

error[E0308]: mismatched types
  --> examples\cargo-equip-check-output-acjm3glcr0fl7guq.rs:13:94
   |
13 | #[cfg_attr(any(),rustfmt::skip)]#[allow(unused)]pub mod minify_sample{pub fn test(){dbg!(1...2.);}}
   |                                                                                              ^^ expected integer, found floating-point number

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `cargo-equip-check-output-acjm3glcr0fl7guq`

To learn more, run the command again with --verbose.
error: the bundled code was not valid

参考:https://doc.rust-lang.org/stable/reference/tokens.html#floating-point-literals

Attempting to install from master fails

If I run the command in your readme to install from master

cargo install --git https://github.com/qryxip/cargo-equip

it fails with the error:

error: multiple packages with binaries found: cargo-equip, solutions

Could not execute process curl

I tried to equip a source code that depends on whiteread. Then I had the following message:

❮ cargo equip --minify libs --mine github.com/krdln --remove docs --remove comments | win32yank.exe -i
     Running `/home/username/.cargo/bin/rustup run nightly cargo udeps --output json -p crate-name --bin alds1_14_b`
    Checking crate-name v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
info: Loading save analysis from "/path/to/alds1_14_b-a56770b0284a7106.json"
    Bundling the code
warning: `package.authors` are no longer used to skip Copyright and License Notices
warning: instead, add `--mine github.com/{your username}` to the arguments
    Checking the license of `whiteread 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)`
error: could not bundle the code

- `whiteread 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)` as `crate::__cargo_equip::crates::whiteread`

note: attempted to bundle with the following crate(s), which are available on AtCoder. to exclude them from bundling, run with `--exclude-atcoder-crates`

- `whiteread 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)`


Caused by:
  could not execute process `/usr/bin/curl 'https://crates.io/api/v1/crates/whiteread/owners' -L` (never executed)

Caused by:
  No such file or directory (os error 2)

But running the curl succeeds:

❮ /usr/bin/curl 'https://crates.io/api/v1/crates/whiteread/owners' -L
{"users":[{"avatar":"https://avatars.githubusercontent.com/u/3074996?v=4","id":1959,"kind":"user","login":"krdln","name":"Michał Krasnoborski","url":"https://github.com/krdln"}]}⏎

What am I getting wrong? Is it an issue of permission?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.