Commit graph

30598 commits

Author SHA1 Message Date
Lukas Wirth
cf2b757a1a Light docs and privacy 2024-06-21 17:54:40 +02:00
davidsemakula
d6d45a23d3 fix: don't remove parentheses for calls of function-like pointers that are members of a struct or union 2024-06-21 17:57:53 +03: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
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
bors
93add0f640 Auto merge of #17455 - Veykril:vscode-ext, r=Veykril
Tidy up vscode extension a bit
2024-06-19 07:45:34 +00:00
Lukas Wirth
ff07caa9de Tidy up vscode extension a bit 2024-06-19 09:42:06 +02:00
bors
867bd099b8 Auto merge of #125852 - bvanjoi:improve-tip-for-invisible-trait, r=compiler-errors
improve tip for inaccessible traits

Improve the tips when the candidate method is from an inaccessible trait.

For example:

```rs
mod m {
  trait Trait {
    fn f() {}
  }
  impl<T> Trait for T {}
}

fn main() {
  struct S;
  S::f();
}
```

The difference between before and now is:

```diff
error[E0599]: no function or associated item named `f` found for struct `S` in the current scope
  --> ./src/main.rs:88:6
   |
LL |   struct S;
   |   -------- function or associated item `f` not found for this struct
LL |   S::f();
   |      ^ function or associated item not found in `S`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
- help: trait `Trait` which provides `f` is implemented but not in scope; perhaps you want to import it
+ help: trait `crate:Ⓜ️:Trait` which provides `f` is implemented but not reachable
   |
- LL + use crate:Ⓜ️:Trait;
   |
```
2024-06-19 06:19:22 +00:00
Tavo Annus
c87609fef1 Add tactic for associated item constants 2024-06-18 22:08:44 +03:00
bors
021ae0101c Auto merge of #17444 - abdullathedruid:patch-1, r=lnicola
minor: Update lib.rs

Update of comment in api walkthrough
2024-06-18 06:26:24 +00:00
bors
0de72abae0 Auto merge of #126279 - Oneirical:you-can-run-make-but-cannot-hide, r=jieyouxu
Migrate `inaccessible-temp-dir`, `output-with-hyphens` and `issue-10971-temps-dir` `run-make` tests to `rmake`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
2024-06-18 00:42:26 +00: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
b6929e2679 Auto merge of #17435 - Lunaphied:fix/manual-generation, r=Veykril
docs: fix manual generation instructions

To generate all the requisite files, you need to run `cargo xtask codegen` not `cargo test -p xtask`.
2024-06-17 16:24:32 +00: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
bors
1bb376cabc Auto merge of #17440 - Veykril:runnables, r=Veykril
Fix and cleanup VSCode task building

Fixes https://github.com/rust-lang/rust-analyzer/issues/17436
2024-06-17 12:17:10 +00:00
Lukas Wirth
8846b5cf4a Fix and cleanup VSCode task building 2024-06-17 14:06:01 +02: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
Joel Daniel Rico
2ebcf55ece feat: add toggleLSPLogs command
add `toggleLSPLogs` command
update docs to reflect new command
2024-06-17 04:08:32 -07:00
bors
0e25481a8e Auto merge of #125720 - folkertdev:optimize_for_size-ptr-rotate, r=Amanieu
make `ptr::rotate` smaller when using `optimize_for_size`

code to reproduce https://github.com/folkertdev/optimize_for_size-slice-rotate

In the example the size of `.text` goes down from 1624 to 276 bytes.

```
> cargo size --release --features "left-std"  -- -A

slice-rotate  :
section              size        addr
.vector_table        1024         0x0
.text                1624       0x400
.rodata                 0       0xa58
.data                   0  0x20000000
.gnu.sgstubs            0       0xa60
.bss                    0  0x20000000
.uninit                 0  0x20000000
.debug_loc            591         0x0
.debug_abbrev        1452         0x0
.debug_info         10634         0x0
.debug_aranges        480         0x0
.debug_ranges        1504         0x0
.debug_str          11716         0x0
.comment               72         0x0
.ARM.attributes        56         0x0
.debug_frame         1036         0x0
.debug_line          5837         0x0
Total               36026

> cargo size --release --features "left-size"  -- -A

slice-rotate  :
section             size        addr
.vector_table       1024         0x0
.text                276       0x400
.rodata                0       0x514
.data                  0  0x20000000
.gnu.sgstubs           0       0x520
.bss                   0  0x20000000
.uninit                0  0x20000000
.debug_loc           347         0x0
.debug_abbrev        965         0x0
.debug_info         4216         0x0
.debug_aranges       168         0x0
.debug_ranges        216         0x0
.debug_str          3615         0x0
.comment              72         0x0
.ARM.attributes       56         0x0
.debug_frame         232         0x0
.debug_line          723         0x0
Total              11910
```

tracking issue: https://github.com/rust-lang/rust/issues/125612
2024-06-17 01:45:22 +00:00
Lunaphied
16c2078c9f docs: fix manual generation instructions
To generate all the requisite files, you need to run `cargo xtask codegen` not
`cargo test -p xtask`.
2024-06-16 15:25:42 -06: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