Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when processing diff file with only file renames. #24

Open
psandana opened this issue Apr 18, 2024 · 0 comments
Open

Panic when processing diff file with only file renames. #24

psandana opened this issue Apr 18, 2024 · 0 comments

Comments

@psandana
Copy link

Description
Generating a diff file with git:

git diff origin/main.. | Tee-Object diff.out

Generates the following output:

diff --git a/crate/examples/example1.rs b/crate/examples/example_renamed1.rs
similarity index 100%
rename from crate/examples/example1.rs
rename to /crate/examples/example_renamed1.rs

The code is panicking on:

stack backtrace:
   0:     0x7ff699b03aa2 - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff699b279cd - core::fmt::rt::Argument::fmt
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\fmt\rt.rs:142
   2:     0x7ff699b279cd - core::fmt::write
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\fmt\mod.rs:1120
   3:     0x7ff699aff6a1 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\io\mod.rs:1810
   4:     0x7ff699b038ca - std::sys_common::backtrace::_print
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff699b038ca - std::sys_common::backtrace::print
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff699b06029 - std::panicking::default_hook::closure$1
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:272
   7:     0x7ff699b05ce5 - std::panicking::default_hook
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:292
   8:     0x7ff699b06554 - std::panicking::rust_panic_with_hook
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:779
   9:     0x7ff699b06429 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:657
  10:     0x7ff699b043a9 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\sys_common\backtrace.rs:171
  11:     0x7ff699b060f2 - std::panicking::begin_panic_handler
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
  12:     0x7ff699b32547 - core::panicking::panic_fmt
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
  13:     0x7ff6995678da - patch::parser::parse_multiple_patches
                               at C:\Users\user\.cargo\registry\src\index.crates.io-6f17d22bba15001f\patch-0.7.0\src\parser.rs:84
  14:     0x7ff6995672fb - patch::ast::Patch::from_multiple
                               at C:\Users\user\.cargo\registry\src\index.crates.io-6f17d22bba15001f\patch-0.7.0\src\ast.rs:134
  15:     0x7ff6991a0641 - cargo_mutants::in_diff::diff_filter
                               at C:\open-src\cargo-mutants\src\in_diff.rs:23
  16:     0x7ff699136a25 - cargo_mutants::main

I was using cargo mutants, but this is reproducible by using patch too. patch::parser::patch is not processing errors from the interior, which are valid: Not finding the --- tags because diff is only renames.

Ask
Add error checks to gracefully handle cases when there is no changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant