Mitigate & document problems with mixed generated sources
- deterministically prefer rust_library's crate spec over rust_test's. This means root_module gets remapped to a workspace path more often, and fixes flakiness of generated_srcs_test.
- document the reasons and tradeoffs for this remapping.
- stop adding
include_dirswhen remapping, it doesn't do anything to help with this problem, and is confusing. - fix test to strictly assert the path, which I broke in 74f164b9dda7d910816a000542fd8749ee12307c
Partially fixes https://github.com/bazelbuild/rules_rust/issues/3126
Sorry about the delay here.
There is already a test for this in test/rust_analyzer/generated_srcs_test, it's "flaky" in that it always passed on the CI and always failed in my local workspace :-(
I think it's based on whether bazel returns the test or the lib first from aquery, which I don't know how to control.
(it looks like there are unrelated failures on buildkite, so I might need help getting this merged)
Any hope of getting this in @sam-mccall @illicitonion? Getting sick of editing the rust-project.json by hand every time gen_rust_project is run :sweat_smile: