rust-analyzer/crates
bors[bot] 099a8f37f5
Merge #3309
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>
2020-02-29 15:36:03 +00:00
..
ra_arena Switch to variant-granularity field type inference 2019-11-25 00:12:36 +03:00
ra_assists Fix typo 2020-02-29 13:51:23 +01:00
ra_cargo_watch Remove unused dependencies 2020-02-27 14:04:13 +09:00
ra_cfg Update versions 2020-02-18 16:12:40 +02:00
ra_db ra_db: removed a couple of explicit lifetimes 2020-02-22 17:00:39 +02:00
ra_fmt When joining lines, unwrap trivial diverging blocks 2020-02-24 17:17:05 +01:00
ra_hir Reduce visibility 2020-02-28 17:28:29 +01:00
ra_hir_def Remove unused dependencies 2020-02-27 14:04:13 +09:00
ra_hir_expand Update versions 2020-02-18 16:12:40 +02:00
ra_hir_ty Fix a common false-positive type mismatch 2020-02-29 15:31:07 +01:00
ra_ide Cleanup editing API 2020-02-29 13:51:23 +01:00
ra_ide_db Fix highlighting of const patterns 2020-02-28 16:38:36 +01:00
ra_mbe Cleanup editing API 2020-02-29 13:51:23 +01:00
ra_parser Parse attr in rhs of let stmts 2020-02-28 13:08:47 +08:00
ra_prof Remove unused dependencies 2020-02-27 14:04:13 +09:00
ra_project_model keep one CargoTomlNotFoundError 2020-02-29 13:05:10 +00:00
ra_syntax Fix typo 2020-02-29 13:51:23 +01:00
ra_text_edit Remove unused dependencies 2020-02-27 14:04:13 +09:00
ra_tt Update versions 2020-02-18 16:12:40 +02:00
rust-analyzer Merge #3309 2020-02-29 15:36:03 +00:00
test_utils Use text_range::extend_to 2020-02-27 10:06:48 +08:00