Skip to content

Cargo thinks project is fresh after moving files #289

@hannobraun

Description

@hannobraun

If I move files around the src directory, Cargo will think the directory is still fresh and won't compile on the next cargo build.

I see this as a problem for two reasons:

  • Ergonomics: I'd like to immediately build to see what files need to be changed after the move.
  • Possibility for errors: If I'm not paying attention, I might think everything's okay, when in fact my program doesn't compile.

Here are the exact steps to reproduce. First, create a project:

$ cargo -V
cargo-nightly 0.1.0-pre (f720684 2014-07-26 04:21:30 +0000)
$ cargo new cargo-bug
$ cd cargo-bug/

Add a new module and build the project:

$ touch src/a.rs
$ echo "mod a;" > src/lib.rs
$ cargo build
   Compiling cargo-bug v0.0.1 (file:/home/hanno/Desktop/Stuff/tmp/cargo-bug)

Move the file and attempt to rebuild:

$ mv src/a.rs src/b.rs
$ cargo build
       Fresh cargo-bug v0.0.1 (file:/home/hanno/Desktop/Stuff/tmp/cargo-bug)

I get a green build, when in fact I expect to see this:

$ cargo build
   Compiling cargo-bug v0.0.1 (file:/home/hanno/Desktop/Stuff/tmp/cargo-bug)
/home/hanno/Desktop/Stuff/tmp/cargo-bug/src/lib.rs:1:5: 1:6 error: file not found for module `a`
/home/hanno/Desktop/Stuff/tmp/cargo-bug/src/lib.rs:1 mod a;
                                                         ^
Could not compile `cargo-bug`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions