Commit Graph

21677 Commits

Author SHA1 Message Date
bors ebe6e30f04 Auto merge of #12054 - HKalbasi:const_generic, r=flodiebold
Fix const generic panic in dyn trait

fix #12048
2022-04-22 15:22:49 +00:00
hkalbasi 785ae4dfa8 remove trailing space 2022-04-22 19:29:10 +04:30
hkalbasi 0b5dd42fac Add some comments about why never!() never happens 2022-04-22 19:22:18 +04:30
bors b6b5214c66 Auto merge of #12053 - willcrichton:master, r=jonas-schievink
Export lc.LanguageClient from VSCode extension

As described in [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Use.20Rust.20Analyzer.20in.20another.20VSCode.20extension), I would like to experiment with using Rust Analyzer's language server inside another VSCode extension, [Flowistry](https://github.com/willcrichton/flowistry). My current use case is to use one of Rust Analyzer's assists (extract function).

This PR would enable that experimentation by exporting the `lc.LanguageClient` from the `activate` function, which [allows other extensions to access it](https://code.visualstudio.com/api/references/vscode-api#extensions). This PR does **not** commit RA to any stability guarantees about the language client, similar to how rustc exports an unstable API.
2022-04-22 14:42:25 +00:00
hkalbasi d33d5fca1d fix const generic panic in dyn trait 2022-04-22 01:36:11 +04:30
Will Crichton d607c1b558 Export lc.LanguageClient from VSCode extension 2022-04-21 13:39:53 -07:00
bors 1db66b96c8 Auto merge of #12052 - lnicola:cargo-config, r=lnicola
minor: drop `install-ra` cargo alias
2022-04-21 18:10:37 +00:00
Laurențiu Nicola 0989f436b2 Rename cargo config to config.toml 2022-04-21 21:08:07 +03:00
Laurențiu Nicola 6037ff3a58 Remove old install-ra cargo alias 2022-04-21 21:06:28 +03:00
bors 9ee080f8b2 Auto merge of #12015 - arjo129:master, r=jonas-schievink
[Documentation]: Update developer documentation link.

Just noticed the docs links broken. The current doc link was broken. replaced with the updated version as found on the front page. Should the rest of the links be updated?
2022-04-21 16:52:10 +00:00
bors 8393f32126 Auto merge of #12051 - jonas-schievink:triagebot, r=jonas-schievink
Add triagebot.toml

Allow people to claim issues
2022-04-21 15:48:42 +00:00
Jonas Schievink 2cab597aae Add triagebot.toml 2022-04-21 17:43:12 +02:00
bors 24f9209a87 Auto merge of #12040 - rainy-me:improve-parameter-completion, r=jonas-schievink
fix: Improve parameter completion

fix https://github.com/rust-lang/rust-analyzer/issues/12016 and handles some extra cases.
2022-04-21 15:39:10 +00:00
rainy-me 8f8f20fda5 fix: lookup 2022-04-22 00:07:42 +09:00
bors 71d49d31bb Auto merge of #12044 - tedinski:fix_rustc_workspace, r=jonas-schievink
fix: index the correct CargoWorkspace with rustc_private

I believe this fixes #12043, but I'm not sufficiently setup/familiar with working on rust-analyzer to test it locally. :/

This section of code is iterating on `rustc_workspace.packages()` but then indexes `cargo[pkg]`, which is likely the source of the bug.
2022-04-21 14:03:37 +00:00
Ted Kaminski ecb1368027 fix: index the correct CargoWorkspace with rustc_private 2022-04-20 17:16:04 +00:00
bors f83dce0a4a Auto merge of #12042 - jonas-schievink:remove-angle-brackets-from-lang-config, r=jonas-schievink
fix: remove angle brackets from language configuration

This should fix https://github.com/rust-lang/rust-analyzer/issues/12034

It looks like we shouldn't add any characters here that can be ambiguous, because it can make the editor highlight unrelated characters. This needs a parser to be correct, so the language server is the right place, not the editor. Upstream LSP feature request: https://github.com/microsoft/language-server-protocol/issues/672 (but it might be possible to implement this as an extension today, as long as that doesn't conflict with the built-in highlighting).
2022-04-20 14:54:24 +00:00
Jonas Schievink c1a28ccf8c fix: remove angle brackets from language configuration 2022-04-20 16:43:24 +02:00
bors 3bda70a232 Auto merge of #12041 - jonas-schievink:prefer-core-cfg-attr-no-std, r=jonas-schievink
feat: prefer core/alloc over std in auto-imports if `#[no_std]` is conditional

We already did this if `#![no_std]` was present, this PR makes it work with `#![cfg_attr(not(test), no_std)]` too, which is very common in libraries.

Fixes https://github.com/rust-lang/rust-analyzer/issues/12035
cc https://github.com/rust-lang/rust-analyzer/issues/10718
2022-04-20 12:11:09 +00:00
Jonas Schievink dd4a92176c Prefer core/alloc over std if no_std is conditional 2022-04-20 14:07:40 +02:00
rainy-me a58f7acc97 fix: improve parameter completion 2022-04-20 17:56:20 +09:00
bors 34c3e0b067 Auto merge of #12037 - lnicola:inlay-hint-config, r=lnicola
fix: Remove `rust-analyzer.inlayHints.enable` and set language scope

Closes #12036
CC https://github.com/rust-lang/rust-analyzer/issues/12027#issuecomment-1102990324

The key was left there by mistake in #12006.

Setting the configuration scope only works if you already have it created, which is fine, but unfortunately not quite discoverable.
2022-04-20 04:38:22 +00:00
Laurențiu Nicola ad751e08ec Pass the language id when toggling inlay hints 2022-04-20 07:34:00 +03:00
Laurențiu Nicola 4de7793425 Actually remove rust-analyzer.inlayHints.enable 2022-04-20 07:33:26 +03:00
bors 55824021e1 Auto merge of #12032 - jonas-schievink:code-action-commands, r=jonas-schievink
feat: display signature help when applying "Add `::<>`" assist

Closes https://github.com/rust-lang/rust-analyzer/issues/12031
2022-04-19 16:46:33 +00:00
Jonas Schievink c6ffffccbd Allows triggering commands after an assist edit 2022-04-19 18:45:48 +02:00
bors e3ec87730a Auto merge of #12029 - xuhongxu96:master, r=lnicola
Fix typo "GreeNode" in syntax.md
2022-04-19 07:57:12 +00:00
Hongxu Xu 4390a8ad7c Fix typo "GreeNode" in syntax.md 2022-04-19 15:45:03 +08:00
bors b25e34837a Auto merge of #12028 - lnicola:fix-changelog, r=lnicola
internal: Fix changelog generation after repo move
2022-04-19 06:09:32 +00:00
Laurențiu Nicola d4dcb16a02 Fix changelog generation after repo move 2022-04-19 09:08:39 +03:00
bors 838cc9d3cc Auto merge of #12025 - Veykril:completion-ctx, r=Veykril
minor: Document completion context some more
2022-04-18 14:55:31 +00:00
Lukas Wirth f8c32df7cd minor: Document completion context some more 2022-04-18 16:54:13 +02:00
bors e0d41bc2a1 Auto merge of #12021 - Veykril:completion-ctx, r=Veykril
internal: Add a `NameContext` to `CompletionContext`, move out some ImmediateLocation variants

Continues the completion rewrite I started some time ago
(will merge tomorrow after stable since our completion tests still let a lot through)
2022-04-18 14:00:56 +00:00
bors ebf4658ae9 Auto merge of #12024 - XFFXFF:derive_completion, r=Veykril
derive completions take existing derives into count

fixes #12019

The immediate reason is that when we are doing derive completion, [`ctx.existing_derives`](https://github.com/rust-lang/rust-analyzer/blob/d1f6b4e2a0ab1a1343ab4a381c89b186a76fd001/crates/ide_completion/src/completions/attribute/derive.rs#L82) is empty, this is because we expand the macro when looking for the ancestors of the token to be completed. Take the following code as an example, we find the first `SyntaxNode` with kind `Attr` based on the ancestors of the token, but the parent of `Attr` is not a `Struct` as we [expect](https://github.com/rust-lang/rust-analyzer/blob/d1f6b4e2a0ab1a1343ab4a381c89b186a76fd001/crates/hir/src/semantics.rs#L518).
```rust
#[derive(PartialEq, Eq, Or$0)]
struct S;
```
The ancestors of the token to be completed above.
```
    NAME_REF@24..26
      IDENT@24..26 "Or"
    ,
    PATH_SEGMENT@24..26
      NAME_REF@24..26
        IDENT@24..26 "Or"
    ,
    PATH@24..26
      PATH_SEGMENT@24..26
        NAME_REF@24..26
          IDENT@24..26 "Or"
    ,
    META@24..26
      PATH@24..26
        PATH_SEGMENT@24..26
          NAME_REF@24..26
            IDENT@24..26 "Or"
    ,
    ATTR@21..28
      POUND@21..22 "#"
      WHITESPACE@22..23 " "
      L_BRACK@23..24 "["
      META@24..26
        PATH@24..26
          PATH_SEGMENT@24..26
            NAME_REF@24..26
              IDENT@24..26 "Or"
      R_BRACK@26..27 "]"
      WHITESPACE@27..28 " "
    ,
    TUPLE_EXPR@0..32
      ATTR@0..14
        POUND@0..1 "#"
        WHITESPACE@1..2 " "
        L_BRACK@2..3 "["
        META@3..12
          PATH@3..12
            PATH_SEGMENT@3..12
              NAME_REF@3..12
                IDENT@3..12 "PartialEq"
        R_BRACK@12..13 "]"
        WHITESPACE@13..14 " "
      ATTR@14..21
        POUND@14..15 "#"
        WHITESPACE@15..16 " "
        L_BRACK@16..17 "["
        META@17..19
          PATH@17..19
            PATH_SEGMENT@17..19
              NAME_REF@17..19
                IDENT@17..19 "Eq"
        R_BRACK@19..20 "]"
        WHITESPACE@20..21 " "
      ATTR@21..28
        POUND@21..22 "#"
        WHITESPACE@22..23 " "
        L_BRACK@23..24 "["
        META@24..26
          PATH@24..26
            PATH_SEGMENT@24..26
              NAME_REF@24..26
                IDENT@24..26 "Or"
        R_BRACK@26..27 "]"
        WHITESPACE@27..28 " "
      L_PAREN@28..29 "("
      WHITESPACE@29..30 " "
      R_PAREN@30..31 ")"
      WHITESPACE@31..32 " "
...
```

I make a small change to not do macro expansion when looking up the ancestors of the token.

What I don't understand is that `self.sema.token_ancestors_with_macros(self.token.clone())` doesn't seem to expand the macro if the derive completion triggered without any prefix, like `#[derive(PartialEq, Eq, $0)]`.

The ancestors of the token with  `#[derive(PartialEq, Eq, $0)]`.
```
    TOKEN_TREE@8..25
      L_PAREN@8..9 "("
      IDENT@9..18 "PartialEq"
      COMMA@18..19 ","
      WHITESPACE@19..20 " "
      IDENT@20..22 "Eq"
      COMMA@22..23 ","
      WHITESPACE@23..24 " "
      R_PAREN@24..25 ")"
    ,
    META@2..25
      PATH@2..8
        PATH_SEGMENT@2..8
          NAME_REF@2..8
            IDENT@2..8 "derive"
      TOKEN_TREE@8..25
        L_PAREN@8..9 "("
        IDENT@9..18 "PartialEq"
        COMMA@18..19 ","
        WHITESPACE@19..20 " "
        IDENT@20..22 "Eq"
        COMMA@22..23 ","
        WHITESPACE@23..24 " "
        R_PAREN@24..25 ")"
    ,
    ATTR@0..26
      POUND@0..1 "#"
      L_BRACK@1..2 "["
      META@2..25
        PATH@2..8
          PATH_SEGMENT@2..8
            NAME_REF@2..8
              IDENT@2..8 "derive"
        TOKEN_TREE@8..25
          L_PAREN@8..9 "("
          IDENT@9..18 "PartialEq"
          COMMA@18..19 ","
          WHITESPACE@19..20 " "
          IDENT@20..22 "Eq"
          COMMA@22..23 ","
          WHITESPACE@23..24 " "
          R_PAREN@24..25 ")"
      R_BRACK@25..26 "]"
    ,
    STRUCT@0..39
      ATTR@0..26
        POUND@0..1 "#"
        L_BRACK@1..2 "["
        META@2..25
          PATH@2..8
            PATH_SEGMENT@2..8
              NAME_REF@2..8
                IDENT@2..8 "derive"
          TOKEN_TREE@8..25
            L_PAREN@8..9 "("
            IDENT@9..18 "PartialEq"
            COMMA@18..19 ","
            WHITESPACE@19..20 " "
            IDENT@20..22 "Eq"
            COMMA@22..23 ","
            WHITESPACE@23..24 " "
            R_PAREN@24..25 ")"
        R_BRACK@25..26 "]"
      WHITESPACE@26..27 " "
      STRUCT_KW@27..33 "struct"
      WHITESPACE@33..34 " "
      NAME@34..38
        IDENT@34..38 "Test"
      SEMICOLON@38..39 ";"
...
```
2022-04-18 13:40:18 +00:00
XFFXFF fedd0245d1 derive completions take existing derives into count 2022-04-18 21:34:36 +08:00
bors d1f6b4e2a0 Auto merge of #12023 - edwin0cheng:add-more-log, r=edwin0cheng
internal: more visibility for switch workspaces and its states
2022-04-18 07:13:30 +00:00
Edwin Cheng 72fcc66835 More visibility for switch workspaces and its states 2022-04-18 14:26:00 +08:00
Lukas Wirth ff667c7228 internal: Add a NameContext to CompletionContext, move out some ImmediateLocation variants 2022-04-17 21:53:58 +02:00
bors 65fbe0a8d1 Auto merge of #12017 - lnicola:bump-deps, r=lnicola
minor: Bump deps
2022-04-17 16:36:36 +00:00
Laurențiu Nicola 117f902d55 Bump deps 2022-04-17 19:36:08 +03:00
bors a45a63e577 Auto merge of #12013 - XFFXFF:associated_const_equality, r=Veykril
fix: support `associated_const_equality` in parser

This pr fixes #11965.  The parser now allows eq constraints on associated constants.

I've added tests for `HasCount<Count = {N}>` and `HasCount<Count = 0>`
2022-04-17 13:05:47 +00:00
Arjo Chakravarty f75bad52d7 Update docs link
The current doc link was broken. replaced with the updated version as found on the front page.
2022-04-17 20:32:06 +08:00
XFFXFF 6580d75308 update parser to support associated const equality 2022-04-17 20:26:06 +08:00
bors 9c675d652f Auto merge of #12014 - Veykril:expmacfmt, r=Veykril
feat: Attempt to format expand_macro output with rustfmt if possible

Fixes https://github.com/rust-lang/rust-analyzer/issues/10548
2022-04-17 12:03:27 +00:00
Lukas Wirth 3de9a42810 Disable rustfmt for expand_macro on wasm platforms 2022-04-17 14:00:19 +02:00
Lukas Wirth 895a16265c Fix macro patterns not getting formatted properly 2022-04-17 13:46:00 +02:00
Lukas Wirth e2f1a9a558 feat: Attempt to format expand_macro output with rustfmt if possible 2022-04-17 13:33:39 +02:00
XFFXFF bdecd9374e update grammer to support associated const equality 2022-04-17 12:03:52 +08:00
bors 53afd2a707 Auto merge of #12011 - iDawer:completion_detail.impl_trait, r=Veykril
fix: Show `impl Trait` in argument positon in completion details

Follow up for #11991

`hir`: Use `db.callable_item_signature` query more.
2022-04-16 21:13:07 +00:00
iDawer d26deb5b9f Show impl Trait in argument positon in completion details
`hir`: Use `db.callable_item_signature` query more.
2022-04-16 19:18:42 +05:00