Commit Graph

24656 Commits

Author SHA1 Message Date
hecatia-elegua
33ee157f3b Render alias text for use imports
* removes one method breaking the flow
2023-04-06 17:25:30 +02:00
hecatia-elegua
b4515d987f Add doc(alias)-based use and other mod completion 2023-04-05 22:08:59 +02:00
hecatia-elegua
f87f468dbd Add doc(alias)-based function name completion 2023-04-05 19:35:21 +02:00
hecatia-elegua
410acd7188 Add doc(alias)-based field completion 2023-04-05 19:28:55 +02:00
bors
da9c0bd0a7 Auto merge of #14442 - DropDemBits:structured-snippet-api, r=Veykril
internal: Implement Structured API for snippets

Fixes #11638 (including moving the cursor before the generated type parameter)

Adds `add_tabstop_{before,after}` for inserting tabstop snippets before & after nodes, and `add_placeholder_snippet` for wrapping nodes inside placeholder nodes.

Currently, the snippets are inserted into the syntax tree in `SourceChange::commit` so that snippet bits won't interfere with syntax lookups before completing a `SourceChange`.

It would be preferable if snippet rendering was deferred to after so that rendering can work directly with text ranges, but have left that for a future PR (it would also make it easier to finely specify which text edits have snippets in them).

Another possible snippet variation to support would be a group of placeholders (i.e. placeholders with the same tabstop number) so that a generated item and its uses can be renamed right as it's generated, which is something that is technically supported by the current snippet hack in VSCode, though it's not clear if that's a thing that is officially supported.
2023-04-05 14:33:30 +00:00
bors
25124a84de Auto merge of #14490 - Veykril:crategraph-dedup, r=Veykril
internal: Switch crate graph to use an Arena instead of a hashmap
2023-04-05 14:12:11 +00:00
bors
a1ca52e2a9 Auto merge of #14486 - HKalbasi:dev, r=Veykril
Desugar async fn completely

fix #14479
2023-04-05 13:58:38 +00:00
bors
265f83031f Auto merge of #14433 - hecatia-elegua:alias-based-completion, r=Veykril
Add doc-alias based completion

Closes #14406.

I adapted the parsing code from the CfgExpr parsing code, maybe there's a better abstraction for both, or attribute parsing in general. It also includes `doc(hidden)`-parsing, which means it could replace the other function.
There are a few tests for parsing.

`process_all_names` changed the most, I added some docs there to explain what happens.

Many call sites just pass an empy vec to `add_path_resolution`'s `doc_aliases`, since either it doesn't make sense to pass anything (e.g. visibility completion) or I don't know where to get them from. Shouldn't really matter, as it will just not show aliases if the vec is empty and we can extend alias completion in these cases later.

I added two tests in `special.rs` for struct name completion (which was the main thing I wanted). I also tried function and field names, but these don't work yet. I want to add those in a follow-up PR.
2023-04-05 13:44:51 +00:00
bors
c3ed59ce1c Auto merge of #14493 - lowr:fix/ws-between-text-and-pound, r=Veykril
fix: insert whitespace between text and pound

Because `text#`, `text"..."`, and `text'...'` are [reserved syntax since Rust 2021][guide]. Note that the latter two are already handled correctly.

Fixes #14487

[guide]: https://doc.rust-lang.org/edition-guide/rust-2021/reserving-syntax.html
2023-04-05 12:25:27 +00:00
Ryo Yoshida
0df9fb22d8
fix: insert whitespace between text and pound
`text#`, `text"..."`, and `text'...'` are reserved syntax since Rust
2021. Note that the latter two are already handled correctly.
2023-04-05 20:33:17 +09:00
bors
af30656785 Auto merge of #14436 - lowr:patch/normalize-assoc-type-in-path-expr, r=HKalbasi
Normalize associated types in paths in expressions

Part of #14393

When we resolve paths in expressions (either path expressions or paths in struct expressions), there's a need of projection normalization, which `TyLoweringContext` cannot do on its own. We've been properly applying normalization for paths in struct expressions without type anchor, but not for others:

```rust
enum E {
    S { v: i32 }
    Empty,
}

impl Foo for Bar {
    type Assoc = E;
    fn foo() {
        let _ = Self::Assoc::S { v: 42 };   // path in struct expr without type anchor; we already support this
        let _ = <Self>::Assoc::S { v: 42 }; // path in struct expr with type anchor; resolves with this PR
        let _ = Self::Assoc::Empty;         // path expr; resolves with this PR
    }
}
```

With this PR we correctly resolve the whole path, but we need some more tweaks in HIR and/or IDE layers to properly resolve a qualifier (prefix) of such paths and provide IDE features that are pointed out in #14393 to be currently broken.
2023-04-05 10:47:47 +00:00
Lukas Wirth
7f0fbf7f9d Switch crate graph to use an Arena instead of a hashmap 2023-04-05 10:32:02 +02:00
hkalbasi
c26b12d01c Desugar async fn completely 2023-04-04 23:07:38 +03:30
bors
a6464392c1 Auto merge of #14483 - jhgg:fix/generate-delegate-methods-autoderef, r=Veykril
assist: autoderef in generate delegate methods

fixes #14438
2023-04-04 09:35:56 +00:00
Jake Heinz
f6b0c19c56 dedupe by name 2023-04-04 06:57:02 +00:00
Jake Heinz
50b427c0d1 use crate from autoderef ty 2023-04-04 06:54:26 +00:00
Jake Heinz
94e6a6642c assist: autoderef in generate delegate methods 2023-04-04 06:50:20 +00:00
bors
e871540171 Auto merge of #14482 - Veykril:vscode-linking-popup, r=Veykril
fix: Fix relative path creation using the wrong path accessor

This should hopefully fix the other errors with paths people seem to be getting
2023-04-04 06:21:34 +00:00
Lukas Wirth
7989a94391 fix: Fix relative path creation using the wrong path accessor 2023-04-04 08:20:35 +02:00
bors
f070093462 Auto merge of #14481 - Veykril:vscode-linking-popup, r=Veykril
fix: Fix vscode project linking popup buttons being swapped

closes https://github.com/rust-lang/rust-analyzer/issues/14480
2023-04-04 05:55:57 +00:00
Lukas Wirth
4243eeeb2b fix: Fix vscode project linking popup buttons being swapped 2023-04-04 07:55:09 +02:00
hecatia-elegua
170822b018
Add note for future me or others 2023-04-02 16:03:42 +02:00
bors
236576227a Auto merge of #14468 - lowr:patch/expand-macro-bang, r=Veykril
Expand Macro Recursively: don't append "!" to non-bang macro name

When we run `Expand Macro Recursively`, we prepend a comment "Recursive expansion of foo! macro" to the expansion result. I've noticed we unconditionally render the macro name with "!" and, while super subtle, I feel a bit awkward when the macro is either a derive or attribute macro.
2023-04-02 11:36:47 +00:00
Ryo Yoshida
613e008593
Don't append "!" to non-bang macro name 2023-04-02 20:13:34 +09:00
bors
1ebac28f0d Auto merge of #14465 - tamasfe:feat/rtn-syntax, r=Veykril
Limited syntax support for return type notations (RTN)

Experimental RTN bound support was recently merged into rustc (https://github.com/rust-lang/rust/issues/109417), the goal of this PR is to allow experimentation without syntax errors everywhere.

The parsing implemented currently aligns with the state of the tracking issue, it only supports the form `T<foo(..): Bounds>`. The parser always checks for the presence of `..` to disambiguate from `Fn*()` types, this is not ideal but I didn't want to spend too much time as it is an experimental feature.
2023-04-01 16:44:11 +00:00
tamasfe
25910bcde6
chore: replace TODO comment with FIXME 2023-04-01 16:31:16 +02:00
tamasfe
0b9c0c5088
feat(syntax): RTN in bounds
Limited syntactic support for experimental return type notations.
https://github.com/rust-lang/rust/issues/109417
2023-04-01 15:26:03 +02:00
bors
1ce25f114d Auto merge of #14464 - HKalbasi:dev, r=HKalbasi
lower adjusts in simple index except the last one

fix #14463
2023-04-01 13:21:44 +00:00
hkalbasi
d7fe4e2fa8 lower adjusts in simple index except the last one 2023-04-01 16:49:32 +03:30
bors
ffb04ae32d Auto merge of #14461 - HKalbasi:dev, r=Veykril
Use async block in async fn type inference

fix #14456

At some point we should probably go further and completely desugar async fn in hir lowering.
2023-04-01 05:19:36 +00:00
hkalbasi
8a6ca86247 Use async block in async fn type inference 2023-04-01 04:35:28 +03:30
bors
853fb44a24 Auto merge of #14458 - Veykril:crate-origins, r=Veykril
Cleanup crate_graph construction
2023-03-31 13:01:20 +00:00
Lukas Wirth
b3919ea80d Cleanup crate_graph construction 2023-03-31 14:14:04 +02:00
bors
419d59f6e7 Auto merge of #14454 - Veykril:crate-origins, r=Veykril
internal: Refine CrateOrigin variants
2023-03-31 11:19:33 +00:00
Lukas Wirth
31db1fc75f internal: Refine CrateOrigin variants 2023-03-31 10:36:13 +02:00
bors
42d671fcb7 Auto merge of #14451 - Veykril:bumo-smol-str, r=Veykril
minor: Bump smol_str

Should slightly improve compile times by it now not depending on serde (rowan and syntax in turn not either)
2023-03-30 15:45:16 +00:00
Lukas Wirth
f1c5cb7e48 Bump smol_str 2023-03-30 17:44:12 +02:00
hecatia-elegua
c469936aac Address review comments part 1 2023-03-30 17:35:57 +02:00
bors
d3b129f04f Auto merge of #14444 - zapkub:runable-debug-env-is-not-passing-properly, r=Veykril
Missing runnable env on debug target

Fix bug in Rust Analyzer VSCode where runnable debugging did not pass
environment variable from configuration to child process of Cargo on binary build stage

There is a missing env passing along to `cargo` in debug target which give an in-consistent result from debug and run target

For example
```json
{
    "rust-analyzer.runnableEnv": {
        "OUT_DIR": "/test/path2"
    }
}
```

## run
![image](https://user-images.githubusercontent.com/4373581/228749503-fa55f62c-13d3-4d3c-bee6-1cfbe042bdd0.png)
## debug
compiling binary is failed. Missing env
![image](https://user-images.githubusercontent.com/4373581/228749688-3fe42efb-b5ca-41be-862d-f2d97ecab7be.png)

## debug (after fix)
![image](https://user-images.githubusercontent.com/4373581/228750057-1db60051-3465-47db-8b18-4159ec58cfdb.png)
2023-03-30 13:38:36 +00:00
bors
562477b4da Auto merge of #14439 - Veykril:proc-mac-attr-durability, r=Veykril
internal: Set Durability to HIGH for enable_proc_attr_macros input
2023-03-30 13:21:49 +00:00
Lukas Wirth
e244942209 internal: Set Durability to HIGH for enable_proc_attr_macros input 2023-03-30 15:11:22 +02:00
bors
5c6a38abde Auto merge of #14449 - Veykril:parser-vis-recov, r=Veykril
fix: Recover from `pub()` visibility modifier
2023-03-30 13:08:14 +00:00
bors
5390949c11 Auto merge of #14448 - Veykril:infer-table, r=Veykril
internal: Don't expose InferenceTable outside of hir-ty
2023-03-30 12:49:23 +00:00
bors
02ea92fecb Auto merge of #14445 - Veykril:adt-flags, r=Veykril
internal: Introduce StructFlags
2023-03-30 12:34:37 +00:00
bors
fc8c5139fa Auto merge of #14410 - Veykril:query-lru-capacities, r=Veykril
internal: Add config to specifiy lru capacities for all queries

Might help figuring out what queries should be limited by LRU by default, as currently we only limit `parse`, `parse_macro_expansion` and `macro_expand`.
2023-03-30 12:20:24 +00:00
Lukas Wirth
cb546390da fix: Recover from pub() visibility modifier 2023-03-30 13:42:15 +02:00
Lukas Wirth
fc840dbb2d internal: Don't expose InferenceTable outside of hir-ty 2023-03-30 13:27:10 +02:00
Lukas Wirth
5616d91b73 internal: Add config to specifiy lru capacities for all queries 2023-03-30 12:52:28 +02:00
Lukas Wirth
33b6012827 Introduce StructFlags 2023-03-30 12:49:08 +02:00
bors
b915eb32fa Auto merge of #14427 - davidbarsky:davidbarsky/allow-subsequent-workspaces-to-have-proc-macros, r=Veykril
fix: allow new, subsequent `rust-project.json`-based workspaces to get proc macro expansion

As detailed in https://github.com/rust-lang/rust-analyzer/issues/14417#issuecomment-1485336174, `rust-project.json` workspaces added after the initial `rust-project.json`-based workspace was already indexed by rust-analyzer would not receive procedural macro expansion despite `config.expand_proc_macros` returning true. To fix this issue:
1. I changed `reload.rs` to check which workspaces are newly added.
2. Spawned new procedural macro expansion servers based on the _new_ workspaces.
    1. This is to prevent spawning duplicate procedural macro expansion servers for already existing workspaces. While the overall memory usage of duplicate procedural macro servers is minimal, this is more about the _principle_ of not leaking processes 😅.
3. Launched procedural macro expansion if any workspaces are `rust-project.json`-based _or_ `same_workspaces` is true. `same_workspaces` being true (and reachable) indicates that that build scripts have finished building (in Cargo-based projects), while the build scripts in `rust-project.json`-based projects have _already been built_ by the build system that produced the `rust-project.json`.

I couldn't really think of structuring this code in a better way without engaging with https://github.com/rust-lang/rust-analyzer/issues/7444.
2023-03-30 07:50:27 +00:00