mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
099a8f37f5
3309: Find cargo toml up the fs r=matklad a=not-much-io Currently rust-analyzer will look for Cargo.toml in the root of the project and if failing that then go down the filesystem until root. This unfortunately wouldn't work automatically with (what I imagine is) a fairly common project structure. As an example with multiple languages like: ``` js/ .. rust/ Cargo.toml ... ``` Added this small change so rust-analyzer would glance one level up if not found in root or down the filesystem. ## Why not go deeper? Could be problematic with large project vendored dependencies etc. ## Why not add a Cargo.toml manual setting option? Loosely related and a good idea, however the convenience of having this automated also is hard to pass up. ## Testing? Build a binary with various logs and checked it in a project with such a structure: ``` [ERROR ra_project_model] find_cargo_toml() [ERROR ra_project_model] find_cargo_toml_up_the_fs() [ERROR ra_project_model] entities: ReadDir("/workspaces/my-project") [ERROR ra_project_model] candidate: "/workspaces/my-project/rust/Cargo.toml", exists: true ``` ## Edge Cases? If you have multiple Cargo.toml files one level deeper AND not in the root, will get whatever comes first (order undefined), example: ``` crate1/ Cargo.toml crate2/ Cargo.toml ... (no root Cargo.toml) ``` However this is quite unusual and wouldn't have worked before either. This is only resolvable via manually choosing. Co-authored-by: nmio <kristo.koert@gmail.com> |
||
---|---|---|
.. | ||
ra_arena | ||
ra_assists | ||
ra_cargo_watch | ||
ra_cfg | ||
ra_db | ||
ra_fmt | ||
ra_hir | ||
ra_hir_def | ||
ra_hir_expand | ||
ra_hir_ty | ||
ra_ide | ||
ra_ide_db | ||
ra_mbe | ||
ra_parser | ||
ra_prof | ||
ra_project_model | ||
ra_syntax | ||
ra_text_edit | ||
ra_tt | ||
rust-analyzer | ||
test_utils |