Commit Graph

28065 Commits

Author SHA1 Message Date
Young-Flash
dba67b46a1 update for review 2024-03-02 10:01:04 +08: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
Shoyu Vanilla
bf23deecb3 Fix goto index_mut 2024-02-29 00:52:58 +09:00
Shoyu Vanilla
83f6dd14f8 Add a new failing test for Goto index_mut definition 2024-02-29 00:52:30 +09:00
Vincent Esche
ed3497883c Add public function for resolving ast::Expr to hir::Callable 2024-02-28 16:44:07 +01:00
Vincent Esche
74531e4d80 Export SemanticsImpl from ra_ap_hir crate, since it's already exposed via Semantics.deref() 2024-02-28 16:16:54 +01:00
Lukas Wirth
ab533d887d fix: Ignore generic arguments in intra doc link path resolution 2024-02-28 14:47:47 +01:00
Vincent Esche
fac8a14de8 Add a more methods for resolving definitions from AST to their corresponding HIR types 2024-02-28 10:27:28 +01:00
Vincent Esche
6112ddfabb Add prefix file_ to Semantics's to_module_defs()/to_module_def() methods 2024-02-28 10:27:28 +01:00
Vincent Esche
c061a9e84e Derive PartialEq, Eq & Hash for hir::Param 2024-02-27 20:53:29 +01:00
bors
0ac05c0527 Auto merge of #16697 - regexident:relpath-to-relpathbuf, r=Veykril
Add `to_path_buf()` method for `RelPath`

There seems to be no ergonomic way to obtain a `RelPathBuf` from a corresponding `&RelPath` at the moment, making the latter sort of a dead end.

The `AbsPath` type provides the following:

```rust
impl AbsPath {
    // ...

    /// Equivalent of [`Path::to_path_buf`] for `AbsPath`.
    pub fn to_path_buf(&self) -> AbsPathBuf {
        AbsPathBuf::try_from(self.0.to_path_buf()).unwrap()
    }

    // ...
}
```

So I took the liberty of adding a corresponding equivalent for `RelPath:

```rust
impl RelPath {
    // ...

    /// Equivalent of [`Path::to_path_buf`] for `RelPath`.
    pub fn to_path_buf(&self) -> RelPathBuf {
        RelPathBuf::try_from(self.0.to_path_buf()).unwrap()
    }

    // ...
}
```

(the change is motivated by an outside use of the `ra_ap_paths` crate that would benefit from being able to use `RelPath` and `AbsPath` over `Path`)
2024-02-27 18:19:43 +00:00
Vincent Esche
0005794770 Add to_path_buf() method for RelPath 2024-02-27 18:33:47 +01:00
bors
a41cec9f7c Auto merge of #16696 - ShoyuVanilla:fix-goto-deref-mut, r=Veykril
fix: Goto definition for `deref_mut`

Fixes #16520

a3236be9d7/crates/hir/src/source_analyzer.rs (L375-L393)

As we can see from the above, current implementation routes all dereferencing prefix operations to `Deref::deref` implementation, not regarding mutabilities.

a3236be9d7/crates/hir-ty/src/infer/mutability.rs (L134-L151)

Since we are resolving them already in mutability inferences, we can use those results for proper `deref` / `deref_mut` routing.
2024-02-27 16:01:45 +00:00
Shoyu Vanilla
612443111b Remove unused imports 2024-02-28 00:10:08 +09:00
Shoyu Vanilla
0f4e313028 Fix goto deref_mut 2024-02-27 23:55:19 +09:00
Shoyu Vanilla
d1bdebf2b9 Add a new failing test for goto deref_mut 2024-02-27 23:54:05 +09:00
Lukas Wirth
30ad0ae209 internal: Revert #16541 2024-02-27 15:48:30 +01:00
bors
a3236be9d7 Auto merge of #16630 - ShoyuVanilla:fix-closure-kind-inference, r=Veykril
fix: Wrong closure kind deduction for closures with predicates

Completes #16472, fixes #16421

The changed closure kind deduction is mostly simlar to `rustc_hir_typeck/src/closure.rs`.
Porting closure sig deduction from it seems possible too and I'm considering doing it with another PR
2024-02-27 14:41:23 +00:00
bors
c031246546 Auto merge of #16693 - Veykril:system-rustc-sysroot, r=Veykril
fix: rust-project.json projects not preferring sysroot rustc
2024-02-27 14:28:36 +00:00
roife
76b86b24bd fix: clippy and format 2024-02-27 20:53:09 +08:00
roife
ec5236f3a8 test: use 4 spaces for indetation in macro expansion 2024-02-27 20:53:07 +08:00