Commit Graph

27824 Commits

Author SHA1 Message Date
bors
4e8cbf36a8 Auto merge of #16708 - Veykril:codegen, r=Veykril
internal: Move ide-assists codegen tests into an xtask codegen command
2024-03-04 15:50:39 +00:00
bors
00879b1c57 Auto merge of #16750 - Veykril:unnecessary-else, r=Veykril
minor: Mark remove_unnecessary_else as experimental

cc https://github.com/rust-lang/rust-analyzer/issues/16566#issuecomment-1976492762 https://github.com/rust-lang/rust-analyzer/issues/16628

There seem to be some leftover issues with this, additionally its a style lint so it's not too nice to see for some people. We should flesh out our diagnostics stuff before adding more style lints I think
2024-03-04 15:37:52 +00:00
Lukas Wirth
6e802a0b56 minor: Mark remove_unnecessary_else as experimental 2024-03-04 16:35:33 +01:00
bors
a7e9f12bf7 Auto merge of #16748 - Veykril:on-demand-validation-err, r=Veykril
internal: Compute syntax validation errors on demand

The LRU cache causes us to re-parse trees quite often, yet we don't use the validation errors at all. With this we push calculating them off to the caller who is interested in them.
2024-03-04 11:19:16 +00:00
Lukas Wirth
c3c9f5ffe1 internal: Compute syntax validation errors on demand 2024-03-04 12:06:15 +01:00
bors
99a1b8f7a8 Auto merge of #16747 - Veykril:cleanup, r=Veykril
internal: Clean some stuff up

Just a bunch of small refactorings, mainly from browsing through `hir-def`
2024-03-04 10:30:17 +00:00
Lukas Wirth
4303e741de Cleanup 2024-03-04 11:10:06 +01:00
bors
2074cc28de Auto merge of #16722 - mo8it:allocations, r=Veykril
Avoid some allocations

I went on a small `.clone()` hunting tour :D
2024-03-04 09:17:23 +00:00
bors
d8feb908be Auto merge of #16703 - regexident:sema-ast-to-hir, r=Veykril
Add more methods for resolving definitions from AST to their corresponding HIR types

In order to be able to add these methods with consistent naming I had to also rename two existing methods that would otherwise be conflicting/confusing:

`Semantics::to_module_def(&self, file: FileId) -> Option<Module>` (before)
`Semantics::file_to_module_def(&self, file: FileId) -> Option<Module>` (after)

`Semantics::to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (before)
`Semantics::file_to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (after)

(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving its exprs/stmts/items to their HIR equivalents)
2024-03-04 09:02:32 +00:00
bors
0b7d4cc6ff Auto merge of #16690 - roife:fix-issue-16471, r=Veykril
fix: use 4 spaces for indentation in macro expansion

Partial fix for #16471.

In the previous code, the indentation produced by macro expansion was set to 2 spaces. This PR modifies it to 4 spaces for the sake of consistency.
2024-03-04 08:49:51 +00:00
bors
518cfe8cb7 Auto merge of #16723 - norskeld:constants-autocomplete, r=Veykril
fix: autocomplete constants inside format strings

Hi! This PR adds autocompletion for constants (including statics) inside format strings and closes #16608.

I'm not sure about adding the `constants` field to the `CompletionContext`. It kinda makes sense, since it's in line with the `locals` field, and this way everything looks a bit cleaner, but at the same time does it really need to be there?

Anyway, let me know if anything should/can be changed. :)
2024-03-04 08:36:39 +00:00
bors
d444acdb19 Auto merge of #16719 - lnicola:native-debug, r=lnicola
fix: Add basic support for Native Debug

Native Debug doesn't work very well and passing command-line arguments is nasty (https://github.com/rust-lang/rust-analyzer/issues/9815), but I guess it's a start.

Closes #9815
2024-03-04 08:16:01 +00:00
bors
037924c4d8 Auto merge of #16740 - lnicola:sync-from-rust, r=lnicola
internal: sync from downstream
2024-03-03 11:50:46 +00:00
Laurențiu Nicola
9fafbfa45a Merge branch 'master' into sync-from-rust 2024-03-03 13:40:05 +02:00
bors
67f7557725 Auto merge of #16738 - Nadrieril:update-pat-ana, r=lnicola
Update rustc_pattern_analysis

This should fix https://github.com/rust-lang/rust-analyzer/issues/16656 but I can't check because we don't have a reproducer.
2024-03-03 11:38:44 +00:00
Nadrieril
7c6f7b2c49 Update rustc_pattern_analysis 2024-03-03 00:34:27 +01:00
bors
4ef6a49b44 Auto merge of #16702 - Veykril:intra-doc-links-generic, r=Veykril
fix: Ignore generic arguments in intra doc link path resolution

Fixes https://github.com/rust-lang/rust-analyzer/issues/16699
2024-03-02 09:51:16 +00:00
bors
5c4c126832 Auto merge of #16704 - Veykril:stuff, r=Veykril
internal: Simplify
2024-03-02 09:37:26 +00:00
bors
6cb576a137 Auto merge of #16735 - lnicola:smolstr-new-static, r=lnicola
minor: Remove outdated comment about static SmolStrs

Closes https://github.com/rust-lang/rust-analyzer/issues/16734
2024-03-02 08:57:47 +00:00
Laurențiu Nicola
dd21914e9d Remove outdated comment about static SmolStrs 2024-03-02 10:56:03 +02:00
bors
79e0fee6a3 Auto merge of #16727 - Veykril:assoc-related, r=Veykril
fix: Don't highlight related assoc items of super traits
2024-03-01 18:34:48 +00:00
bors
c512e2e1bf Auto merge of #16728 - Veykril:span-docs, r=Veykril
minor: Move span stuff around
2024-03-01 18:20:35 +00:00
Lukas Wirth
efd76ecff1 Move AstIdMap infra to the span crate 2024-03-01 15:39:44 +01:00
Lukas Wirth
549aae7c07 Add a few more doc lines to the span crate 2024-03-01 15:20:30 +01:00
Lukas Wirth
8a5bb9d5ac Only the ROOT syntax context has None outer_expn 2024-03-01 15:14:17 +01:00
Lukas Wirth
eb7a4f293e minor: Add some basic docs for spans/hygiene handling 2024-03-01 14:39:15 +01:00
Lukas Wirth
aabaa47bfb fix: Don't highlight related assoc items of super traits 2024-03-01 14:03:12 +01:00
Lukas Wirth
ed7e9aa5d8 Simplify 2024-03-01 13:25:24 +01:00
Lukas Wirth
c8fdcea85c Fix targetDir config name 2024-03-01 13:19:55 +01:00
Lukas Wirth
83a1ad5bfe Give all threads names 2024-03-01 13:19:55 +01:00
Vladislav Mamon
1d28aecd13
fix: autocomplete constants inside format strings 2024-03-01 14:23:31 +03:00
mo8it
00a049b585 Avoid cloning deps 2024-02-29 17:01:32 +01:00
mo8it
9df73c6cb0 Convert directly into an Arc<str> 2024-02-29 16:53:48 +01:00
mo8it
4aab2d5cb4 Remove unneeded to_owned 2024-02-29 16:29:15 +01:00
mo8it
748f57c16d Only clone when required 2024-02-29 16:28:59 +01:00
bors
9efa23c4da Auto merge of #16707 - regexident:pub-sema-impl, r=Veykril
Export `SemanticsImpl` from `ra_ap_hir` crate, since it's already exposed via `Semantics.deref()`

The `SemanticsImpl` type is already de-facto exposed via `<Semantics as Deref>::Target`.

By not being part of the public crate interface it however doesn't get included in the documentation, resulting in a massive blind spot when it comes to `ra_ap_hir`'s type resolution APIs.
2024-02-29 15:12:04 +00:00
mo8it
06a883e32f Take a reference instead of cloning 2024-02-29 16:05:26 +01:00
bors
b3b9b53df8 Auto merge of #16706 - Veykril:load-cargo-ide-db, r=Veykril
internal: Remove load-cargo dependency on ide

This lightens up the dep tree for projects using r-a as a library that do not need the ide crate itself.
2024-02-29 14:59:27 +00:00
bors
ecda4642ef Auto merge of #16705 - regexident:resolve-callable-exprs, r=Veykril
Add public function for resolving callable AST exprs to their HIR equivalents

(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving callable exprs within to their HIR equivalents)
2024-02-29 14:46:21 +00:00
bors
a6606d1767 Auto merge of #16698 - regexident:param-derives, r=Veykril
Derive `PartialEq`, `Eq` & `Hash` for `hir::Param`

Since `hir::SelfParam`, as well as all members of `hir::Param` already implement `PartialEq`, `Eq` & `Hash` it seems reasonable to also make `hir::Param` implement those.

(the change is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to collect params in a `HashSet`)
2024-02-29 14:33:37 +00:00
bors
ef2acb6ff3 Auto merge of #16695 - Veykril:revert-16541, r=Veykril
internal: Revert #16541

Closes https://github.com/rust-lang/rust-analyzer/issues/16602
2024-02-29 14:20:57 +00:00
Laurențiu Nicola
a01e4f8b72 Add basic support for Native Debug 2024-02-29 16:14:58 +02:00
bors
71eb5400a3 Auto merge of #16638 - Lindronics:destructure-struct-binding, r=Veykril
feature: Add `destructure_struct_binding`

Adds an assist for destructuring a struct in a binding (#8673). I saw that #13997 has been abandoned for a while, so I thought I'd give it a go.

## Example

```rust
let foo = Foo { bar: 1, baz: 2 };
let bar2 = foo.bar;
let baz2 = foo.baz;
let foo2 = foo;

let fizz = Fizz(1, 2);
let buzz = fizz.0;
```
becomes
```rust
let Foo { bar, baz } = Foo { bar: 1, baz: 2 };
let bar2 = bar;
let baz2 = baz;
let foo2 = todo!();

let Fizz(_0, _1) = Fizz(1, 2);
let buzz = _0;
```

More examples in the tests.

## What is included?

- [x] Destructure record, tuple, and unit struct bindings
- [x] Edit field usages
- [x] Non-exhaustive structs in foreign crates and private fields get hidden behind `..`
- [x] Nested bindings
- [x] Carry over `mut` and `ref mut` in nested bindings to fields, i.e. `let Foo { ref mut bar } = ...` becomes `let Foo { bar: Bar { baz: ref mut baz } } = ...`
- [x] Attempt to resolve collisions with other names in the scope
- [x] If the binding is to a reference, field usages are dereferenced if required
- [x] Use shorthand notation if possible

## Known limitations

- `let foo = Foo { bar: 1 }; foo;` currently results in `let Foo { bar } = Foo { bar: 1 }; todo!();` instead of reassembling the struct. This requires user intervention.
- Unused fields are not currently omitted. I thought that this is more ergonomic, as there already is a quick fix action for adding `: _` to unused field patterns.
2024-02-29 14:07:50 +00:00
bors
0ec6015b6e Auto merge of #16709 - ShoyuVanilla:fix-goto-index-mut, r=Veykril
fix: Goto definition for `index_mut`

Mostly same with #16696.
0ac05c0527/crates/hir-ty/src/infer/mutability.rs (L103-L133)
Thankfully, we are doing similar method resolutions so we can use them like the mentioned PR.
As there are only three `LangItem`s having `Mut` in there names; `FnMut`, `DerefMut` and `IndexMut`, I think that this is the last one 😄
2024-02-29 13:55:23 +00:00
Niklas Lindorfer
dc7b502689
Fix usage in other assist 2024-02-29 13:17:45 +00:00
Niklas Lindorfer
7c30c70658
Attempt resolving name collisions 2024-02-29 13:17:45 +00:00
Niklas Lindorfer
b203a07d92
Handle bindings to refs 2024-02-29 13:17:45 +00:00
Niklas Lindorfer
ed230048dc
Add destructure_struct_binding action
Separate into create and apply edit

Rename usages

Hacky name map

Add more tests

Handle non-exhaustive

Add some more TODOs

Private fields

Use todo

Nesting

Improve rest token generation

Cleanup

Doc -> regular comment

Support mut
2024-02-29 13:17:44 +00:00
Lukas Wirth
4ee0dbdc04 internal: Remove load-cargo dependency on ide 2024-02-28 16:59:04 +01:00
Lukas Wirth
03b02e6bd0 internal: Move ide-assists codegen tests into an xtask codegen command 2024-02-28 16:54:44 +01:00