qryxip / cargo-equip

A Cargo subcommand to bundle your code into one `.rs` file for competitive programming
Apache License 2.0
76 stars 10 forks source link

Failed to expand nested mods #186

Open vvforekk opened 2 years ago

vvforekk commented 2 years ago

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. https://github.com/qryxip/cargo-equip/blob/9b697c17437f959b72cf1e473dfc0278b7615e85/src/rust.rs#L377 https://github.com/qryxip/cargo-equip/blob/9b697c17437f959b72cf1e473dfc0278b7615e85/src/rust.rs#L381

jakobrs commented 1 year ago

This prevents using cargo-equip with e.g. ndarray, because src/extension.rs includes pub(crate) mod nonnull;, and cargo-equip looks for the nonnull module in src/nonnull.rs instead of src/extension/nonnull.rs. (I tried to fix the bug but it just breaks somewhere else)