Open
Description
When testing little ideas I very commonly work with a crate foo
in different temp directories. If I haven't recently cleaned my shared target-dir then cargo-miri
gets confused about whether it needs to rebuild artifacts and uses the wrong binary to test with.
As an example these two commands create two separate crates that should print different things, but cargo miri run
in the second crate doesn't do a rebuild and instead runs the binary from the first crate:
> cd $(mktemp -d) && cargo new foo && cd foo && pwd && echo 'fn main() { println!("foo 1"); }' > src/main.rs && cargo miri run
Created binary (application) `foo` package
/tmp/tmp.mI8gDBgdqJ/foo
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
Compiling foo v0.1.0 (/tmp/tmp.mI8gDBgdqJ/foo)
Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Running `/home/nemo157/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/nemo157/.cargo/shared-target/miri/x86_64-unknown-linux-gnu/debug/foo`
foo 1
> cd $(mktemp -d) && cargo new foo && cd foo && pwd && echo 'fn main() { println!("foo 2"); }' > src/main.rs && cargo miri run
Created binary (application) `foo` package
/tmp/tmp.IHFWjzhAmy/foo
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `/home/nemo157/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/nemo157/.cargo/shared-target/miri/x86_64-unknown-linux-gnu/debug/foo`
foo 1