Commit graph

14610 commits

Author SHA1 Message Date
Florian Diebold
59b5696aaa Snapshot obligations 2022-03-17 17:04:32 +01:00
Florian Diebold
8f5b6ac556 Properly try unifying the receivers during method resolution
Instead of hackily checking if they're equal.
2022-03-17 17:03:54 +01:00
Florian Diebold
1b71cd074d Add test for DynMap type inference 2022-03-17 15:44:14 +01:00
bors[bot]
631b504991
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>
2022-03-17 13:23:22 +00:00
bors[bot]
0a18e4355a
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>
2022-03-17 13:14:26 +00:00
Laurențiu Nicola
de53232ada Emit #[must_use] in Generate enum is_variant assist 2022-03-17 15:10:25 +02:00
Walther
217b30568e Insert #[must_use] in generate_is_empty_from_len 2022-03-17 15:03:02 +02:00
bors[bot]
502e30e676
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>
2022-03-17 12:58:14 +00:00
Walther
e5adbd88e9 Insert #[must_use] in generate_getter 2022-03-17 14:49:22 +02:00
Laurențiu Nicola
7e05e10495 Emit #[must_use] in Generate new assist 2022-03-17 14:21:42 +02:00
hkalbasi
0141f28475 fix regression_11688_2 2022-03-17 12:47:31 +03:30
bors[bot]
3bff42fd14
Merge #11734
11734: internal: Bump `xshell` and fix `dist` r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-03-17 06:54:27 +00:00
Laurențiu Nicola
be6d5001e4 Bump xshell and fix dist 2022-03-17 08:53:33 +02:00
bors[bot]
b3cfa1986b
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>
2022-03-16 20:31:47 +00:00
Lukas Wirth
bd17933c31 feat: Add return type hints for closures with block bodies 2022-03-16 21:25:03 +01:00
bors[bot]
a57fee6b6f
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>
2022-03-16 16:35:34 +00:00
Lukas Wirth
a40a847d77 Revert omitting field completions 2022-03-16 16:41:35 +01:00
Lukas Wirth
c1f6f135e1 Remove code duplication 2022-03-16 16:32:36 +01:00
Lukas Wirth
02b401b130 Simplify completion render functionality 2022-03-16 16:27:55 +01:00
Lukas Wirth
4fe5f03c7f Rename compound things to variant things 2022-03-16 13:41:47 +01:00
Laurențiu Nicola
620411df80 Mark chaining hints as types, since that's what they are 2022-03-16 07:46:09 +02:00
bors[bot]
fb9e66d9fc
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>
2022-03-15 20:27:51 +00:00
hkalbasi
1f3d18718c fix const generic panic 2022-03-15 22:34:05 +03:30
bors[bot]
61b1449387
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>
2022-03-15 17:58:21 +00:00
Lukas Wirth
d5f8d91872 fix: Fix completions not always working in for-loop patterns 2022-03-15 18:46:32 +01:00
bors[bot]
683fea4de4
Merge #11707
11707: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-14 20:05:46 +00:00
Lukas Wirth
fbc1d2a514 Simplify 2022-03-14 20:36:35 +01:00
bors[bot]
83575c96ed
Merge #11700
11700: ⬆️ xshell r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-03-14 15:02:34 +00:00
Aleksey Kladov
56e43c34e7 ⬆️ xshell 2022-03-14 14:57:24 +00:00
hkalbasi
b301b040f5 Add const generics 2022-03-14 14:38:37 +03:30
Morgan Thomas
14e20047c4 broke a test trying to make the diff look better... 2022-03-12 10:35:26 -08:00
Morgan Thomas
3fafbca32e 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.
2022-03-12 08:54:06 -08:00
Matthias Krüger
f39cac17ce fix clippy::needless_late_init 2022-03-12 16:50:49 +01:00
Matthias Krüger
5a0078c9d1 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
2022-03-12 16:50:49 +01:00
Matthias Krüger
56e4ea59d9 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
2022-03-12 16:50:49 +01:00
Matthias Krüger
77790f2b8e fix clippy::needless_return 2022-03-12 16:50:49 +01:00
Matthias Krüger
21ffc5350d fix clippy::redundant_clone 2022-03-12 16:50:49 +01:00
Matthias Krüger
d64d711db2 fix clippy::map_flatten 2022-03-12 16:50:49 +01:00
Matthias Krüger
62ed658311 fix clippy::useless_conversion 2022-03-12 16:50:49 +01:00
Matthias Krüger
451fcd3c79 fix clippy::redundant_closure 2022-03-12 16:50:49 +01:00
Matthias Krüger
1f70886b15 fix clippy::single_char_pattern 2022-03-12 16:50:49 +01:00
Matthias Krüger
7912e33ed6 fix clippy::needless_borrow 2022-03-12 16:50:49 +01:00
bors[bot]
ff7e057dca
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>
2022-03-12 15:44:51 +00:00
Morgan Thomas
f922b805fe - 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
2022-03-12 07:35:13 -08:00
Lukas Wirth
301711ee71 internal: Remove ide_completion::render::build_ext module 2022-03-12 16:13:49 +01:00
Morgan Thomas
6519b0a009 Suggest union literals, suggest union fields within an empty union literal 2022-03-12 06:58:43 -08:00
bors[bot]
d65f9a28fa
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>
2022-03-12 13:14:31 +00:00
Lukas Wirth
21af9ba4f0 minor: Pad type inlay hints if no colons are requested 2022-03-12 14:08:39 +01:00
yipinliu
c15ebcd84c Optimize imports 2022-03-12 21:06:33 +08:00
bors[bot]
d75a46852a
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>
2022-03-12 13:05:45 +00:00