Description
If you're in a subdirectory of Cargo repository (e.g. src
) and run cargo build
, rustc
is run from the directory with Cargo.toml
, meaning all printed paths are relevative to that directory, not the one where cargo build
was run.
Emac's M-x compile mode will "hyperlink" paths in error messages to allow jumping straight to the error (I'm sure other editors provide this functionality too), but it is taken relative to the folder of the buffer on which M-x compile
was run (i.e. if you are editing .../src/lib.rs
and run M-x compile cargo build
then emacs assumes the diagnostics are relative to .../src
). Hence, the automatic running of rustc
in a different directory makes it harder to use that mode.
This would theoretically be fixed by running the rustc
subprocess from the directory in which cargo
is invoked.