]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agointernal: Remove ide_completion::render::build_ext module
Lukas Wirth [Sat, 12 Mar 2022 15:10:30 +0000 (16:10 +0100)]
internal: Remove ide_completion::render::build_ext module

2 years agoMerge #11687 #11689
bors[bot] [Sat, 12 Mar 2022 13:14:31 +0000 (13:14 +0000)]
Merge #11687 #11689

11687: Highlight escape sequences in byte strings r=Veykril a=yipinliu

#11605

11689: minor: Pad type inlay hints if no colons are requested r=Veykril a=Veykril

bors r+

Co-authored-by: yipinliu <ypliu18@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: Pad type inlay hints if no colons are requested
Lukas Wirth [Sat, 12 Mar 2022 13:08:39 +0000 (14:08 +0100)]
minor: Pad type inlay hints if no colons are requested

2 years agoOptimize imports
yipinliu [Sat, 12 Mar 2022 13:06:33 +0000 (21:06 +0800)]
Optimize imports

2 years agoMerge #11686
bors[bot] [Sat, 12 Mar 2022 13:05:45 +0000 (13:05 +0000)]
Merge #11686

11686: feat: Enum variant field completion, enum variant / struct consistency r=Veykril a=m0rg-dev

This addresses several related inconsistencies:
 - tuple structs use tab stops instead of placeholders
 - tuple structs display in the completion menu as `Struct {…}` instead of `Struct(…)`
 - enum variants don't receive field completions at all
 - enum variants display differently from structs in the completion menu

Also, structs now display their type in the completion detail rather than the raw snippet text to be inserted.

As far as what's user-visible, that looks like this:

| | Menu | Completion | Detail |
|-|-|-|-|
| Record struct (old) | `Struct {…}` | `Struct { x: ${1:()}, y: ${2:()} }$0` | `Struct { x: ${1:()}, y: ${2:()} }$0` |
| Record struct (new) | `Struct {…}` | `Struct { x: ${1:()}, y: ${2:()} }$0` | `Struct { x: i32, y: i32 }` |
| Tuple struct (old) | `Struct {…}`  | `Struct($1, $2)$0` | `Struct($1, $2)` |
| Tuple struct (new) | `Struct(…)` | `Struct(${1:()}, ${2:()})$0` | `Struct(i32, i32)` |
| Unit variant (old) | `Variant` | `Variant` | `()` |
| Unit variant (new) | `Variant` | `Variant$0` | `Variant` |
| Record variant (old) | `Variant` | `Variant` | `{x: i32, y: i32}` |
| Record variant (new) | `Variant {…}` | `Variant { x: ${1:()}, y: ${2:()} }$0` | `Variant { x: i32, y: i32 }` |
| Tuple variant (old) | `Variant(…)` | `Variant($0)` | `(i32, i32)` |
| Tuple variant (new) | `Variant(…)` | `Variant(${1:()}, ${2:()})$0` | `Variant(i32, i32)` |

Additionally, tuple variants no longer set `triggers_call_info` because it conflicts with placeholder generation, and tuple variants that require a qualified path should now use the qualified path.

Internally, this also lets us break the general "format an item with fields on it" code out into a shared module, so that means it'll be a lot easier to implement features like #11568.

Co-authored-by: Morgan Thomas <corp@m0rg.dev>
2 years agoReduce intermediate string allocations in render::compound::render_record and ::rende...
Morgan Thomas [Sat, 12 Mar 2022 13:01:25 +0000 (05:01 -0800)]
Reduce intermediate string allocations in render::compound::render_record and ::render_tuple

2 years agoExtract the code for formatting struct and enum-variant literal labels out into a...
Morgan Thomas [Sat, 12 Mar 2022 12:40:05 +0000 (04:40 -0800)]
Extract the code for formatting struct and enum-variant literal labels out into a common function

2 years agoFixed code style issues
yipinliu [Sat, 12 Mar 2022 12:36:56 +0000 (20:36 +0800)]
Fixed code style issues

2 years agoFixed tidy test
yipinliu [Sat, 12 Mar 2022 12:04:14 +0000 (20:04 +0800)]
Fixed tidy test

2 years agoHighlight escape sequences in byte strings
yipinliu [Sat, 12 Mar 2022 11:00:17 +0000 (19:00 +0800)]
Highlight escape sequences in byte strings

2 years agomake the doc comment on render::compound::visible_fields a little better
Morgan Thomas [Sat, 12 Mar 2022 03:23:04 +0000 (19:23 -0800)]
make the doc comment on render::compound::visible_fields a little better

2 years agovisibility tweak for CI
Morgan Thomas [Sat, 12 Mar 2022 03:10:43 +0000 (19:10 -0800)]
visibility tweak for CI

2 years agoComplete enum variants identically to structures.
Morgan Thomas [Sat, 12 Mar 2022 02:26:01 +0000 (18:26 -0800)]
Complete enum variants identically to structures.

In particular:
 - unit variants now display in the menu as "Variant", complete to "Variant", and display a detail of "Variant" (was "()")
 - tuple variants now display in the menu as "Variant(…)", complete to "Variant(${1:()})$0" (was "Variant($0)"), and display a detail of "Variant(type)" (was "(type)")
 - record variants now display in the menu as "Variant {…}", complete to "Variant { x: ${1:()} }$0" (was "Variant"), and display a detail of "Variant { x: type }" (was "{x: type}")

This behavior is identical to that of struct completions. In addition, tuple variants no longer set triggers_call_info, as to my understanding it's unnecessary now that we're emitting placeholders.

Tests have been updated to match, and the render::enum_variant::tests::inserts_parens_for_tuple_enums test has been removed entirely as it's covered by other tests (render::enum_detail_includes_{record, tuple}_fields, render::enum_detail_just_name_for_unit, render::pattern::enum_qualified).

2 years ago- Break out functionality related to rendering struct completions into `crates/ide_co...
Morgan Thomas [Sat, 12 Mar 2022 01:17:01 +0000 (17:17 -0800)]
- Break out functionality related to rendering struct completions into `crates/ide_completion/src/render/compound.rs`
- Add support for placeholder completions in tuple structs
- Denote tuple struct completions with `(…)` instead of ` {…}`
- Show struct completions as their type (`Struct { field: Type }`) in the completion menu instead of raw snippet text (`Struct { field: ${1:()} }$0`)

2 years agoMerge #11685
bors[bot] [Sat, 12 Mar 2022 01:15:21 +0000 (01:15 +0000)]
Merge #11685

11685: internal: Simplify CompletionContext r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRemove no_completions_required from CompletionContext
Lukas Wirth [Sat, 12 Mar 2022 00:59:01 +0000 (01:59 +0100)]
Remove no_completions_required from CompletionContext

2 years agoMerge #11684
bors[bot] [Sat, 12 Mar 2022 00:44:39 +0000 (00:44 +0000)]
Merge #11684

11684: fix: Allow configuration of colons in inlay-hints r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: add missing definitions of lsp_ext::InlayHintLabel
Lukas Wirth [Fri, 11 Mar 2022 21:36:58 +0000 (22:36 +0100)]
minor: add missing definitions of lsp_ext::InlayHintLabel

2 years agoMerge #11683
bors[bot] [Fri, 11 Mar 2022 23:31:24 +0000 (23:31 +0000)]
Merge #11683

11683: fix: Stop wrapping ConstParam's default values in ConstArg r=Veykril a=steven-joruk

I came across this problem while implementing the assist for inlining type aliases. This was causing `ConstParam::default_val` to always return `None` for block expressions. The `const_arg_path` test was actually testing const params so I've updated that.

The only code that uses `default_val` right now is  the `extract_function` assist. I couldn't figure out how to hit the affected code path, if someone can give me hint I'll add a test.

This test in my WIP branch fails without this:
```rust
    #[test]
    fn param_expression() {
        check_assist(
            inline_type_alias,
            r#"
type A<const N: usize = { 1 }> = [u32; N];
fn main() {
    let a: $0A;
}
"#,
            r#"
type A<const N: usize = { 1 }> = [u32; N];
fn main() {
    let a: [u32; { 1 }];
}
"#,
        );
    }
```

Co-authored-by: Steven Joruk <steven@joruk.com>
2 years agorefactor: Rename and move const_arg_path
Steven Joruk [Fri, 11 Mar 2022 21:44:18 +0000 (21:44 +0000)]
refactor: Rename and move const_arg_path

It wasn't testing the `const_arg` code path, it was actually hitting
const_param's default value code path, so move it to the right place
and rename it.

2 years agorefactor: Rename const_arg_content to const_arg_expr
Steven Joruk [Fri, 11 Mar 2022 20:38:03 +0000 (20:38 +0000)]
refactor: Rename const_arg_content to const_arg_expr

2 years agofix: Allow configuration of colons in inlay-hints
Lukas Wirth [Fri, 11 Mar 2022 20:06:26 +0000 (21:06 +0100)]
fix: Allow configuration of colons in inlay-hints

2 years agofix: Stop wrapping ConstParam's default values in ConstArg
Steven Joruk [Fri, 11 Mar 2022 19:22:49 +0000 (19:22 +0000)]
fix: Stop wrapping ConstParam's default values in ConstArg

This was causing ConstParam::default_val to always return None for block
expressions.

CONST_ARG@24..29
  BLOCK_EXPR@24..29
    ...

2 years agoMerge #11680
bors[bot] [Fri, 11 Mar 2022 16:17:59 +0000 (16:17 +0000)]
Merge #11680

11680: fix: Show what file paths were expected for unresolved modules r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Show what file paths were expected for unresolved modules
Lukas Wirth [Fri, 11 Mar 2022 15:49:41 +0000 (16:49 +0100)]
fix: Show what file paths were expected for unresolved modules

2 years agoMerge #11676
bors[bot] [Thu, 10 Mar 2022 21:24:11 +0000 (21:24 +0000)]
Merge #11676

11676: internal: Expand into pseudo-derive attribute expansions in completions r=Veykril a=Veykril

With this we now properly handle qualified path completions in derives
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoDon't parse source files to generate macro completion details
Lukas Wirth [Thu, 10 Mar 2022 21:21:58 +0000 (22:21 +0100)]
Don't parse source files to generate macro completion details

2 years agoEnable qualifier completions for derives
Lukas Wirth [Thu, 10 Mar 2022 20:56:19 +0000 (21:56 +0100)]
Enable qualifier completions for derives

2 years agoDon't offer qualified path completions for buitlin derives
Lukas Wirth [Thu, 10 Mar 2022 20:22:13 +0000 (21:22 +0100)]
Don't offer qualified path completions for buitlin derives

2 years agoExpand into pseudo-derive attribute expansions in completions
Lukas Wirth [Thu, 10 Mar 2022 19:53:50 +0000 (20:53 +0100)]
Expand into pseudo-derive attribute expansions in completions

2 years agoMerge #11672
bors[bot] [Thu, 10 Mar 2022 17:24:36 +0000 (17:24 +0000)]
Merge #11672

11672: Add support for new `where` clause location in associated types. r=Veykril a=Dirbaio

A recent Rust nightly changed it: https://github.com/rust-lang/rust/issues/89122

This allows both the old and new location.

Fixes #11651

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2 years agoAdd support for new `where` clause location in associated types.
Dario Nieuwenhuis [Thu, 10 Mar 2022 17:10:03 +0000 (18:10 +0100)]
Add support for new `where` clause location in associated types.

A recent Rust nightly changed it: https://github.com/rust-lang/rust/issues/89122

This allows both the old and new location.

2 years agoMerge #11671
bors[bot] [Thu, 10 Mar 2022 16:15:12 +0000 (16:15 +0000)]
Merge #11671

11671: minor: Access parser internals through ide_db for ide crates r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: Access parser internals through ide_db for ide crates
Lukas Wirth [Thu, 10 Mar 2022 16:07:11 +0000 (17:07 +0100)]
minor: Access parser internals through ide_db for ide crates

2 years agoMerge #11662
bors[bot] [Thu, 10 Mar 2022 15:49:03 +0000 (15:49 +0000)]
Merge #11662

11662: fix: extract_module selection inside impl r=Veykril a=feniljain

Should close: #11508

From issue:
Concern 1: Seems to be fixed in latest `rust-analyzer` build
Concern 2 and 3: Should be fixed by this PR
Concern 4: Got fixed in #11472

Points to note:

- Here I have seperated use items and other items, this is becuase the new `impl` block which we will be creating cannot contain use items as immediate children. As they are the only one item that can be generated by our assist, so seperating them helps in handling their inclusion in new `impl` block inside new `module`

- There's also a new method added which helps in removing remaning left over indentation after removing `impl` or other `item`

Co-authored-by: vi_mi <fkjainco@gmail.com>
2 years agoMerge #11664
bors[bot] [Wed, 9 Mar 2022 21:45:42 +0000 (21:45 +0000)]
Merge #11664

11664: fix: Properly handle proc-macro crate types for nameres r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUpdate project_model test outputs
Lukas Wirth [Wed, 9 Mar 2022 21:34:42 +0000 (22:34 +0100)]
Update project_model test outputs

2 years agoSpecific proc-macro crate type for other test fixture where needed
Lukas Wirth [Wed, 9 Mar 2022 21:18:09 +0000 (22:18 +0100)]
Specific proc-macro crate type for other test fixture where needed

2 years agoMerge #11660
bors[bot] [Wed, 9 Mar 2022 17:18:03 +0000 (17:18 +0000)]
Merge #11660

11660: Insert dummy values for const generics in subst r=flodiebold a=HKalbasi

fix #11659

This is a band-aid until proper const generic support.

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2 years agoSpecify proc-macro crate type for proc-macro hir_def test fixtures
Lukas Wirth [Wed, 9 Mar 2022 14:36:05 +0000 (15:36 +0100)]
Specify proc-macro crate type for proc-macro hir_def test fixtures

2 years agofix: Properly handle proc-macro crate types for nameres
Lukas Wirth [Wed, 9 Mar 2022 13:33:39 +0000 (14:33 +0100)]
fix: Properly handle proc-macro crate types for nameres

2 years agoMerge #11663
bors[bot] [Wed, 9 Mar 2022 10:26:34 +0000 (10:26 +0000)]
Merge #11663

11663: Internal: Add hir_def::MacroId, add Macro{Id} to ModuleDef{Id} r=Veykril a=Veykril

With this we can now handle macros like we handle ModuleDefs making them work more like other definitions and allowing us to remove a bunch of special cases. This also enables us to track the modules these macros are defined in, instead of only recording the crate they come from.

Introduces a new class of `MacroId`s (for each of the 3 macro kinds) into `hir_def`. We can't reuse `MacroDefId` as that is defined in `hir_expand` which doesn't know of modules, so now we have two different macro ids, this unfortunately requires some back and forth mapping between the two via database accesses which I hope won't be too expensive.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Wed, 9 Mar 2022 10:26:06 +0000 (11:26 +0100)]
Simplify

2 years agoDisable one of the failing SSR test cases
Lukas Wirth [Wed, 9 Mar 2022 01:08:44 +0000 (02:08 +0100)]
Disable one of the failing SSR test cases

2 years agofix symbol index collection not collecting legacy macros
Lukas Wirth [Wed, 9 Mar 2022 00:44:20 +0000 (01:44 +0100)]
fix symbol index collection not collecting legacy macros

2 years agoFix ProcMacroData recording wrong name for derives
Lukas Wirth [Wed, 9 Mar 2022 00:13:38 +0000 (01:13 +0100)]
Fix ProcMacroData recording wrong name for derives

2 years agoAdd data queries for macros
Lukas Wirth [Tue, 8 Mar 2022 23:41:54 +0000 (00:41 +0100)]
Add data queries for macros

2 years agoRemove unnecessary macro_declarations from ItemScope
Lukas Wirth [Tue, 8 Mar 2022 23:19:53 +0000 (00:19 +0100)]
Remove unnecessary macro_declarations from ItemScope

2 years agoOnly store derive<->derive-helper mapping in DefMap
Lukas Wirth [Tue, 8 Mar 2022 23:01:19 +0000 (00:01 +0100)]
Only store derive<->derive-helper mapping in DefMap

2 years agoMove ide crates to new hir::Macro
Lukas Wirth [Tue, 8 Mar 2022 22:52:26 +0000 (23:52 +0100)]
Move ide crates to new hir::Macro

2 years agoMove hir to new MacroId
Lukas Wirth [Tue, 8 Mar 2022 22:51:48 +0000 (23:51 +0100)]
Move hir to new MacroId

2 years agoRename MacroDef to Macro
Lukas Wirth [Tue, 8 Mar 2022 22:51:19 +0000 (23:51 +0100)]
Rename MacroDef to Macro

2 years agoinsert dummy values for const generics in subst
hkalbasi [Tue, 8 Mar 2022 16:21:35 +0000 (19:51 +0330)]
insert dummy values for const generics in subst

2 years agoAdd MacroId to hir_def in attempt to unify Macros with ModuleDefId
Lukas Wirth [Tue, 8 Mar 2022 20:41:19 +0000 (21:41 +0100)]
Add MacroId to hir_def in attempt to unify Macros with ModuleDefId

2 years agofix: extract_module selection inside impl
vi_mi [Tue, 8 Mar 2022 19:54:07 +0000 (01:24 +0530)]
fix: extract_module selection inside impl

2 years agoMerge #11658
bors[bot] [Tue, 8 Mar 2022 10:31:54 +0000 (10:31 +0000)]
Merge #11658

11658: Add back colons around inlay hints r=Veykril a=lnicola

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/2797#issuecomment-1061594139.

I originally thought that other extensions don't include the colons, but the TypeScript one seems to do.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAdd back colons around inlay hints
Laurențiu Nicola [Tue, 8 Mar 2022 10:01:02 +0000 (12:01 +0200)]
Add back colons around inlay hints

2 years agoMerge #11656
bors[bot] [Tue, 8 Mar 2022 06:34:49 +0000 (06:34 +0000)]
Merge #11656

11656: Fix package.json key replacement r=lnicola a=lnicola

CC #11653

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoFix package.json replacement
Laurențiu Nicola [Tue, 8 Mar 2022 06:34:03 +0000 (08:34 +0200)]
Fix package.json replacement

2 years agoMerge #11653
bors[bot] [Tue, 8 Mar 2022 01:33:18 +0000 (01:33 +0000)]
Merge #11653

11653: fix: client distribution string replacement looking for wrong key r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/pull/11445
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: client distribution string replacement looking for wrong key
Lukas Wirth [Tue, 8 Mar 2022 01:32:35 +0000 (02:32 +0100)]
fix: client distribution string replacement looking for wrong key

2 years agoMerge #11647
bors[bot] [Mon, 7 Mar 2022 17:19:43 +0000 (17:19 +0000)]
Merge #11647

11647: Improve inlay hint padding r=lnicola a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoImprove inlay hint padding
Laurențiu Nicola [Mon, 7 Mar 2022 17:18:36 +0000 (19:18 +0200)]
Improve inlay hint padding

2 years agoMerge #11445
bors[bot] [Mon, 7 Mar 2022 16:49:12 +0000 (16:49 +0000)]
Merge #11445

11445: Upstream inlay hints r=lnicola a=lnicola

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2797
Closes https://github.com/rust-analyzer/rust-analyzer/issues/3394 (since now resolve the hints for the range given only, not for the whole document. We don't actually resolve anything due to [hard requirement](https://github.com/rust-analyzer/rust-analyzer/pull/11445#issuecomment-1035227434) on label being immutable. Any further heavy actions could go to the `resolve` method that's now available via the official Code API for hints)

Based on `@SomeoneToIgnore's` branch, with a couple of updates:

 - I squashed, more or less successfully, the commits on that branch
 - downloading the `.d.ts` no longer works, but you can get it manually from https://raw.githubusercontent.com/microsoft/vscode/release/1.64/src/vscode-dts/vscode.proposed.inlayHints.d.ts
 - you might need to pass `--enable-proposed-api matklad.rust-analyzer`
 - if I'm reading the definition right, `InlayHintKind` needs to be serialized as a number, not string
 - this doesn't work anyway -- the client-side gets the hints, but they don't display

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAdd inlayHints cap
Laurențiu Nicola [Mon, 7 Mar 2022 16:48:27 +0000 (18:48 +0200)]
Add inlayHints cap

2 years agoAdd missing parameter
Laurențiu Nicola [Mon, 7 Mar 2022 13:42:20 +0000 (15:42 +0200)]
Add missing parameter

2 years agoFix parameter hint position
Laurențiu Nicola [Mon, 7 Mar 2022 13:24:54 +0000 (15:24 +0200)]
Fix parameter hint position

2 years agoBump esbuild
Laurențiu Nicola [Mon, 7 Mar 2022 13:22:13 +0000 (15:22 +0200)]
Bump esbuild

2 years agoUpdate LSP docs
Laurențiu Nicola [Fri, 4 Mar 2022 06:26:44 +0000 (08:26 +0200)]
Update LSP docs

2 years agoMerge #11645
bors[bot] [Mon, 7 Mar 2022 11:24:52 +0000 (11:24 +0000)]
Merge #11645

11645: Update manual.adoc r=lnicola a=vi

Resolves #11507

Co-authored-by: Vitaly Shukela <vi0oss@gmail.com>
2 years agoUpdate manual.adoc
Vitaly Shukela [Mon, 7 Mar 2022 11:22:07 +0000 (14:22 +0300)]
Update manual.adoc

Resolves #11507

2 years agoMerge #11644
bors[bot] [Mon, 7 Mar 2022 10:05:31 +0000 (10:05 +0000)]
Merge #11644

11644: Emit more detailed highlighting for `%`, `>>`, `<<` r=Veykril a=arzg

These are currently just given `operator`, when `%` can be grouped under `arithmetic`, and `>>` and `<<` can be grouped under `bitwise`.

Co-authored-by: Luna Razzaghipour <aramisnoah@gmail.com>
2 years agoEmit more detailed highlighting for `%`, `>>`, `<<`
Luna Razzaghipour [Mon, 7 Mar 2022 09:16:03 +0000 (20:16 +1100)]
Emit more detailed highlighting for `%`, `>>`, `<<`

2 years agoMerge #11639
bors[bot] [Sun, 6 Mar 2022 18:31:30 +0000 (18:31 +0000)]
Merge #11639

11639: internal: Re-arrange ide_db modules r=Veykril a=Veykril

Thins out the `helpers` module by giving some items more appropriate places to live
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUpdate tidy ignore list
Lukas Wirth [Sun, 6 Mar 2022 18:11:05 +0000 (19:11 +0100)]
Update tidy ignore list

2 years agointernal: Re-arrange ide_db modules
Lukas Wirth [Sun, 6 Mar 2022 18:01:30 +0000 (19:01 +0100)]
internal: Re-arrange ide_db modules

2 years agoMerge #11637
bors[bot] [Sun, 6 Mar 2022 16:56:29 +0000 (16:56 +0000)]
Merge #11637

11637: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: Simplify
Lukas Wirth [Sun, 6 Mar 2022 16:56:02 +0000 (17:56 +0100)]
minor: Simplify

2 years agoMerge #11633
bors[bot] [Sun, 6 Mar 2022 12:22:35 +0000 (12:22 +0000)]
Merge #11633

11633: Automatically change text color in logo based on dark mode r=Veykril a=arzg

Currently the black text in the logo in the README just has a white stroke so it’s readable in dark mode. This PR adds automatic detection of whether the user is using system dark mode, and if they are changes the text colour to white and removes the stroke.

Before:

<img width="910" alt="Screen Shot 2022-03-06 at 10 54 35 pm" src="https://user-images.githubusercontent.com/31783266/156921920-7ac88aa4-bab6-44c2-be37-30338a2d9ec9.png">

After (now in Chrome because this doesn’t seem to work in Safari):

<img width="822" alt="Screen Shot 2022-03-06 at 11 10 12 pm" src="https://user-images.githubusercontent.com/31783266/156922615-41fe63e0-7901-4cb1-a229-6d37b6e4369a.png">
<img width="820" alt="Screen Shot 2022-03-06 at 11 10 25 pm" src="https://user-images.githubusercontent.com/31783266/156922619-1bdd5b9c-89ac-4fe1-bf17-1a1ac4ead805.png">

Co-authored-by: Luna Razzaghipour <aramisnoah@gmail.com>
2 years agoAutomatically change text color in logo based on dark mode
Luna Razzaghipour [Sun, 6 Mar 2022 11:53:52 +0000 (22:53 +1100)]
Automatically change text color in logo based on dark mode

2 years agoMerge #11632
bors[bot] [Sun, 6 Mar 2022 08:44:54 +0000 (08:44 +0000)]
Merge #11632

11632: Bring back syntax highlighting in test data r=matklad a=matklad

cc #11597

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoBring back syntax highlighting in test data
Aleksey Kladov [Sun, 6 Mar 2022 08:42:17 +0000 (08:42 +0000)]
Bring back syntax highlighting in test data

cc #11597

2 years agoMerge #11631
bors[bot] [Sun, 6 Mar 2022 03:19:54 +0000 (03:19 +0000)]
Merge #11631

11631: internal: Refactor syntax_highlighting r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agointernal: Simplify and optimize syntax_highlighting
Lukas Wirth [Sun, 6 Mar 2022 02:49:54 +0000 (03:49 +0100)]
internal: Simplify and optimize syntax_highlighting

2 years agoMerge #11630
bors[bot] [Sat, 5 Mar 2022 23:48:54 +0000 (23:48 +0000)]
Merge #11630

11630: fix: Recognize `Self` as a proper keyword r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11627

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoAdd a macro case for the keyword highlighting test fixture
Lukas Wirth [Sat, 5 Mar 2022 23:26:15 +0000 (00:26 +0100)]
Add a macro case for the keyword highlighting test fixture

2 years agoFix extern crate self having self unresolved
Lukas Wirth [Sat, 5 Mar 2022 23:17:40 +0000 (00:17 +0100)]
Fix extern crate self having self unresolved

2 years agoHighlight `Self` as a keyword by default
Lukas Wirth [Sat, 5 Mar 2022 23:12:10 +0000 (00:12 +0100)]
Highlight `Self` as a keyword by default

2 years agoSimplify
Lukas Wirth [Sat, 5 Mar 2022 22:53:24 +0000 (23:53 +0100)]
Simplify

2 years agoFix hover for `Self` keyword
Lukas Wirth [Sat, 5 Mar 2022 22:47:44 +0000 (23:47 +0100)]
Fix hover for `Self` keyword

2 years agoMerge #11629
bors[bot] [Sat, 5 Mar 2022 22:34:59 +0000 (22:34 +0000)]
Merge #11629

11629: fix: Fix macro-calls expanding to items in if/while conditions r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11617

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoFix highlighting of `Self`
Lukas Wirth [Sat, 5 Mar 2022 22:34:37 +0000 (23:34 +0100)]
Fix highlighting of `Self`

2 years agoFix test fixture
Lukas Wirth [Sat, 5 Mar 2022 21:44:49 +0000 (22:44 +0100)]
Fix test fixture

2 years agofix: Recognize `Self` as a proper keyword
Lukas Wirth [Sat, 5 Mar 2022 22:20:06 +0000 (23:20 +0100)]
fix: Recognize `Self` as a proper keyword

2 years agofix macro-calls always expanding to expressions in LetStmt
Lukas Wirth [Sat, 5 Mar 2022 21:04:06 +0000 (22:04 +0100)]
fix macro-calls always expanding to expressions in LetStmt

2 years agofix: Fix macro-calls expanding to items in if/while conditions
Lukas Wirth [Sat, 5 Mar 2022 20:58:51 +0000 (21:58 +0100)]
fix: Fix macro-calls expanding to items in if/while conditions

2 years agoMerge #11598
bors[bot] [Sat, 5 Mar 2022 11:31:29 +0000 (11:31 +0000)]
Merge #11598

11598: feat: Parse destructuring assignment r=Veykril a=ChayimFriedman2

Part of #11532.

Lowering is not as easy and may not even be feasible right now as it requires generating identifiers: `(a, b) = (b, a)` is desugared into
```rust
{
    let (<gensym_a>, <gensym_b>) = (b, a);
    a = <gensym_a>;
    b = <gensym_b>;
}
```

rustc uses hygiene to implement that, but we don't support hygiene yet.

However, I think parsing was the main problem as lowering will just affect type inference, and while `{unknown}` is not nice it's much better than a syntax error.

I'm still looking for the best way to do lowering, though.

Fixes #11454.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoMerge #11574
bors[bot] [Sat, 5 Mar 2022 11:20:05 +0000 (11:20 +0000)]
Merge #11574

11574: Small refactor text edit 2nd r=Veykril a=HansAuger

Some more changes to text_edit. Basic idea is to make `Indel` implement `PartialOrd` to take advantage of some sweet sweet iteration, most notably itertool's `merge`.

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agoMerge #11623
bors[bot] [Sat, 5 Mar 2022 10:32:07 +0000 (10:32 +0000)]
Merge #11623

11623: fix: Add type variable table to InferenceTableSnapshot r=flodiebold a=tysg

Fixes #11601.

I observed that removing the `rollback` line in https://github.com/rust-analyzer/rust-analyzer/commit/6fc3d3aa4cbf637d748c60cfdbb98b5f6a040576 fixes the issue.

Looking at the stacktrace, I believe not restoring `type_variable_table` causes `type_variable_table` and `var_unification_table` to go out of sync, then when `hir_ty::infer::unify::InferenceTable::new_var` tries to extend `type_variable_table` to be the same length as `var_unification_table`, problems will arise.

However, I cannot pinpoint exactly how or where the vector capacity overflow happens, so my understanding might not be correct after all.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
2 years agoAdd type variable table to InferenceTableSnapshot
Tianyi Song [Sat, 5 Mar 2022 09:59:28 +0000 (17:59 +0800)]
Add type variable table to InferenceTableSnapshot