Commit graph

30520 commits

Author SHA1 Message Date
bors
f998561964 Auto merge of #17411 - Wilfred:clearer_unlinked_file, r=Veykril
fix: Improve hover text in unlinked file diagnostics

Use full sentences, and mention how to disable the diagnostic if users are intentionally working on unowned files.

![Screenshot 2024-06-12 at 5 55 48 PM](https://github.com/rust-lang/rust-analyzer/assets/70800/c91ee1ed-1c72-495a-9ee3-9e360a5c6977)

(Full disclosure: I've tested a rust-analyzer build in VS Code, but the pop-up logic is currently disabled due to #17062, so I haven't tested that.)
2024-06-24 08:11:43 +00:00
bors
f2cffbac85 Auto merge of #17466 - chenyukang:patch-1, r=Veykril
chore: Fix diagnostic name in macro_error.rs
2024-06-24 07:57:45 +00:00
bors
3432ef4414 Auto merge of #17481 - roife:fix-issue-17480, r=Veykril
fix: pattern completions in let-stmt

fix #17480.

We can write `let S { a, b } = s;` or `let Some(x) = a else {}`, so it is reasonable to allow pattern completions in `LetStmt`.
2024-06-24 07:34:08 +00:00
bors
db69df3216 Auto merge of #17478 - kilpkonn:master, r=Veykril
Simplify some term search tactics

Working on the paper `@phijor` found that "Data constructor" tactic could be simplified quite a bit by running it only in the backwards direction. With n+1 rounds it has same coverage as previous implementation in n rounds, however the tactic it self is more simple and also potentially faster as there is less to do.

In a nutshell the idea is to only work with types in the wish-list rather than with any types.

Turns out it is quite a bit faster:

Before:
```
ripgrep:
Tail Expr syntactic hits: 238/1692 (14%)
Tail Exprs found: 1223/1692 (72%)
Term search avg time: 15ms

nalgebra:
Tail Expr syntactic hits: 125/3001 (4%)
Tail Exprs found: 2143/3001 (71%)
Term search avg time: 849ms
```

After
````
ripgrep:
Tail Expr syntactic hits: 246/1692 (14%)
Tail Exprs found: 1209/1692 (71%)
Term search avg time: 8ms

nalgebra:
Tail Expr syntactic hits: 125/3001 (4%)
Tail Exprs found: 2028/3001 (67%)
Term search avg time: 305ms
````

_Also removed niche optimization of removing scope defs from the search space as this wasn't helping much anyway and made code a bit more complex._
2024-06-24 07:20:50 +00:00
roife
291e96a562 fix: pattern completions in let-stmt 2024-06-23 22:27:54 +08:00
Tavo Annus
51c3bd215a Fix suggestions of unstable constants 2024-06-22 21:33:58 +03:00
Tavo Annus
3825d8bd0f Increase search depth to account for more granual steps 2024-06-22 15:06:07 +03:00
bors
2fd803cc13 Auto merge of #17475 - lnicola:changelog-title, r=lnicola
minor: Remove Changelog: XXX title from Github release notes

Fixes #16455
Closes #17165
2024-06-22 11:57:52 +00:00
Laurențiu Nicola
d598164927 Remove Changelog: XXX title from Github release notes 2024-06-22 14:55:23 +03:00
Tavo Annus
b4f3eb48db Simplify impl_method tactic 2024-06-22 14:22:56 +03:00
Tavo Annus
23d3ac70e9 Simplify impl_static_method tactic 2024-06-22 14:14:42 +03:00
Tavo Annus
a3315fe028 Remove remove not-very-helpful optimizations 2024-06-22 10:17:33 +03:00
Tavo Annus
957325a5fe Run data_constructor tactic only backwards 2024-06-21 22:01:06 +03:00
bors
c4681ea2cc Auto merge of #17469 - roife:fix-issue-17425, r=Veykril
fix: use ItemInNs::Macros to convert ModuleItem to ItemInNs

fix #17425.

When converting `PathResolution` to `ItemInNs`, we should convert `ModuleDef::Macro` to `ItemInNs::Macros` to ensure that it can be found in `DefMap`.
2024-06-21 17:52:42 +00:00
bors
fe0da852e2 Auto merge of #17474 - Veykril:ty-perf-stuff, r=Veykril
internal: Remove some allocations from hir-ty
2024-06-21 17:39:45 +00:00
Lukas Wirth
4c62e6b05f Prevent re-allocation in CallableSig::from_params_and_return 2024-06-21 19:26:08 +02:00
Lukas Wirth
34ba8db3ed Save allocations for empty generic_defaults query results 2024-06-21 19:21:27 +02:00
bors
8f55368941 Auto merge of #17473 - Veykril:generics, r=Veykril
internal: Tidy up generics handling in hir-ty a bit
2024-06-21 17:12:35 +00:00
Lukas Wirth
2761b1e236 Don't attempt to compute implict sized clauses for empty generics 2024-06-21 19:10:57 +02:00
Lukas Wirth
4d709cc866 Save allocations for empty generic_predicates query results 2024-06-21 19:10:45 +02:00
Lukas Wirth
7a16e06009 Lazy generics 2024-06-21 18:38:37 +02:00
Lukas Wirth
c01f4cf902 Simplify 2024-06-21 18:27:05 +02:00
Lukas Wirth
480bfd5a7d There can only be one self param 2024-06-21 17:55:16 +02:00
Lukas Wirth
cf2b757a1a Light docs and privacy 2024-06-21 17:54:40 +02:00
roife
d5bb2f0cba fix: use ItemInNs::Macros to convert ModuleItem to ItemInNs 2024-06-21 21:05:14 +08:00
Lukas Wirth
585cc9e014 Extract generics module 2024-06-21 10:55:05 +02:00
Wilfred Hughes
e62bc2d1f5 fix: Improve hover text in unlinked file diagnostics
Use full sentences, and mention how to disable the diagnostic
if users are intentionally working on unowned files.
2024-06-20 09:32:48 -07:00
Yukang
bfcdeb2a24
Fix diagnostic name in macro_error.rs 2024-06-21 00:13:34 +08:00
bors
67f7eb505e Auto merge of #17464 - wyatt-herkamp:fix-actix-macro, r=lnicola
Check that Expr is none before adding fixup

Closes #17463
2024-06-20 12:59:02 +00:00
Wyatt Herkamp
f51b161568
Check that Expr is none before adding fixup 2024-06-20 08:55:05 -04:00
bors
e08f7953f4 Auto merge of #17462 - Veykril:sema-attr-macro-res, r=Veykril
fix: Fix IDE features breaking in some attr macros

Fixes https://github.com/rust-lang/rust-analyzer/issues/17453, Fixes https://github.com/rust-lang/rust-analyzer/issues/17458
2024-06-20 09:11:44 +00:00
Lukas Wirth
ee8a3458ee fix: Fix IDE features breaking in some attr macros 2024-06-20 11:00:19 +02:00
bors
180c2292f9 Auto merge of #17461 - Veykril:drop-flycheck-recv, r=Veykril
fix: Fix flycheck panicking when cancelled

Fixes https://github.com/rust-lang/rust-analyzer/issues/17445
2024-06-20 08:58:44 +00:00
bors
6738f81b12 Auto merge of #17419 - ishanjain28:filter_builtin_macro_expansion, r=Veykril
Filter builtin macro expansion

This PR adds a filter on the types of built in macros that are allowed to be expanded.

Currently, This list of allowed macros contains, `stringify, cfg, core_panic, std_panic, concat, concat_bytes, include, include_str, include_bytes, env` and `option_env`.

Fixes #14177
2024-06-20 08:39:17 +00:00
Lukas Wirth
bf9a7264d1 Invert matching on builtin macros in expand_allowed_builtins 2024-06-20 10:31:20 +02:00
bors
8568bd8086 Auto merge of #17456 - panicbit:remove-cargo-extension-warning, r=Veykril
Remove panicbit.cargo extension warning

A warning was introduced regarding the incompatabilities between `rust-analyzer` and `panicbit.cargo`'s diagnostics / `cargo check` functionality.

This functionality has been removed in the latest version of the cargo extension (`0.3.0`), which is why the warning can be removed now.
2024-06-20 08:25:30 +00:00
Lukas Wirth
48cf13b598 fix: Fix flycheck panicking when cancelled 2024-06-20 10:21:58 +02:00
bors
501b1fa594 Auto merge of #17457 - roife:remove-circle, r=Veykril
fix: ensure there are no cycles in the source_root_parent_map

See #17409

We can view the connections between roots as a graph. The problem is that this graph may contain cycles, so when adding edges, it is necessary to check whether it will lead to a cycle.

Since we ensure that each node has at most one outgoing edge (because each SourceRoot can have only one parent), we can use a disjoint-set to maintain the connectivity between nodes. If an edge’s two nodes belong to the same set, they are already connected.

Additionally, this PR includes the following three changes:

1. Removed the workaround from #17409.
2. Added an optimization: If `map.contains_key(&SourceRootId(*root_id as u32))`, we can skip the current loop iteration since we have already found its parent.
3. Modified the inner loop to iterate in reverse order with `roots[..idx].iter().rev()` at line 319. This ensures that if we are looking for the parent of `a/b/c`, and both `a` and `a/b` meet the criteria, we will choose the longer match (`a/b`).
2024-06-20 07:53:57 +00:00
bors
02bdd41dc7 Auto merge of #17460 - lnicola:sync-from-rust, r=lnicola
minor: Sync from rust
2024-06-20 06:22:59 +00:00
roife
34f167cc5d fix: ensure there are no cycles in the source_root_parent_map 2024-06-20 13:46:14 +08:00
Laurențiu Nicola
0a2652390a Merge from rust-lang/rust 2024-06-20 08:03:36 +03:00
Laurențiu Nicola
ffbfd02a80 Preparing for merge from rust-lang/rust 2024-06-20 08:03:11 +03:00
bors
7c52065675 Auto merge of #17459 - MariaSolOs:async-compl, r=Veykril
fix(completion): complete async keyword

Fixes #17452

Not entirely confident of the fix here, but my logic is that `async` should in general be offered in similar semantic scenarios as other keywords like `static` or `pub`.
2024-06-19 18:20:20 +00:00
Maria José Solano
20df14321a fix(completion): complete async keyword 2024-06-19 11:12:24 -07:00
panicbit
792155e790 remove panicbit.cargo extension warning 2024-06-19 15:37:09 +02:00
Ishan Jain
19d9bb808d
removed format_args from allowed expansions 2024-06-19 16:58:48 +05:30
Ishan Jain
5465979b7a
updated tests 2024-06-19 16:11:50 +05:30
bors
327372466e Auto merge of #17449 - kilpkonn:assoc_const, r=Veykril
Term search: new tactic for associated item constants

New tactic to cover some more exotic cases that started bothering me.

Associated constants seem to be common in [axum](806bc26e62/examples/readme/src/main.rs (L53)).
2024-06-19 08:52:42 +00:00
bors
87ee18da54 Auto merge of #17438 - jjoeldaniel:toggle_lsp_logs, r=Veykril
feat: add `toggleLSPLogs` command

Implement client-side command to toggle LSP logs in VSCode.

The command replaces the need to add/remove the `"rust-analyzer.trace.server": "verbose"` setting each time one wants to display logs. I've also updated the docs/ instances that reference the now outdated manual method.

The command labeled `rust-analyzer: Toggle LSP Logs` enables the setting project-wide and opens the relevant trace output channel.

Closes #8233
2024-06-19 08:39:42 +00:00
bors
fe4232c97c Auto merge of #17431 - roife:fix-issue-17428, r=Veykril
feat: add space after specific keywords in completion

fix #17428.

When completing some specific keywords, it would be convenient if r-a could automatically add a space afterwards.

This PR implements this feature for the following keywords:

- Visibility: `pub`, `pub(crate)`, `pub(super)`, `pub(in xxx)`
- Pattern: `ref` / `mut`
- Others: `unsafe` / `for` / `where`
2024-06-19 08:26:32 +00:00