Commit graph

20080 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
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
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
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
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
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
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
Maria José Solano
20df14321a fix(completion): complete async keyword 2024-06-19 11:12:24 -07: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
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
bors
a150d422cf Auto merge of #17426 - roife:fix-issue-17420, r=Veykril
fix: handle character boundaries for wide chars in extend_selection

fix #17420.

When calling 'extend_selection' within a string, r-a attempts to locate the current word at the cursor. This is done by finding the first char before the cursor which is not a letter, digit, or underscore.

The position of this character is referred to as `start_idx`, and the word is considered to start from `start_idx + 1`. However, for wide characters, `start_idx + 1` is not character boundaries, which leading to panic. We should use `ceil_char_boundary` to ensure that the idx is always on character boundaries.
2024-06-19 08:13:18 +00:00
bors
889ca281f0 Auto merge of #17415 - Wilfred:unlinked_diagnostic_span, r=Veykril
fix: Only show unlinked-file diagnostic on first line during startup

This partially reverts #17350, based on the feedback in #17397.

If we don't have an autofix, it's more annoying to highlight the whole file. This autofix heuristic fixes the diagnostic being overwhelming during startup.
2024-06-19 07:58:53 +00:00
Tavo Annus
c87609fef1 Add tactic for associated item constants 2024-06-18 22:08:44 +03:00
abdullathedruid
2592f3168f
Update lib.rs 2024-06-18 00:52:53 +01:00
bors
53be113617 Auto merge of #17442 - Veykril:pat-eof, r=Veykril
fix: Fix pat fragment parsers choking on <eoi>

Fixes https://github.com/rust-lang/rust-analyzer/issues/17441
2024-06-17 17:44:35 +00:00
Lukas Wirth
f9bb5476c3 fix: Fix pat fragment parsers choking on <eoi> 2024-06-17 19:42:56 +02:00
bors
9cc746463f Auto merge of #17434 - Lunaphied:fix/document-inlay-parameters, r=Veykril
docs: document omission heuristics for parameter inlay hints

These are not currently documented and could cause users to think that their rust-analyzer configuration is broken.

Partially addresses #17433.
2024-06-17 16:11:17 +00:00
bors
7b38f8ab12 Auto merge of #17439 - Veykril:paralleler-prime-caches, r=Veykril
Properly prime all crate def maps in parallel_prime_caches
2024-06-17 15:58:09 +00:00
Lukas Wirth
158626bed4 Add some more syntax fixup rules 2024-06-17 13:10:56 +02:00
Lukas Wirth
f11891f882 Properly prime all crate def maps in parallel_prime_caches 2024-06-17 13:10:39 +02:00
Lunaphied
e1ffec2b4c docs: document omission heuristics for parameter inlay hints
These are not currently documented and could cause users to think
that their rust-analyzer configuration is broken.

Partially addresses #17433.
2024-06-16 15:15:36 -06:00