Commit graph

20575 commits

Author SHA1 Message Date
Shoyu Vanilla
aa62c9d664 fix: Panic while rendering function with impl trait arg 2024-08-08 22:03:31 +09:00
Lukas Wirth
6bb29b1b54 Split up flycheck module 2024-08-08 13:08:50 +02:00
Lukas Wirth
085e4126e6 Move flycheck crate into rust-analyzer main crate 2024-08-08 13:06:39 +02:00
Vincent Esche
b8cf3c48f3 Add missing [package.description] for 'syntax-bridge' crate 2024-08-07 19:58:13 +02:00
Vincent Esche
a966f6ec31 Make 'syntax-bridge' crate inherit [package.repository] from workspace 2024-08-07 19:57:59 +02:00
bors
935883fd82 Auto merge of #17825 - Veykril:server-things, r=Veykril
internal: Offload diagnostics serialization to the task pool
2024-08-07 15:01:52 +00:00
Lukas Wirth
a147018e8e Offload diagnostics serialization to the task pool 2024-08-07 16:43:51 +02:00
Lukas Wirth
bb60c21885 Slightly quieter fatal panics 2024-08-07 16:35:58 +02:00
Shoyu Vanilla
ec0f00fc03 Fix native diagnostics not working 2024-08-07 23:33:39 +09:00
bors
0e282fcd04 Auto merge of #17823 - Veykril:mod-unconfigured-diag, r=Veykril
fix: Fix unconfigured diagnostic being attached to the wrong file for modules

Fixes https://github.com/rust-lang/rust-analyzer/issues/17817
2024-08-07 13:08:35 +00:00
Lukas Wirth
e3e31ce199 Fix unconfigured diagnostic being attached to the wrong file for modules 2024-08-07 15:07:09 +02:00
bors
4523657760 Auto merge of #17821 - Veykril:project-model-cleanup, r=Veykril
internal: Remove unnecessary CfgFlag definition in project-model
2024-08-07 12:46:26 +00:00
Lukas Wirth
ffd28e6ee9 Fix cargo config get env parsing 2024-08-07 14:36:22 +02:00
Lukas Wirth
d2fe906a62 Remove unnecessary CfgFlag definition in project-model 2024-08-07 14:27:59 +02:00
bors
0c20faf1f3 Auto merge of #17809 - nicolas-guichard:index-vendored, r=Veykril
Include vendored crates in StaticIndex

`StaticIndex::compute` filters out modules from libraries. This makes an exceptions for vendored libraries, ie libraries actually defined inside the workspace being indexed.

This aims to solve https://bugzilla.mozilla.org/show_bug.cgi?id=1846041 In general StaticIndex is meant for code browsers, which likely want to index all visible source files.
2024-08-07 11:05:49 +00:00
bors
ee10731c31 Auto merge of #17813 - roife:fix-issue-17803, r=Veykril
fix: tyck for non-ADT types when searching refs for `Self` kw

See e0276dc5dd (r1389848845)

For ADTs, to handle `{error}` in generic args, we should to convert them to ADT for comparisons; for others, we can directly compare the types.
2024-08-07 06:34:46 +00:00
Ali Bektas
2426649661 Allow rust-project.json to be hidden 2024-08-07 03:27:03 +02:00
roife
dc104b05cd fix: tyck for non-ADT types when searching refs for Self kw 2024-08-06 21:52:43 +08:00
Nicolas Guichard
6dcc4e34c2 Include vendored crates in StaticIndex
StaticIndex::compute filters out modules from libraries. This makes an
exceptions for vendored libraries, ie libraries actually defined inside
the workspace being indexed.

This aims to solve https://bugzilla.mozilla.org/show_bug.cgi?id=1846041
In general StaticIndex is meant for code browsers, which likely want to
index all visible source files.
2024-08-06 14:27:22 +02:00
bors
b23142209e Auto merge of #17745 - regexident:improve-crate-manifests, r=Veykril
Improve crate manifests, adding missing `[package.repository]` and `[package.description]` fields

As [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Could.20we.20add.20repository.20url.20to.20.60ra_ap_.60.20crates.20on.20crates.2Eio.3F/near/455095161).

cc `@Veykril` `@lnicola`
2024-08-06 06:28:54 +00:00
bors
5fe545c87f Auto merge of #17805 - ShoyuVanilla:issue-17578, r=Veykril
fix: Panic in path transform with default type parameters

Fixes #17578
2024-08-06 06:14:36 +00:00
Vincent Esche
7dec7e92ea Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
Vincent Esche
624f2ead7b Unify package descriptions by adding references to "rust-analyzer"
With the lack of a README on the individually published library crates and the somewhat cryptic `ra_ap_` prefix it is hard to figure out where those crates belong to, so mentioning "rust-analyzer" feels like auseful hint there.
2024-08-06 00:25:02 +02:00
Vincent Esche
f8de86b308 Apply Veykril's change suggestions 2024-08-06 00:25:02 +02:00
Vincent Esche
e9ee0d4166 Replace "ra_ap_ide" with "ide (aka ra_ap_ide)" 2024-08-06 00:25:02 +02:00
Vincent Esche
0a45f6dc24 Fix spelling of "data structure" 2024-08-06 00:25:02 +02:00
Vincent Esche
ddb9686246 Fix spelling of "object-oriented" 2024-08-06 00:25:02 +02:00
Vincent Esche
07058a71d4 Fix obsolete repository URL in [package.repository] of rust-analyzer crate 2024-08-06 00:25:02 +02:00
Vincent Esche
6f329e6d5b Add repository URL for published crates' missing [package.repository] fields 2024-08-06 00:25:02 +02:00
Vincent Esche
b5b0f4bc5a Replace "TBD" with more helpful desciptions in published crates' [package.description] fields 2024-08-06 00:25:02 +02:00
Shoyu Vanilla
0241116462 fix: Panic in path transform with default type parameters 2024-08-06 04:24:40 +09:00
bors
4a99d795d0 Auto merge of #17802 - Veykril:arg-mismatch-no-ty-mismatch, r=Veykril
fix: Surpress type mismatches in calls with mismatched arg counts

These tend to get very noisy, hiding the actual problem.
2024-08-05 14:35:50 +00:00
Lukas Wirth
deddbbfa60 Surpress type mismatches in calls with mismatched arg counts 2024-08-05 16:15:28 +02:00
bors
ce73b7cba2 Auto merge of #17771 - Veykril:parallel-vfs-config, r=Veykril
internal: Load VFS config changes in parallel

Simple attempt to make some progress f or https://github.com/rust-lang/rust-analyzer/issues/17373
No clue if those atomic orderings are right, though I don't think they are really too relevant either.

A more complete fix would probably need to replace our `ProjectFolders` handling a bit.
2024-08-05 14:07:22 +00:00
Lukas Wirth
e437db2483 Slightly optimize watch list in vfs 2024-08-05 15:56:23 +02:00
bors
25d9e05c03 Auto merge of #17791 - ShoyuVanilla:await-outside-of-async, r=Veykril
feat: Implement diagnostic for `await` outside of `async`

Closes #17781
2024-08-05 13:53:21 +00:00
bors
f62d7b9f11 Auto merge of #17775 - ShoyuVanilla:segregate-diags, r=Veykril
perf: Segregate syntax and semantic diagnostics

Closes #17731
2024-08-05 13:39:30 +00:00
Shoyu Vanilla
eea1e9b21f perf: Segregate syntax and semantic diagnostics 2024-08-05 22:12:47 +09:00
Shoyu Vanilla
8a51419a2d feat: Implement diagnostic for await outside of async 2024-08-05 21:47:57 +09:00
bors
fbed308ebe Auto merge of #17799 - Veykril:syntax-bridge, r=Veykril
Split out syntax-bridge into a separate crate

This functionality is not really tied to mbe macros, so imo it has no place in that crate.
2024-08-05 12:31:45 +00:00
bors
f6197355eb Auto merge of #17784 - Young-Flash:block_with_label, r=Veykril
feat: support inlay hint for more expr with label

follow up https://github.com/rust-lang/rust-analyzer/pull/17635
2024-08-05 12:03:18 +00:00
Lukas Wirth
c9e1cb4887
Simplify 2024-08-05 13:58:01 +02:00
Lukas Wirth
188c577855 Newtype ErasedFileAstId 2024-08-05 13:46:47 +02:00
Lukas Wirth
d2dd4f6d5f Split out syntax-bridge into a separate crate 2024-08-05 13:45:00 +02:00
Lukas Wirth
fcb88832de Simplify FileDelegate 2024-08-05 13:03:03 +02:00
bors
000eed1da8 Auto merge of #17795 - Veykril:library-dep-loading, r=Veykril
feat: Load sysroot library via cargo metadata

See https://github.com/rust-lang/rust/pull/128534, fixes https://github.com/rust-lang/rust-analyzer/issues/7637

Requires a toolchain from 176e54520 2024-08-04 or later to work.
2024-08-05 10:45:47 +00:00
Lukas Wirth
f053b1aa6a feat: Load sysroot library via cargo metadata 2024-08-05 12:18:19 +02:00
Shoyu Vanilla
8fa454d7aa fix: Insert a generic arg for impl Trait when lowering generic args 2024-08-05 00:06:29 +09:00
Young-Flash
747615d95b test: add test case for inlay hint support for expr with label 2024-08-04 19:19:15 +08:00
Lukas Wirth
c6ae9cde99 Wait with change processing until the vfs is done 2024-08-02 17:09:25 +02:00
Lukas Wirth
8286847bee internal: Load VFS config changes in parallel 2024-08-02 13:04:15 +02:00
Lukas Wirth
758ad25229 internal: Remove AbsPathBuf::TryFrom impl that checks too many things at once 2024-08-02 11:08:19 +02:00
Ali Bektas
ed865a60bf Make toggle_macro_delimiters work only for macro_calls 2024-08-02 02:00:26 +02:00
Young-Flash
722020e63f feat: support inlay hint for more expr with label 2024-08-01 22:06:15 +08:00
Shoyu Vanilla
3121a91e0a fix: Insert a tail Ok(()) for expr block instead of wrapping with Ok 2024-08-01 21:24:28 +09:00
Ali Bektas
0a4ea1ed8f Add new assist toggle_macro_delimiter 2024-08-01 02:38:33 +02:00
Wilfred Hughes
e7d61e8f9c docs: Fix JSON example for rust-analyzer.workspace.discoverConfig
The user does not specify `{arg}` in their JSON, and be pedantic about
commas in JSON sample.
2024-07-31 16:10:42 -07:00
Shoyu Vanilla
b5494d7cc3 Prevent redundant obigation push for assignee exprs 2024-08-01 02:51:33 +09:00
Shoyu Vanilla
20e2623234 fix: Apply IndexMut obligations for non-assigning mutable index usages, too 2024-08-01 02:20:52 +09:00
bors
f982f3fa2c Auto merge of #17750 - davidbarsky:david/remove-abspath-requirement-in-linked-projects, r=Veykril
fix: remove AbsPath requirement from linkedProjects

Should (fingers crossed!) fix https://github.com/rust-lang/rust-analyzer/issues/17664. I opened the `rustc` workspace with the [suggested configuration](e552c168c7/src/etc/rust_analyzer_settings.json) and I was able to successfully open some rustc crates (`rustc_incremental`) and have IDE functionality.

`@Veykril:` can you try these changes and let me know if it fixed rustc?
2024-07-31 14:31:16 +00:00
David Barsky
8ac0ffecc1 fix: remove AbsPath requirement from linkedProjects 2024-07-31 10:07:48 -04:00
Shoyu Vanilla
a871730142
Add a test case 2024-07-31 10:47:13 +09:00
Shoyu Vanilla
92a6e51b20 fix: Errors on method call inferences with elided lifetimes 2024-07-31 02:36:44 +09:00
bors
4feec4b0c1 Auto merge of #17744 - alibektas:debug_env_not_set, r=Veykril
minor: Set tracing level to debug when `cargo config get env` fails

fixes #17739
2024-07-30 11:02:21 +00:00
Ali Bektas
02c066cd1c Set tracing level to debug when cargo config get env fails 2024-07-30 12:57:21 +02:00
bors
412c915139 Auto merge of #17735 - alibektas:ratoml_workspaces, r=Veykril
feat: Introduce workspace `rust-analyzer.toml`s

In order to globally configure a project it was, prior to this PR, possible to have a `ratoml` at the root path of a project. This is not the case anymore. Instead we now let ratoml files that are placed at the root of any workspace have a new scope called `workspace`. Although there is not a difference between a `workspace` scope and and a `global` scope, future PRs will change that.
2024-07-30 06:49:14 +00:00
bors
14f7a91677 Auto merge of #17742 - Veykril:wrong-retries, r=Veykril
fix: Fix incorrect retrying of inlay hint requests
2024-07-30 06:35:28 +00:00
Lukas Wirth
5c40ad4407 fix: Fix incorrect retrying of inlay hint requests 2024-07-30 08:23:17 +02:00
bors
5b934bd25c Auto merge of #17741 - Veykril:include-raw, r=Veykril
fix: Fix builtin includes rejecting raw string literals

Fixes https://github.com/rust-lang/rust-analyzer/issues/17701
2024-07-30 06:21:07 +00:00
Lukas Wirth
ad71abb9ad fix: Fix builtin includes rejecting raw string literals 2024-07-30 08:19:32 +02:00
Ali Bektas
e5e6221873 Remove clippy errors 2024-07-29 17:00:31 +02:00
bors
a021b85be5 Auto merge of #17707 - Veykril:proc-macro-err-cleanup, r=Veykril
feat: Use spans for builtin and declarative macro expansion errors

This should generally improve some error reporting for macro expansion errors. Especially for `compile_error!` within proc-macros
2024-07-29 14:07:33 +00:00
Lukas Wirth
fab30c45cb Add missing doc string 2024-07-29 16:05:21 +02:00
Lukas Wirth
d46060b168 Fix error spans for include! and compile_error! 2024-07-29 15:57:01 +02:00
bors
510a8ffff3 Auto merge of #17736 - hyf0:hyf_09234908234, r=Veykril
feat(ide-completion): explictly show `async` keyword on `impl trait` methods

OLD:

<img width="676" alt="image" src="https://github.com/user-attachments/assets/f6fa626f-6b6d-4c22-af27-b0755e7a6bf8">

Now:

<img width="684" alt="image" src="https://github.com/user-attachments/assets/efbaac0e-c805-4dd2-859d-3e44b2886dbb">

---

This is an preparation for https://github.com/rust-lang/rust-analyzer/issues/17719.

```rust
use std::future::Future;

trait DesugaredAsyncTrait {
    fn foo(&self) -> impl Future<Output = usize> + Send;
    fn bar(&self) -> impl Future<Output = usize> + Send;
}

struct Foo;

impl DesugaredAsyncTrait for Foo {
    fn foo(&self) -> impl Future<Output = usize> + Send {
        async { 1 }
    }

    //
    async fn bar(&self) -> usize {
        1
    }
}

fn main() {
    let fut = Foo.bar();
    fn _assert_send<T: Send>(_: T) {}
    _assert_send(fut);
}
```

If we don't distinguish `async` or not. It would be confusing to generate sugared version `async fn foo ....` and original form `fn foo`  for `async fn in trait` that is defined in desugar form.
2024-07-29 12:55:53 +00:00
Lukas Wirth
ae9c553902 Make basic use of spans for macro expansion errors 2024-07-29 14:52:40 +02:00
Yunfei
8a1b9cab67 Add test in ide-completion/src/tests/item_list.rs 2024-07-29 20:40:51 +08:00
Yunfei
59dc1c9b2c Revert "Fix error message"
This reverts commit 752c49b679.
2024-07-29 20:36:03 +08:00
bors
0cbcbb0357 Auto merge of #17715 - Throne3d:fix/glob-may-override-vis-2, r=Veykril
fix: let glob imports override other globs' visibility

Follow up to #14930

Fixes #11858
Fixes #14902
Fixes #17704

I haven't reworked the code here at all - I don't feel confident in the codebase to do so - just rebased it onto the current main branch and fixed conflicts.

I'm not _entirely_ sure I understand the structure of the `check` function in `crates/hir-def/src/nameres` tests. I think the change to the test expectation from #14930 is correct, marking the `crate::reexport::inner` imports with `i`, and I understand it to mean there's a specific token in the import that we can match it to (in this case, `Trait`, `function` and `makro` of `pub use crate::defs::{Trait, function, makro};` respectively), but I had some trouble understanding the meaning of the different parts of `PerNs` to be sure.
Does this make sense?

I tested building and using RA locally with `cargo xtask install` and after this change the documentation for `arrow_array::ArrowPrimitiveType` seems to be picked up correctly!
2024-07-29 12:06:31 +00:00
Yunfei
f3a1b902fd Cargo fmt 2024-07-29 16:51:49 +08:00
Yunfei
752c49b679 Fix error message 2024-07-29 16:35:19 +08:00
Yunfei
94244a7a11 feat(ide-completion): explictly show async keyword on impl trait 2024-07-29 15:55:21 +08:00
Ali Bektas
5ece296adf Remove unnec copying of source_root_ids 2024-07-29 03:46:02 +02:00
Ali Bektas
f0d595dc77 add skip_slow_tests to ratoml tests 2024-07-29 03:43:27 +02:00
Ali Bektas
e0b6d2f681 Combine krate_ratoml and workspace_ratomls into one 2024-07-29 03:39:47 +02:00
Laurențiu Nicola
900db35537 Merge from rust-lang/rust 2024-07-28 17:19:33 +03:00
bors
cdb97b8b30 Auto merge of #17720 - ThouCheese:fix/doc-to-comment-naming, r=Veykril
flip the naming of the doc comment to comment assist

I did this the wrong way around when I implemented these assists, so here is a quick fix for it
2024-07-28 08:46:34 +00:00
duncan
20d3237dfa 17470 - run test explorer tests at the package level and add missing extra_test_bin_args settings 2024-07-28 07:43:07 +01:00
Luuk Wester
64ee4d3b1e flip the naming of the doc comment to comment assist 2024-07-28 00:48:08 +02:00
Ali Bektas
d7bedc85b3 Down to 1 failing test
And that is due to a case where we have two ratomls in a source root, one of which
is a `workspace_ratoml` and the other one is simple old ratoml. Since we are not checking to see if
the source root is already populated with workspace ratoml, this test fails. Due to principles of clear
code I believe it is reasonable to not have two HashMaps that are almost for the exact same thing.
So next commit should remove `workspace_ratoml` and merge it with `krate_ratoml`s.
2024-07-27 23:52:40 +02:00
Francis McKenzie
e77752eaf0 Fix for #17497 - Invalid RA diagnostic error: expected 2 arguments, found 1
The issue occurs because in some configurations of traits where one of them has Deref as a supertrait, RA's type inference algorithm fails to resolve the Deref::Target type, and instead uses a TyKind::BoundVar (i.e. an unknown type). This "autoderefed" type then incorrectly acts as if it implements all traits in scope.

The fix is to re-apply the same sanity-check that is done in iterate_method_candidates_with_autoref(), that is: don't try to resolve methods on unknown types. This same sanity-check is now done on each autoderefed type for which trait methods are about to be checked. If the autoderefed type is unknown, then the iterating of the trait methods for that type is skipped.

Includes a unit test that only passes after applying the fixes in this commit.

Includes a change to the assertion count in test syntax_highlighting::tests::benchmark_syntax_highlighting_parser as suggested by Lukas Wirth during review.

Includes a change to the sanity-check code as suggested by Florian Diebold during review.
2024-07-28 00:32:37 +08:00
Ryo Yoshida
fdb367ab89 fix: let glob imports override other globs' visibility 2024-07-27 00:10:53 -03:00
Ali Bektas
480db310b6 early exit if unresolved field is an index 2024-07-26 22:44:47 +02:00
Lukas Wirth
7beac14cba Internal: Cleanup proc-macro error handling 2024-07-26 14:38:19 +02:00
Lukas Wirth
df15b6f668 fix: Fix includes not working with expr fragment inputs 2024-07-26 10:12:06 +02:00
Ali Bektas
1aece03d16 Globals too are asking for sourcerootid 2024-07-26 03:04:29 +02:00
Ali Bektas
c4c6b64976 Turn root_ratoml into workspace_ratomls 2024-07-26 02:38:02 +02:00
Lukas Wirth
d32e60467f Remove unused trace module 2024-07-25 14:08:48 +02:00
bors
0ba6f4eda0 Auto merge of #17676 - winstxnhdw:precise-capturing, r=Veykril
feat: add preliminary support for `+ use<..>` `precise_capturing` syntax

## Summary

This PR adds basic support for the following syntax.

```rs
fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
//                                  ~~~~~~~~~~~~~~~~~~~~~~~
//                          This opaque type does not capture `'a`.

fn outlives<'o, T: 'o>(_: T) {}

fn caller<'o, 'a, 'b: 'o, T: 'o>() {
    //        ~~
    //        ^ Note that we don't need `'a: 'o`.
    outlives::<'o>(captures::<'a, 'b, T>());
}
```

Related to #17598
2024-07-25 11:10:56 +00:00
Winston H.
9f74787d5d fix: handle new TypeBoundKind variant 2024-07-25 10:58:25 +00:00
bors
fa5ff86e04 Auto merge of #17697 - Veykril:cargo-env, r=Veykril
fix: Support new cargo config get env format

Fixes https://github.com/rust-lang/rust-analyzer/issues/17686
2024-07-25 10:30:03 +00:00
Lukas Wirth
c7d6fe5257 fix: Support new cargo config get env format 2024-07-25 12:28:31 +02:00
Lukas Wirth
0e93e6fee7 Make legacy_const_generics_indices thin by double boxing as its seldom used 2024-07-25 11:51:15 +02:00
Lukas Wirth
7f884487d7 Reduce size of TypeRef by 8 bytes 2024-07-25 11:14:55 +02:00
Lukas Wirth
f2fa456a8c Fix incorrect handling of cfg'd varargs 2024-07-25 11:02:19 +02:00
Lukas Wirth
9cbafa2d49 Remove Params and Fields from AstIdMap 2024-07-25 10:22:05 +02:00
Lukas Wirth
200a01adc4 Generate From impls for Any* nodes 2024-07-25 10:21:58 +02:00
winstxnhdw
d42e85758c fix: temporarily use ast::GenericParamList 2024-07-25 07:40:08 +01:00
Laurențiu Nicola
b392eb4eb5 Fix and enable unsafe_op_in_unsafe_fn 2024-07-25 08:41:30 +03:00
bors
eeb192b79a Auto merge of #17674 - davidbarsky:david/add-more-information-to-status-command, r=Veykril
internal: add more output to the status command

Bit of a lazy change, but this is was pretty handy. I think I should clean up the configuration into something a bit more legible (maybe serialize as JSON?), but I think this is a good enough starting point that we might as well start asking people for it in issue reports.
2024-07-24 10:10:58 +00:00
bors
c155ad0695 Auto merge of #17610 - regexident:impl-all_in_module, r=Veykril
Add method `Impl::all_in_module(…)` for allowing more localized querying

This PR is motivated by an [outside use](https://github.com/regexident/cargo-modules) of the `ra_ap_hir` crate that would benefit from being able to more efficiently query for all impls of a given module (instead of having to query for its parent crate's impls and then filtering on `impl_hir.module(db) == module_hir`).

I have the suspicion that the code as is won't quite work for file-level modules, since those don't have a block, afaict, but with all the crate-rename and version shenanigans around the `ra_ap_` release process I haven't yet been able to figure out how to patch a `ra_ap_` dependency from a third-party crate (let alone how to test this from inside of `rust-analyzer`), so haven't been able to actually run and test this. 😔

Any hints on how to make this (i.e. the code itself, as well as the testing) work are more than welcome!
2024-07-24 09:56:56 +00:00
bors
fbfda1b566 Auto merge of #17661 - alibektas:read_ratoml_on_startup, r=Veykril
minor: Read workspace root ratomls on startup
2024-07-24 09:42:49 +00:00
Winston H.
5af51fa476
fix: use cannot have optional generics
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2024-07-24 10:42:20 +01:00
winstxnhdw
4a91453409 fix: move use parsing to outer match arm 2024-07-23 22:36:46 +01:00
winstxnhdw
e4941c0c73 chore: update codegens 2024-07-23 22:36:46 +01:00
winstxnhdw
61b232369b feat: add arm for use type bound 2024-07-23 22:36:46 +01:00
winstxnhdw
fa3484f39f feat: add use type bound grammar 2024-07-23 22:36:46 +01:00
bors
eb5da56d83 Auto merge of #17395 - davidbarsky:david/remove-unindexed-project-notification, r=Veykril
chore: remove `UnindexinedProject` notification

This PR is split out from https://github.com/rust-lang/rust-analyzer/pull/17246/ (and contains its changes, which is a little annoying from a review perspective...). I'd like to land this change a week or so after #17246 lands in order to give any users of the unindexed project notification time to adopt migrate.
2024-07-23 17:38:41 +00:00
David Barsky
2783aa7312 internal: remove UnindexedProject notification
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2024-07-23 13:34:04 -04:00
bors
7507695a16 Auto merge of #17483 - alibektas:ratoml/fixes, r=alibektas
minor : fixes for ratoml module

This is a follow-up PR to #17058.

- Parse errors are reflected as such by defining a new variant called `ConfigError::ParseError`
- New error collection has been added to store config level agnostic errors.

EDIT : Some things that this PR promised to solve are removed and will be addressed by other PRs
2024-07-23 14:13:45 +00:00
Ali Bektas
784d46e814 rename config::ConfigChange::other_errors to validation_errors 2024-07-23 15:54:39 +02:00
Ali Bektas
af88940dca minor changes 2024-07-23 15:50:12 +02:00
Vincent Esche
acb50efb3a Add method Impl::all_in_module(…) for supporting more localized querying 2024-07-23 14:43:38 +02:00
PaulDotSH
49184a138c Remove lens.forceCustomCommands config 2024-07-23 03:27:28 -04:00
David Barsky
d0017cef9b internal: add more output to the status command 2024-07-22 15:23:49 -04:00
Lukas Wirth
7c374a10bd internal: Shrink size of Binding 2024-07-22 17:14:17 +02:00
bors
36f58f5fff Auto merge of #17670 - Veykril:mem, r=Veykril
LRU `body_with_source_map` query

This query is being invalidated all the time anyways (we have an extra query on top of it for the body incrementality that is not source dependent), so there is little reason to keep these around all the time when only some IDE features are interested in them.
2024-07-22 14:48:05 +00:00
Lukas Wirth
bd359b32b0 LRU body_with_source_map query 2024-07-22 16:34:59 +02:00
bors
9d86412498 Auto merge of #17668 - Veykril:incorrect-nevers, r=Veykril
Remove incorrect never! invocations

These can crop up when the `Future` related lang items are missing
2024-07-22 09:36:15 +00:00
bors
d092f7d78f Auto merge of #17542 - roife:fix-issue-17517, r=Veykril
feat: go-to-def and find-references on control-flow keywords

fix #17517.

This PR implements **go-to-definition** and **find-references** functionalities for control flow keywords, which is similar to the behaviors in the `highlight-related` module. Besides, this PR also fixes some incorrect behaviors in `highlight-related`.

## Changes

1. **Support for go-to-definition on control flow keywords**:
   This PR introduces functionality allowing users to navigate on the definition of control flow keywords (`return`, `break`, `continue`).
   Commit: 2a3244ee147f898dd828c06352645ae1713c260f..7391e7a608634709db002a4cb09229de4d12c056.

2. **Bug fixes and refactoring in highlight-related**:
   - **Handling return/break/continue within try_blocks**:
     This PR adjusted the behavior of these keywords when they occur within `try_blocks`. When encounter these keywords, the program should exit the outer function or loop which containing the `try_blocks`, rather than the `try_blocks` itself; while the `?` will cause the program to exit `try_blocks`.
     Commit: 59d697e807f0197f59814b37dca1563959da4aa1.
   - **Support highlighting keywords in macro expansion for highlight-related**:
     Commit: 88df24f01727c23a667a763ee3ee0cec22d5ad52.
   - Detailed description for the bug fixes
     + The previous implementation of `preorder_expr` incorrectly treated `try_blocks` as new contexts, thereby r-a will not continue to traverse inner `return` and `break/continue` statements. To resolve this, a new function `preorder_expr_with_ctx_checker` has been added, allowing users to specify which expressions to skip.
       * For example, when searching for the `?` in the context, r-a should skip `try_blocks` where the `?` insides just works for `try_blocks`. But when search for the `return` keyword, r-a should collect both the `return` keywords inside and outside the `try_blocks`
     + Thus, this PR added `WalkExpandedExprCtx` (builder pattern). It offers the following improvements: customizable context skipping, maintenance of loop depth (for `break`/`continue`), and handling macro expansion during traversal.

3. **Support for find-references on control flow keywords**:
   This PR enables users to find all references to control flow keywords.
   Commit: 9202a33f81218fb9c2edb5d42e6b4de85b0323a8.
2024-07-22 09:22:13 +00:00
bors
6f3030f316 Auto merge of #17586 - ShoyuVanilla:tuple-arg-macro-rest, r=Veykril
Allow macro expansions into `RestPat` in tuple args work as ellipsis like plain `RestPat`

Fixes #17292

Currently, Rust Analyzer lowers `ast::Pat::RestPat` into `Pat::Missing` in general cases on the following lines;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1359-L1367)

And in some proper positions such as `TupleStruct(..)`, it is specially handed on the following lines;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1429-L1437)

This behavior is reasonable because rustc does similar things in
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L108-L111)
and
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L123-L142)

But this sometimes works differently because Rust Analyzer expands macros while ast lowering;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1386-L1398)
ffbc5ad993/crates/hir-def/src/body/lower.rs (L941-L963)
but rustc uses expanded ast in the corresponding tuple-handling process, so it does not have macro patterns there.
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L114)

So, if a macro expansion in a tuple arg results in `..`, rustc permits it like plain `..` pattern, but Rust Analyzer rejects it.
This is the root cause of #17292 and this PR allows macros expanded into `..` in a tuple arg position work as ellipsis like that.
2024-07-22 09:08:12 +00:00
Lukas Wirth
5806950712 Remove incorrect never! invocations 2024-07-22 10:53:18 +02:00
bors
c29bac1cdf Auto merge of #17647 - joshka:jm/rename-commands, r=Veykril
Rename rust-analyzer commands

The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

Fixes: https://github.com/rust-lang/rust-analyzer/issues/17644

Note: This seems like it will be a breaking change for any RA client that previously reacted to `editor.action.triggerParameterHints` - naive search: https://github.com/search?q=editor.action.triggerParameterHints+AND+%28NOT+is%3Afork%29+rust-analyzer&type=code
2024-07-22 08:10:03 +00:00
bors
274c214b16 Auto merge of #17666 - Veykril:simplify, r=Veykril
Simplify
2024-07-22 07:56:04 +00:00
Lukas Wirth
e3f16223c8 Simplify 2024-07-22 09:54:31 +02:00
bors
232e55515f Auto merge of #17660 - ObsidianMinor:fix/17645, r=Veykril
Fix more path resolution for included submodules

Now with more comprehensive testing! This adds tests for includes within modules. Previous testing was not comprehensive enough since submodules that use `include!` didn't actually work either! The `ModDir` used for resolving mods relative to included files has to be `ModDir::root()`. The original test just so happened to put the submodules in the root which made this work, but if you put the `include!` inside a `mod` block it didn't work.

With this change, when collecting a macro expansion, if the macro call is an `include!`, we use the `ModDir::root()` instead of the current module we're in.
2024-07-22 07:00:54 +00:00
bors
6512e29a80 Auto merge of #17658 - alibektas:rename_get_field, r=Veykril
minor: Rename `config::get_field` to `config::get_field_json`
2024-07-22 06:24:53 +00:00
Ali Bektas
e0db833082 Read rust-analyzer.toml files on startup 2024-07-22 02:42:39 +02:00
Sydney Acksman
cdd7b18149 Fix more path resolution for included submodules
Now with much more comprehensive testing! This
adds tests for includes within modules.
2024-07-21 19:04:19 -05:00
Ali Bektas
db2ba64540 Add FIXME to root ratoml tests. 2024-07-22 01:42:50 +02:00
Ali Bektas
4f8735fd56 Apply changes to ratoml/fixes 2024-07-22 01:33:15 +02:00
Ali Bektas
97bad3582a Minor fixes for ratoml module
- Parse errors are reflected as such by defining a new variant called `ConfigError::ParseError`
- New error collection has been added to store config level agnostic errors.
2024-07-22 01:31:38 +02:00
Ali Bektas
d4214ec502 Rename config::get_field to config::get_field_json 2024-07-21 22:52:37 +02:00
bors
4afe0d5393 Auto merge of #17657 - Veykril:cfg-slim, r=lnicola
internal: Make `CfgExpr` slimmer
2024-07-21 15:50:31 +00:00
Lukas Wirth
1141c35a4b Make CfgExpr slimmer 2024-07-21 14:50:44 +02:00
bors
db1343e1d6 Auto merge of #17656 - Veykril:flyimport-builtin-mod, r=Veykril
fix: Allow flyimport to import primitive shadowing modules

Fixes https://github.com/rust-lang/rust-analyzer/issues/16371
2024-07-21 11:35:12 +00:00
Lukas Wirth
0851d21d1e fix: Allow flyimport to import primitive shadowing modules 2024-07-21 13:26:19 +02:00
bors
e88946ace8 Auto merge of #17655 - Veykril:std-find-path, r=Veykril
More `find_path` improvements
2024-07-21 11:21:25 +00:00
Lukas Wirth
733cb1e645 Optimize find_path for sysroot library search some more 2024-07-21 13:20:12 +02:00
Lukas Wirth
4b2a123280 Fix visited module tracking not clearing itself on backtracking 2024-07-21 12:17:50 +02:00
Lukas Wirth
2a32976e90 Use out parameter instead of return value for find_path choice 2024-07-21 11:32:48 +02:00
Lukas Wirth
9fd6d26e97 Fix using wrong length for max_len arg 2024-07-21 11:16:23 +02:00
Lukas Wirth
2564b69e1d Specialize find_path local search 2024-07-21 11:10:15 +02:00
Lukas Wirth
a6e4ac705c Optimize find_path choice selection 2024-07-21 10:53:33 +02:00
bors
88258b7fd2 Auto merge of #17653 - Veykril:std-find-path, r=Veykril
Prefer standard library paths over shorter extern deps re-exports

This should generally speed up path finding for std items as we no longer bother looking through all external dependencies. It also makes more sense to prefer importing std items from the std dependencies directly.

Fixes https://github.com/rust-lang/rust-analyzer/issues/17540
2024-07-21 07:24:38 +00:00
Lukas Wirth
40bbc684ad Prefer standard library paths over shorter extern deps re-exports 2024-07-21 09:14:17 +02:00
bors
5f26438b5d Auto merge of #17650 - ObsidianMinor:fix/17645, r=Veykril
Fix path resolution for child mods of those expanded by `include!`

Child modules wouldn't use the correct candidate paths due to a branch that doesn't seem to be doing what it's intended to do. Removing the branch fixes the problem and all existing test cases pass.

Having no knowledge of how any of this works, I believe this fixes #17645. Using another test that writes the included mod directly into `lib.rs` instead, I found the difference can be traced to the candidate files we use to look up mods. A separate branch for if the file comes from an `include!` macro doesn't take into account the original mod we're contained within:

```rust
None if file_id.macro_file().map_or(false, |it| it.is_include_macro(db.upcast())) => {
    candidate_files.push(format!("{}.rs", name.display(db.upcast())));
    candidate_files.push(format!("{}/mod.rs", name.display(db.upcast())));
}
```

I'm not sure why this branch exists. Tracing the branch back takes us to 3bb9efb but it doesn't say *why* the branch was added. The test case that was added in this commit passes with the branch removed, so I think it's just superfluous at this point.
2024-07-21 06:17:14 +00:00
Mark Rousskov
f410a2d02f Allow deprecated temporarily to unblock version bump 2024-07-20 15:51:58 -04:00
Sydney Acksman
b9469f52a3 Fix path resolution for child mods of those expanded by include!
Child modules wouldn't use the correct candidate paths due to a branch that doesn't seem to be doing what it's intended to do. Removing the branch fixes the problem and all existing test cases pass.
2024-07-20 14:32:28 -05:00
bors
8d489e21eb Auto merge of #17649 - ShoyuVanilla:issue-17585, r=Veykril
fix: Panic in debug profile for tuple deconstruct with arity mismatch

Fixes #17585, which doesn't affect daily use cases but quite annoying in development of r-a itself like writing tests.

This PR applies similar approach as in #17534, skipping match usefulness check for patterns containing errors
2024-07-20 18:04:01 +00:00
Shoyu Vanilla
6e728df43a fix: Panic in debug profile for tuple deconstruct with arity mismatch 2024-07-21 02:37:37 +09:00
Josh McKinney
5b1a5a250b
Rename rust-analyzer commands
The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

Fixes: https://github.com/rust-lang/rust-analyzer/issues/17644
2024-07-20 01:11:14 -07:00
Lukas Wirth
41603ab14e Add missing dyn parse special cases in 2015 edition 2024-07-20 09:18:40 +02:00
bors
062822ce91 Auto merge of #17641 - nyurik:optimize-refs, r=Veykril
Avoid ref when using format! in compiler

Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.

See https://github.com/rust-lang/rust-clippy/issues/10851
2024-07-20 06:40:27 +00:00
Lukas Wirth
3092e1c0b1
Keep references in format! when the target is unsized 2024-07-20 08:39:04 +02:00
Laurențiu Nicola
1075978bed Fix some typos 2024-07-20 08:30:22 +03:00
Young-Flash
18e7299997 minor: tweak comment 2024-07-20 09:33:23 +08:00
Young-Flash
a2d142b9f2 internal: add test case for inlay hint support for block expr with lifetime label 2024-07-20 09:33:23 +08:00
Young-Flash
0416dec50a feat: add inlay hint support for block expr with lifetime label 2024-07-20 09:33:23 +08:00
bors
b333f85a9d Auto merge of #17639 - Veykril:salsa-perf, r=Veykril
Some more small salsa memory improvements

This does limit our lru limits to 2^16 but if you want to set them higher than that you might as well not set them at all. Also makes `LRU` opt-in per query now, allowing us to drop all the unnecessary LRU stuff for most queries
2024-07-19 18:45:16 +00:00
Yuri Astrakhan
cc1aded86c Avoid ref when using format! in compiler
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-19 14:41:59 -04:00
Lukas Wirth
09ef75c717 Add back equality check that went missing 2024-07-19 20:39:09 +02:00
Lukas Wirth
92f5e806f1 Fix edition used for include macro parsing 2024-07-19 20:29:53 +02:00
Lukas Wirth
f4199f786e Parse contextual dyn keyword properly in edition 2015 2024-07-19 20:20:30 +02:00
roife
f027a46d94 internal: move NavigationTarget::from_expr to goto_definition 2024-07-20 01:58:51 +08:00
roife
1b59cf2d52 fix: sort references in tests 2024-07-20 01:55:55 +08:00
roife
55cd8ab904 fix: handle highlightings inside macro calls & only highlight kws in current file 2024-07-20 01:45:51 +08:00
roife
d94dcfa841 fix: ensure that highlight_related works for macro_expr 2024-07-20 01:42:52 +08:00
roife
ae6e8d56d4 use token_ancestors_with_macros to simplify goto-def on kw 2024-07-20 01:42:52 +08:00
roife
22c5924080 fix: navigate to label directly when perform 'goto-def' on control-flow kw
See https://github.com/rust-lang/rust-analyzer/pull/17542#discussion_r1667656190
2024-07-20 01:42:52 +08:00
roife
07570bac66 feat: find references on control-flow kws 2024-07-20 01:42:52 +08:00
roife
3650b40714 fix: keyword highlighting in macro expansion 2024-07-20 01:42:52 +08:00
roife
1bca00d1bc fix: incorrect highlighting of try blocks with control flow kws 2024-07-20 01:42:51 +08:00
roife
a93a7c2403 fix: ensure that goto-def works on fn/try/async kw 2024-07-20 01:41:01 +08:00
roife
37085d9dcd feat: goto-def on keywords 2024-07-20 01:41:00 +08:00
Lukas Wirth
a324e46b0b Drop an unnecessary Arc::clone 2024-07-19 18:53:52 +02:00
Lukas Wirth
89bcc79b5d Regenerate files 2024-07-19 18:39:42 +02:00
Lukas Wirth
6d4989b3c7 Make LRU opt-in 2024-07-19 18:38:08 +02:00
Lukas Wirth
7fcac48023 Remove duplicate information from interned::Slot 2024-07-19 17:52:49 +02:00
bors
9fd6c695da Auto merge of #17638 - Veykril:salsa-perf, r=Veykril
perf: Reduce memory usage of salsa slots by 8 bytes
2024-07-19 15:48:57 +00:00
Lukas Wirth
8e3133f118 Reduce maximum LRU size to 2^16 entries, reducing memory footprint of LRU entries 2024-07-19 17:48:12 +02:00
Lukas Wirth
4691ca97f1 perf: Reduce memory usage of salsa slots by 8 bytes 2024-07-19 17:34:48 +02:00
bors
aa4768f7be Auto merge of #17622 - roife:fix-issue-17602, r=Veykril
fix: handle synonymous imports with different renaming in 'merge imports'

fix #17602
2024-07-19 15:16:02 +00:00
bors
fa3dd33c27 Auto merge of #17620 - Veykril:edition-aware-parser, r=Veykril
Edition aware parser

Fixes https://github.com/rust-lang/rust-analyzer/issues/16324 by allowing us to properly thread through the edition to the parser
2024-07-19 14:56:56 +00:00
Lukas Wirth
546eb6b530 Test macros doing edition dependent parsing 2024-07-19 16:43:58 +02:00
Lukas Wirth
2c32ee7cfa Prevent generated runner module from being format checked 2024-07-19 16:01:47 +02:00
Lukas Wirth
d235d09bf9 Parse try as a keyword only in edition 2018 and up 2024-07-19 15:43:20 +02:00
Lukas Wirth
713c47f25b Add basic edition inline parser test support 2024-07-19 15:19:43 +02:00
bors
52143a5ac0 Auto merge of #17246 - davidbarsky:david/move-rust-project-generation-to-server, r=Veykril
feature: teach rust-analyzer to discover `linked_projects`

This PR's been a long-time coming, but like the title says, it introduces server-side project discovery and removes the extension hooks I previously introduced. I don't think this PR is ready to land, but here are the things I'm feeling squishy about:
- I don't think I like the idea of introducing the `cargo-metadata` command-but-for-everything-else in the `flycheck` module, but the progress reporting infrastructure was too convenient to pass up. Happy to move it elsewhere.

Here are the things I _know_ I need to change:
- For progress reporting, I'm extracting from a `serde_json::Value` that corresponds to `tracing_subsciber::fmt::Layer`'s JSON output. I'd like to make this a bit more structured/documented than the current nonsense I wrote.
- The progress reporting currently hardcodes "Buck"; it should be deriving that from the previously mentioned more-structured-output.
- This doesn't handle *reloading* when a corresponding buildfile is changed. It should be doing that.

<details>
<summary>Anyway, here's a video of rust-analyzer discovering a Buck target.</summary>

https://github.com/rust-lang/rust-analyzer/assets/2067774/be6cd9b9-2c9a-402d-847f-05f860a91df1
</details>
2024-07-18 16:15:31 +00:00
David Barsky
db43a5a6e9 feature: move linked_projects discovery to the rust-analyzer server 2024-07-18 12:01:27 -04:00