]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoMerge #11713
bors[bot] [Fri, 18 Mar 2022 13:54:09 +0000 (13:54 +0000)]
Merge #11713

11713: Complete associated consts in patterns  r=jonas-schievink a=hi-rustin

Try close https://github.com/rust-analyzer/rust-analyzer/issues/11555

Co-authored-by: hi-rustin <rustin.liu@gmail.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoUpdate crates/ide_completion/src/tests/pattern.rs
Jonas Schievink [Fri, 18 Mar 2022 13:53:44 +0000 (14:53 +0100)]
Update crates/ide_completion/src/tests/pattern.rs

2 years agoMerge #11750
bors[bot] [Fri, 18 Mar 2022 11:13:37 +0000 (11:13 +0000)]
Merge #11750

11750: fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11746
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix runnables trying to add doc tests in the crate root from #[macro_export...
Lukas Wirth [Fri, 18 Mar 2022 10:55:53 +0000 (11:55 +0100)]
fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros

2 years agoMerge #11747
bors[bot] [Fri, 18 Mar 2022 07:19:42 +0000 (07:19 +0000)]
Merge #11747

11747: minor: Remove Update GitHub API token command r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoRemove Update GitHub API token command
Laurențiu Nicola [Fri, 18 Mar 2022 07:19:02 +0000 (09:19 +0200)]
Remove Update GitHub API token command

2 years agoMerge #11744
bors[bot] [Thu, 17 Mar 2022 17:25:07 +0000 (17:25 +0000)]
Merge #11744

11744: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump deps
Laurențiu Nicola [Thu, 17 Mar 2022 17:10:45 +0000 (19:10 +0200)]
Bump deps

2 years agoMerge #11743
bors[bot] [Thu, 17 Mar 2022 16:28:21 +0000 (16:28 +0000)]
Merge #11743

11743: fix: Properly unify receivers during method resolution r=flodiebold a=flodiebold

This fixes our type inference problems with `DynMap`; the problem there were the projection types in
```rust
impl<P: Policy> KeyMap<Key<P::K, P::V, P>>
```
which messed up the naive type equality check we did. It also actually simplifies the logic though, IMO. I also added a fix for associated const resolution that I noticed (visibility not being taken into account).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoMove fallback_bound_vars to the only place it's used now
Florian Diebold [Thu, 17 Mar 2022 16:08:43 +0000 (17:08 +0100)]
Move fallback_bound_vars to the only place it's used now

2 years agoFixes for consts
Florian Diebold [Thu, 17 Mar 2022 16:02:58 +0000 (17:02 +0100)]
Fixes for consts

2 years agoSnapshot obligations
Florian Diebold [Thu, 17 Mar 2022 13:29:39 +0000 (14:29 +0100)]
Snapshot obligations

2 years agoProperly try unifying the receivers during method resolution
Florian Diebold [Thu, 17 Mar 2022 11:39:42 +0000 (12:39 +0100)]
Properly try unifying the receivers during method resolution

Instead of hackily checking if they're equal.

2 years agoFix typo
hi-rustin [Thu, 17 Mar 2022 14:59:47 +0000 (22:59 +0800)]
Fix typo

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAdd test for DynMap type inference
Florian Diebold [Sun, 13 Mar 2022 15:25:03 +0000 (16:25 +0100)]
Add test for DynMap type inference

2 years agoMatch the enum and union
hi-rustin [Thu, 17 Mar 2022 13:18:52 +0000 (21:18 +0800)]
Match the enum and union

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoMerge #11741
bors[bot] [Thu, 17 Mar 2022 13:23:22 +0000 (13:23 +0000)]
Merge #11741

11741: Emit #[must_use] in Generate enum is_variant assist r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMerge #11740
bors[bot] [Thu, 17 Mar 2022 13:14:26 +0000 (13:14 +0000)]
Merge #11740

11740: Insert #[must_use] in generate_is_empty_from_len r=lnicola a=Walther

Inserts `#[must_use]` for the generated `is_empty` methods. I also added the `#[must_use]` for the `len()` methods in the documentation examples and tests for this generator while at it, to make sure they too encourage the use of the annotation.

From discussion in https://github.com/rust-analyzer/rust-analyzer/issues/11736 and https://github.com/rust-analyzer/rust-analyzer/pull/11738

Co-authored-by: Walther <veeti.haapsamo@gmail.com>
2 years agoEmit #[must_use] in Generate enum is_variant assist
Laurențiu Nicola [Thu, 17 Mar 2022 13:10:25 +0000 (15:10 +0200)]
Emit #[must_use] in Generate enum is_variant assist

2 years agoInsert #[must_use] in generate_is_empty_from_len
Walther [Thu, 17 Mar 2022 13:03:02 +0000 (15:03 +0200)]
Insert #[must_use] in generate_is_empty_from_len

2 years agoMerge #11737 #11739
bors[bot] [Thu, 17 Mar 2022 12:58:14 +0000 (12:58 +0000)]
Merge #11737 #11739

11737: Emit `#[must_use]` in `Generate new` assist r=lnicola a=lnicola

Closes #11736

11739: Insert #[must_use] in generate_getter r=lnicola a=Walther

Inserts `#[must_use]` for the generated getter methods.

From discussion in https://github.com/rust-analyzer/rust-analyzer/issues/11736 and https://github.com/rust-analyzer/rust-analyzer/pull/11738

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Walther <veeti.haapsamo@gmail.com>
2 years agoInsert #[must_use] in generate_getter
Walther [Thu, 17 Mar 2022 12:49:22 +0000 (14:49 +0200)]
Insert #[must_use] in generate_getter

2 years agoFix the wrong path resolution
hi-rustin [Wed, 16 Mar 2022 12:54:01 +0000 (20:54 +0800)]
Fix the wrong path resolution

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAdd completes_associated_const test
hi-rustin [Tue, 15 Mar 2022 13:54:45 +0000 (21:54 +0800)]
Add completes_associated_const test

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoComplete associated consts in patterns
hi-rustin [Tue, 15 Mar 2022 13:14:02 +0000 (21:14 +0800)]
Complete associated consts in patterns

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoEmit #[must_use] in Generate new assist
Laurențiu Nicola [Thu, 17 Mar 2022 12:11:29 +0000 (14:11 +0200)]
Emit #[must_use] in Generate new assist

2 years agoMerge #11735
bors[bot] [Thu, 17 Mar 2022 09:23:26 +0000 (09:23 +0000)]
Merge #11735

11735: Fix const generic panic, again r=lnicola a=HKalbasi

fix https://github.com/rust-analyzer/rust-analyzer/pull/11734#issuecomment-1070526085

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2 years agofix regression_11688_2
hkalbasi [Thu, 17 Mar 2022 09:15:04 +0000 (12:45 +0330)]
fix regression_11688_2

2 years agoMerge #11734
bors[bot] [Thu, 17 Mar 2022 06:54:27 +0000 (06:54 +0000)]
Merge #11734

11734: internal: Bump `xshell` and fix `dist` r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump xshell and fix dist
Laurențiu Nicola [Thu, 17 Mar 2022 06:53:33 +0000 (08:53 +0200)]
Bump xshell and fix dist

2 years agoMerge #11731
bors[bot] [Wed, 16 Mar 2022 20:31:47 +0000 (20:31 +0000)]
Merge #11731

11731: feat: Add return type hints for closures with block bodies r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11386
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofeat: Add return type hints for closures with block bodies
Lukas Wirth [Wed, 16 Mar 2022 20:16:55 +0000 (21:16 +0100)]
feat: Add return type hints for closures with block bodies

2 years agoMerge #11727
bors[bot] [Wed, 16 Mar 2022 19:56:31 +0000 (19:56 +0000)]
Merge #11727

11727: minor: Fix metrics.json path r=lnicola a=lnicola

CC https://github.com/rust-analyzer/rust-analyzer/pull/11724#issuecomment-1069047929

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoFix metrics.json path
Laurențiu Nicola [Wed, 16 Mar 2022 16:15:44 +0000 (18:15 +0200)]
Fix metrics.json path

2 years agoMerge #11694
bors[bot] [Wed, 16 Mar 2022 16:35:34 +0000 (16:35 +0000)]
Merge #11694

11694: fix: "Extract to function" assist preserves `break` and `continue` labels r=Veykril a=m0rg-dev

Adds a label / lifetime parameter to `ide_assists::handlers::extract_function::FlowKind::{Break, Continue}`, adds support for emitting labels to `syntax::ast::make::{expr_break, expr_continue}`, and implements the required machinery to let `extract_function` make use of them.

This does modify the external API of the `syntax` crate, but the changes there are simple, not used outside `ide_assists`, and, well, we should probably support emitting `break` and `continue` labels through `syntax` anyways, they're part of the language spec.

Closes #11413.

Co-authored-by: Morgan Thomas <corp@m0rg.dev>
2 years agoMerge #11726
bors[bot] [Wed, 16 Mar 2022 16:04:10 +0000 (16:04 +0000)]
Merge #11726

11726: internal: More ide_completion refactoring r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRevert omitting field completions
Lukas Wirth [Wed, 16 Mar 2022 15:41:35 +0000 (16:41 +0100)]
Revert omitting field completions

2 years agoRemove code duplication
Lukas Wirth [Wed, 16 Mar 2022 15:32:36 +0000 (16:32 +0100)]
Remove code duplication

2 years agoSimplify completion render functionality
Lukas Wirth [Wed, 16 Mar 2022 15:27:55 +0000 (16:27 +0100)]
Simplify completion render functionality

2 years agoRename compound things to variant things
Lukas Wirth [Wed, 16 Mar 2022 12:41:35 +0000 (13:41 +0100)]
Rename compound things to variant things

2 years agoMerge #11724
bors[bot] [Wed, 16 Mar 2022 11:12:09 +0000 (11:12 +0000)]
Merge #11724

11724: minor: unblock metrics r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: unblock metrics
Lukas Wirth [Wed, 16 Mar 2022 11:11:21 +0000 (12:11 +0100)]
minor: unblock metrics

2 years agoMerge #11720
bors[bot] [Wed, 16 Mar 2022 06:32:33 +0000 (06:32 +0000)]
Merge #11720

11720: fix: Mark chaining hints as types r=SomeoneToIgnore a=lnicola

CC https://github.com/rust-analyzer/rust-analyzer/pull/11445#discussion_r826863321

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMark chaining hints as types, since that's what they are
Laurențiu Nicola [Wed, 16 Mar 2022 05:46:09 +0000 (07:46 +0200)]
Mark chaining hints as types, since that's what they are

2 years agoMerge #11718
bors[bot] [Tue, 15 Mar 2022 20:27:51 +0000 (20:27 +0000)]
Merge #11718

11718: Fix const generic panic r=lnicola a=HKalbasi

fix https://github.com/rust-analyzer/rust-analyzer/pull/11688#issuecomment-1066824954

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2 years agofix const generic panic
hkalbasi [Tue, 15 Mar 2022 19:04:05 +0000 (22:34 +0330)]
fix const generic panic

2 years agoMerge #11708
bors[bot] [Tue, 15 Mar 2022 18:05:27 +0000 (18:05 +0000)]
Merge #11708

11708: Update manual for inlay hint customization r=Veykril a=ian-h-chamberlain

Related to #6405, #6883 but not sure if they should be closed or not as this is just a documentation update.

This functionality was changed as of #11445 and now can be customized using native VSCode settings instead of `rust-analyzer`-specific ones.

Co-authored-by: Ian Chamberlain <ian-h-chamberlain@users.noreply.github.com>
2 years agoMerge #11714
bors[bot] [Tue, 15 Mar 2022 17:58:21 +0000 (17:58 +0000)]
Merge #11714

11714: fix: Fix completions not always working in for-loop patterns r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11205
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix completions not always working in for-loop patterns
Lukas Wirth [Tue, 15 Mar 2022 17:06:34 +0000 (18:06 +0100)]
fix: Fix completions not always working in for-loop patterns

2 years agoMerge #11710
bors[bot] [Tue, 15 Mar 2022 07:27:05 +0000 (07:27 +0000)]
Merge #11710

11710:  editors/code: fix crash due to missing ID= field r=lnicola a=cab404

Assuming ID=linux by default.
Also removed toLowerCase — it really shouldn't be needed.
Fixes #11709

Co-authored-by: Vladimir Serov <me@cab404.ru>
2 years agoeditors/code: fix crash due to missing ID= field
Vladimir Serov [Tue, 15 Mar 2022 03:52:03 +0000 (06:52 +0300)]
editors/code: fix crash due to missing ID= field

Assuming ID=linux in isNixOs by default. You can get away with
default "", but why do that if there's a default value in spec?)

Also removed toLowerCase — it really shouldn't be needed.
Fixes #11709

2 years agoUpdate manual for inlay hint customization
Ian Chamberlain [Mon, 14 Mar 2022 21:21:36 +0000 (17:21 -0400)]
Update manual for inlay hint customization

Closes #6883

This functionality was changed as of #11445 and now can be customized using native VSCode settings instead of `rust-analyzer`-specific ones.

2 years agoMerge #11707
bors[bot] [Mon, 14 Mar 2022 20:05:46 +0000 (20:05 +0000)]
Merge #11707

11707: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Mon, 14 Mar 2022 19:36:35 +0000 (20:36 +0100)]
Simplify

2 years agoMerge #11700
bors[bot] [Mon, 14 Mar 2022 15:02:34 +0000 (15:02 +0000)]
Merge #11700

11700: :arrow_up: xshell r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years ago:arrow_up: xshell
Aleksey Kladov [Sun, 13 Mar 2022 21:20:51 +0000 (21:20 +0000)]
:arrow_up: xshell

2 years agoMerge #11688
bors[bot] [Mon, 14 Mar 2022 11:15:00 +0000 (11:15 +0000)]
Merge #11688

11688: Add const generics r=HKalbasi a=HKalbasi

#7434 is not in this PR, so there is no evaluation of constants and no default const argument. But the rest (type inference and method resolution with chalk) should work.

Chalk is pedantic about kind of generic arguments, and will panic in case of mixing type and const arguments. I tried to add test that, but I'm not sure if it covers all cases.

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2 years agoAdd const generics
hkalbasi [Wed, 9 Mar 2022 18:50:24 +0000 (22:20 +0330)]
Add const generics

2 years agoMerge #11696
bors[bot] [Sun, 13 Mar 2022 09:25:55 +0000 (09:25 +0000)]
Merge #11696

11696: editors/code: fix nixos detection r=lnicola a=cab404

Problem: NixOS started using quotes around it's id field in /etc/os-release
Solution: Parially parsing os-release, and detecting, whether `nixos` appears anywhere in "ID=" field\
See https://github.com/rust-analyzer/rust-analyzer/issues/11695

Closes #11695

Co-authored-by: Vladimir Serov <me@cab404.ru>
2 years agoeditors/code: fix nixos detection
Vladimir Serov [Sat, 12 Mar 2022 21:26:36 +0000 (00:26 +0300)]
editors/code: fix nixos detection

Problem: NixOS started using quotes around it's id field in /etc/os-release
Solution: Parially parsing os-release, and detecting, whether `nixos` appears anywhere in "ID=" field\
See https://github.com/rust-analyzer/rust-analyzer/issues/11695
Closes #11695

2 years agobroke a test trying to make the diff look better...
Morgan Thomas [Sat, 12 Mar 2022 18:35:26 +0000 (10:35 -0800)]
broke a test trying to make the diff look better...

2 years agofix: "Extract to function" assist preserves `break` and `continue` labels
Morgan Thomas [Sat, 12 Mar 2022 16:44:37 +0000 (08:44 -0800)]
fix: "Extract to function" assist preserves `break` and `continue` labels

Adds a label / lifetime parameter to `ide_assists::handlers::extract_function::FlowKind::{Break, Continue}`, adds support for emitting labels to `syntax::ast::make::{expr_break, expr_continue}`, and implements the required machinery to let `extract_function` make use of them.

This does modify the external API of the `syntax` crate, but the changes there are simple, not used outside `ide_assists`, and, well, we should probably support emitting `break` and `continue` labels through `syntax` anyways, they're part of the language spec.

Closes #11413.

2 years agoMerge #11692
bors[bot] [Sat, 12 Mar 2022 15:53:05 +0000 (15:53 +0000)]
Merge #11692

11692: round of clippy fixes. r=Veykril a=matthiaskrgr

Split these up into smaller chunks so I can easily revert parts of it if needed.

Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
2 years agofix clippy::needless_late_init
Matthias Krüger [Sat, 12 Mar 2022 15:17:53 +0000 (16:17 +0100)]
fix clippy::needless_late_init

2 years agomore clippy fixes:
Matthias Krüger [Sat, 12 Mar 2022 14:57:57 +0000 (15:57 +0100)]
more clippy fixes:

clippy::search_is_some
clippy::redundant_static_lifetimes
clippy::match_single_binding
clippy::match_ref_pats
clippy::map_entry
clippy::manual_map
clippy::iter_overeager_cloned
clippy::into_iter_on_ref
clippy::extra_unused_lifetimes

2 years agomore clippy fixes:
Matthias Krüger [Sat, 12 Mar 2022 14:30:07 +0000 (15:30 +0100)]
more clippy fixes:

clippy::match_like_matches_macro
clippy::to_string_in_format_args
clippy::single_char_add_str
clippy::filter_map_identity
clippy::clone_on_copy
clippy::useless_format
clippy::unused_unit

2 years agofix clippy::needless_return
Matthias Krüger [Sat, 12 Mar 2022 13:56:26 +0000 (14:56 +0100)]
fix clippy::needless_return

2 years agofix clippy::redundant_clone
Matthias Krüger [Sat, 12 Mar 2022 13:35:25 +0000 (14:35 +0100)]
fix clippy::redundant_clone

2 years agofix clippy::map_flatten
Matthias Krüger [Sat, 12 Mar 2022 13:26:16 +0000 (14:26 +0100)]
fix clippy::map_flatten

2 years agofix clippy::useless_conversion
Matthias Krüger [Sat, 12 Mar 2022 12:43:53 +0000 (13:43 +0100)]
fix clippy::useless_conversion

2 years agofix clippy::redundant_closure
Matthias Krüger [Sat, 12 Mar 2022 12:35:31 +0000 (13:35 +0100)]
fix clippy::redundant_closure

2 years agofix clippy::single_char_pattern
Matthias Krüger [Sat, 12 Mar 2022 12:22:12 +0000 (13:22 +0100)]
fix clippy::single_char_pattern

2 years agofix clippy::needless_borrow
Matthias Krüger [Sat, 12 Mar 2022 12:04:13 +0000 (13:04 +0100)]
fix clippy::needless_borrow

2 years agoMerge #11691
bors[bot] [Sat, 12 Mar 2022 15:44:51 +0000 (15:44 +0000)]
Merge #11691

11691: feat: Suggest union literals, suggest union fields within an empty union literal r=Veykril a=m0rg-dev

Adds a `Union {…}` completion in contexts where a union is expected, expanding to a choice of available fields (if snippets are supported):

![image](https://user-images.githubusercontent.com/38578268/158023335-84c03e39-daf0-4a52-b969-f40b01501cc8.png)
![image](https://user-images.githubusercontent.com/38578268/158023354-db49d0bb-034c-49d3-bc02-07414179cb61.png)

Also, adds support for listing possible fields in an empty union literal.

![image](https://user-images.githubusercontent.com/38578268/158023398-4695ae34-ce64-4f40-8494-68731a3030c6.png)
![image](https://user-images.githubusercontent.com/38578268/158023406-be96dd95-125a-47ac-9628-0bce634ca2eb.png)

Closes #11568.

Co-authored-by: Morgan Thomas <corp@m0rg.dev>
2 years ago- clean up match in ide_completion::completions::record::complete_record_literal
Morgan Thomas [Sat, 12 Mar 2022 15:35:13 +0000 (07:35 -0800)]
- clean up match in ide_completion::completions::record::complete_record_literal
- use original instead of adjusted type in ide_completion::completions::record::complete_record
- don't even bother checking if we can complete union literals to Default or to struct update syntax

2 years agoMerge #11693
bors[bot] [Sat, 12 Mar 2022 15:28:33 +0000 (15:28 +0000)]
Merge #11693

11693: internal: Remove ide_completion::render::build_ext module r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
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 agoSuggest union literals, suggest union fields within an empty union literal
Morgan Thomas [Sat, 12 Mar 2022 14:58:43 +0000 (06:58 -0800)]
Suggest union literals, suggest union fields within an empty union literal

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
    ...