Commit Graph

14885 Commits

Author SHA1 Message Date
bors[bot]
c2ea378920
Merge #11795
11795: fix: Correctly suggest auto importing traits from aliases r=Veykril a=unexge

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

Co-authored-by: unexge <unexge@gmail.com>
2022-03-22 21:44:06 +00:00
unexge
4e4c9ea4ac fix: Correctly suggest auto importing traits from aliases 2022-03-22 22:30:29 +01:00
bors[bot]
1a92ee5db5
Merge #11792
11792: minor: Bump dependencies r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-22 21:00:24 +00:00
Kyle Huey
af1aa86ac0 Preserve order when grouping references. 2022-03-22 12:38:59 -07:00
Kyle Huey
0583919919 LSIF: consolidate references into a single edge where possible. 2022-03-22 12:00:52 -07:00
Lukas Wirth
8e91bb7660 minor: Bump dependencies 2022-03-22 17:42:24 +01:00
Jonas Schievink
4e07864f59 signature help: skip lifetimes when non-lifetime arguments are present 2022-03-22 16:44:27 +01:00
bors[bot]
f1dbc2acd4
Merge #11789
11789: fix: Fix lifetime elision hint configuration key r=Veykril a=Veykril

This is inconsistent with the other configuration keys unfortunately, but this is an issue of how we structured them here in general.

I feel like we'll have to do a proper pass over all the configs, check them for consistency and then write down some documentation of how our configs should be laid out, then apply fixes to the inconsistencies all at once which will entail breaking some user configurations unfortunately since we won't be able to do proper fallback handling for some of these.

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

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-22 15:31:45 +00:00
Lukas Wirth
ecf2c98859 fix: Fix lifetime elision hint configuration key 2022-03-22 16:28:36 +01:00
bors[bot]
800ae516db
Merge #11788
11788: internal: Improve `find_path` and extern prelude handling r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-22 15:17:50 +00:00
Jonas Schievink
b7cc9a7275 Trigger call info when completing generic type
Closes #11763
2022-03-22 16:10:17 +01:00
Jonas Schievink
4bb5df0ce5 Avoid signature help inside multiline expressions
Fixes #11768
2022-03-22 16:08:46 +01:00
bors[bot]
98d1724cb0
Merge #11786
11786: fix: fill_match_arms doesn't add wildcard pat for local enums r=Veykril a=OleStrohm

Fix #11783 

This adds similar logic to non_exhaustive as is currently on doc(hidden)

Co-authored-by: Ole Strohm <strohm99@gmail.com>
2022-03-22 14:58:17 +00:00
Lukas Wirth
cb1b7e18fe internal: Improve find_path and extern prelude handling 2022-03-22 15:54:46 +01:00
Jonas Schievink
c9cefb9916 Improve readability of signature help tests 2022-03-22 15:03:19 +01:00
Ole Strohm
b3bd547dda applied rustfmt 2022-03-22 11:10:48 +00:00
Ole Strohm
94113b0ac6 fix: fill_match_arms doesn't add wildcard pat for local enums 2022-03-22 10:56:20 +00:00
bors[bot]
5d2cd18765
Merge #11780
11780: feat: Add type mismatch diagnostic r=flodiebold a=flodiebold

This adds a proper diagnostic for type mismatches, turning "Add reference here", "Missing Ok or Some" and "Remove this semicolon" into quickfixes for this single diagnostic.
The diagnostic is marked as experimental when it does not have one of these quickfixes, so it can be turned off with `rust-analyzer.diagnostics.enableExperimental` (or specifically with `rust-analyzer.diagnostics.disabled` of course, the ID is `type-mismatch`).
There will still be some false positives, but I think there shouldn't be too many especially when the Chalk fix lands, and it's still experimental anyway 🙂 
This also fixes type checking for `rustc_legacy_const_generics` just to avoid some errors in tests.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-03-22 10:40:23 +00:00
Lukas Wirth
000e681d5f fix: Fix tuple- and record struct completions not working with existing braces 2022-03-21 22:01:26 +01:00
Lukas Wirth
7370a6b5b8 fix: Fix flyimport showing functions in pattern position 2022-03-21 19:41:39 +01:00
Florian Diebold
3bdb68d80f Clean up commented-out lines 2022-03-21 19:16:58 +01:00
Florian Diebold
5f24ff0d84 Fix unreachable_pub 2022-03-21 18:54:20 +01:00
Florian Diebold
344cf1db5f Fix expect 2022-03-21 17:00:03 +01:00
Florian Diebold
baa43a86ab Add a FIXME 2022-03-21 16:49:01 +01:00
Florian Diebold
8498eaa6ab Implement type checking for legacy_const_generics 2022-03-21 16:46:01 +01:00
Florian Diebold
2ef541b35f Cleanups 2022-03-21 16:46:01 +01:00
Florian Diebold
b632d706c7 Remove old diagnostics 2022-03-21 16:46:01 +01:00
Florian Diebold
a49a0ab883 Add 'remove this semicolon' 2022-03-21 16:46:01 +01:00
Florian Diebold
0689fdb650 Add "add missing Ok/Some" fix 2022-03-21 16:46:01 +01:00
Florian Diebold
ab3313b1cb Add new type-mismatch diagnostic 2022-03-21 16:46:01 +01:00
Florian Diebold
2d30dd67d3 Expose coercion logic in hir API 2022-03-21 16:45:59 +01:00
Florian Diebold
6133e6a002 Extract coercion logic to InferenceTable
To make it accessible without an InferenceContext.
2022-03-21 16:45:30 +01:00
Laurențiu Nicola
1a37b17162 Replace write! with direct calls 2022-03-21 10:43:36 +02:00
bors[bot]
b594f9c441
Merge #11690
11690: feat: Add an assist for inlining type aliases r=Veykril a=steven-joruk

I'm working towards implementing #10881, but I'd like to get this in first with earlier feedback.

Is `inline_type_alias` a good enough name? I guess the follow up assist would be called `inline_type_alias_into_all_users` based on that.

![valid_inlines](https://user-images.githubusercontent.com/1277939/158020510-fed78b5c-4c7e-46d1-9151-3044a29b9990.gif)

![invalid_inlines](https://user-images.githubusercontent.com/1277939/158020516-8a2deb6d-c6ec-4adf-a15b-c514fc97dc43.gif)



Co-authored-by: Steven Joruk <steven@joruk.com>
2022-03-20 21:15:49 +00:00
Steven Joruk
1381a2de23 refactor: Do more work in inline_type_alias closure 2022-03-20 20:53:03 +00:00
bors[bot]
6f2b118605
Merge #11775
11775: internal: Treat `global_asm` and `asm` macros as unsafe r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 18:31:27 +00:00
Lukas Wirth
ddf144051a internal: Treat {global_}asm macros as unsafe 2022-03-20 19:31:00 +01:00
bors[bot]
fedf724d82
Merge #11774
11774: feat: Tag macro calls as unsafe if they expand to unsafe expressions r=Veykril a=Veykril

as long as they aren't inside an unsafe block inside the macro that is.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 18:15:29 +00:00
Lukas Wirth
3b7b223b25 Simplify 2022-03-20 19:13:50 +01:00
Lukas Wirth
68de7b30e0 feat: Tag macro calls as unsafe if they expand to unsafe expressions 2022-03-20 19:07:44 +01:00
bors[bot]
966b692422
Merge #11771
11771: feat: Visualize compiler inserted reborrows via inlay hints r=Veykril a=Veykril

Disabled by default.

![image](https://user-images.githubusercontent.com/3757771/159165178-baaf968a-4381-468e-933f-5326ca1b203d.png)

Closes https://github.com/rust-analyzer/rust-analyzer/issues/11275


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 13:47:16 +00:00
Lukas Wirth
5a87f09a71 Update inlay hint feature docs 2022-03-20 14:41:27 +01:00
Lukas Wirth
37b48ceb8f feat: Visualize compiler inserted reborrows via inlay hints 2022-03-20 14:38:16 +01:00
bors[bot]
a82caff588
Merge #11765
11765: fix: Fix closure hints using macro ranges r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-19 19:26:34 +00:00
Lukas Wirth
2598575a35 fix: Fix closure hints using macro ranges 2022-03-19 20:24:09 +01:00
bors[bot]
7315d97347
Merge #11755
11755: feat: Implement lifetime elision hints r=Veykril a=Veykril

With names on:
![Code_erl26zKvuf](https://user-images.githubusercontent.com/3757771/159134856-e2c75d2d-f17c-45c7-9a78-3da5ee8b1acd.png)
With names off:
![Code_MRP1Pbfe9d](https://user-images.githubusercontent.com/3757771/159134857-30fac3a1-825e-4f49-ba9b-9fa0bb215694.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-19 19:15:06 +00:00
Lukas Wirth
7da5b80f25 Change skip trivial behaviour 2022-03-19 20:12:14 +01:00
Lukas Wirth
7ab0aaa82a Add option to skip trivial cases 2022-03-19 19:01:19 +01:00
Lukas Wirth
45756c823f Use numbers for lifetimes by default, add setting to prefer using parameter names 2022-03-19 18:11:56 +01:00
Jonas Schievink
55d2a25123 Rename call info to "signature help"
It is no longer limited to just calls
2022-03-18 20:19:35 +01:00
Jonas Schievink
0642724e94 Provide signature help when editing generic args 2022-03-18 19:59:41 +01:00
Lukas Wirth
c22fed895e Fix test fixtures 2022-03-18 18:57:15 +01:00
Lukas Wirth
b634d99361 Give the lifetimes better names 2022-03-18 18:55:03 +01:00
Lukas Wirth
673e2b1d8f feat: Implement lifetime elision hints 2022-03-18 18:11:16 +01:00
bors[bot]
e3217c5015
Merge #11752
11752: internal: Allow explicitly specifying end of fixture annotation r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-18 16:38:32 +00:00
Lukas Wirth
890f98f21f internal: Allow explicitly specifying end of fixture annotation 2022-03-18 15:42:19 +01:00
Jonas Schievink
14203c6378 Complete assoc const patterns on builtin types 2022-03-18 15:36:18 +01:00
bors[bot]
849ac25f05
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>
2022-03-18 13:54:09 +00:00
Jonas Schievink
e7564086f4
Update crates/ide_completion/src/tests/pattern.rs 2022-03-18 14:53:44 +01:00
bors[bot]
6ad8c022ed
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>
2022-03-18 11:13:37 +00:00
Lukas Wirth
828196be3b fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros 2022-03-18 12:01:59 +01:00
Laurențiu Nicola
86b1ef9ab2 Bump deps 2022-03-17 19:24:37 +02:00
Florian Diebold
60aeb8fa1a Move fallback_bound_vars to the only place it's used now 2022-03-17 17:08:43 +01:00
Florian Diebold
9ea2e0bd5b Fixes for consts 2022-03-17 17:04:32 +01:00
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
hi-rustin
bc8665e14d Fix typo
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-17 22:59:47 +08:00
Florian Diebold
1b71cd074d Add test for DynMap type inference 2022-03-17 15:44:14 +01:00
hi-rustin
2bc545d9ef Match the enum and union
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-17 21:38:21 +08: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
hi-rustin
c6ef4e830e Fix the wrong path resolution
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-17 20:39:04 +08:00
hi-rustin
a9aae250ed Add completes_associated_const test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-17 20:39:00 +08:00
hi-rustin
37d0c722ef Complete associated consts in patterns
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-17 20:35:04 +08: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
Steven Joruk
1981a3dc65 test: Make imported_external test that the full path is replaced 2022-03-13 13:25:06 +00:00
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
Steven Joruk
2e00fa208f chore: Remove unused import 2022-03-12 15:59:00 +00:00
Steven Joruk
d7517d8323 refactor: Veykril's code review suggestions 2022-03-12 15:55:47 +00: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
Steven Joruk
5b712bd821 feat: Add an assist for inlining type aliases
This intends to lead to a more useful assist to replace all users of an
alias with its definition.
2022-03-12 13:42:24 +00:00
Steven Joruk
cdeb1b2c78 chore: fill_match_arms was renamed - update its usage in a comment 2022-03-12 13:41:23 +00: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
Morgan Thomas
f27c0ef1cf Reduce intermediate string allocations in render::compound::render_record and ::render_tuple 2022-03-12 05:01:25 -08:00
Morgan Thomas
d430ddd809 Extract the code for formatting struct and enum-variant literal labels out into a common function 2022-03-12 04:40:05 -08:00
yipinliu
0c54921f93 Fixed code style issues 2022-03-12 20:36:56 +08:00
yipinliu
8247925313 Fixed tidy test 2022-03-12 20:04:14 +08:00
yipinliu
581e1bf0d7 Highlight escape sequences in byte strings 2022-03-12 19:03:14 +08:00
Morgan Thomas
b3640ce424 make the doc comment on render::compound::visible_fields a little better 2022-03-11 19:23:04 -08:00
Morgan Thomas
6a1c151159 visibility tweak for CI 2022-03-11 19:10:43 -08:00
Morgan Thomas
2a22cf8efc 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).
2022-03-11 18:26:01 -08:00
Morgan Thomas
1c5b2c7d03 - 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`)
2022-03-11 17:55:25 -08:00
bors[bot]
36e87fdb98
Merge #11685
11685: internal: Simplify CompletionContext r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-12 01:15:21 +00:00
Lukas Wirth
0b54d31359 Remove no_completions_required from CompletionContext 2022-03-12 02:12:00 +01:00
bors[bot]
71f7e67dcf
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>
2022-03-12 00:44:39 +00:00
Lukas Wirth
119ba82e4b minor: add missing definitions of lsp_ext::InlayHintLabel 2022-03-12 01:08:33 +01:00
Steven Joruk
8a28430676 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.
2022-03-11 22:28:38 +00:00
Steven Joruk
e84453c47f refactor: Rename const_arg_content to const_arg_expr 2022-03-11 22:28:35 +00:00
Lukas Wirth
62265ee9cb fix: Allow configuration of colons in inlay-hints 2022-03-11 21:15:36 +01:00
Steven Joruk
972f50da2d 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
    ...
2022-03-11 19:51:35 +00:00
bors[bot]
224a255c5a
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>
2022-03-11 16:17:59 +00:00
Lukas Wirth
a9dd606387 fix: Show what file paths were expected for unresolved modules 2022-03-11 17:08:30 +01:00
bors[bot]
69e5bd5a25
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>
2022-03-10 21:24:11 +00:00
Lukas Wirth
6c8c02f625 Don't parse source files to generate macro completion details 2022-03-10 22:21:58 +01:00
Lukas Wirth
b1ab5770c9 Enable qualifier completions for derives 2022-03-10 21:56:19 +01:00
Lukas Wirth
2abe19e46a Don't offer qualified path completions for buitlin derives 2022-03-10 21:22:13 +01:00
Lukas Wirth
a8b76b632c Expand into pseudo-derive attribute expansions in completions 2022-03-10 20:53:50 +01:00
Dario Nieuwenhuis
49d1207775 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.
2022-03-10 18:21:29 +01:00
Lukas Wirth
533f178a52 minor: Access parser internals through ide_db for ide crates 2022-03-10 17:07:28 +01:00
bors[bot]
a7d440e368
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>
2022-03-10 15:49:03 +00:00
bors[bot]
5b51cb835a
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>
2022-03-09 21:45:42 +00:00
Lukas Wirth
fdde10ba6f Update project_model test outputs 2022-03-09 22:34:42 +01:00
Lukas Wirth
1f1185dcbb Specific proc-macro crate type for other test fixture where needed 2022-03-09 22:18:09 +01:00
bors[bot]
4fcaefa62a
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>
2022-03-09 17:18:03 +00:00
Lukas Wirth
5b9799bba4 Specify proc-macro crate type for proc-macro hir_def test fixtures 2022-03-09 15:36:05 +01:00
Lukas Wirth
3edc5dcea8 fix: Properly handle proc-macro crate types for nameres 2022-03-09 14:33:39 +01:00
bors[bot]
d70ea759b3
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>
2022-03-09 10:26:34 +00:00
Lukas Wirth
2537ad0d9e Simplify 2022-03-09 11:26:06 +01:00
Lukas Wirth
054ab5fd9c Disable one of the failing SSR test cases 2022-03-09 02:08:44 +01:00
Lukas Wirth
f9c8646d89 fix symbol index collection not collecting legacy macros 2022-03-09 01:44:20 +01:00
Lukas Wirth
4e94fb7028 Fix ProcMacroData recording wrong name for derives 2022-03-09 01:13:38 +01:00
Lukas Wirth
c37fe779c6 Add data queries for macros 2022-03-09 00:41:54 +01:00
Lukas Wirth
55ec93a337 Remove unnecessary macro_declarations from ItemScope 2022-03-09 00:19:53 +01:00
Lukas Wirth
dbada38b61 Only store derive<->derive-helper mapping in DefMap 2022-03-09 00:01:19 +01:00
Lukas Wirth
eba90936c1 Move ide crates to new hir::Macro 2022-03-08 23:52:26 +01:00
Lukas Wirth
c04b0f435b Move hir to new MacroId 2022-03-08 23:51:48 +01:00
Lukas Wirth
ad54ee2939 Rename MacroDef to Macro 2022-03-08 23:51:19 +01:00
hkalbasi
1282178783 insert dummy values for const generics in subst 2022-03-09 02:02:42 +03:30
Lukas Wirth
42d46325a1 Add MacroId to hir_def in attempt to unify Macros with ModuleDefId 2022-03-08 21:50:00 +01:00
vi_mi
5789caf60e fix: extract_module selection inside impl 2022-03-09 01:38:53 +05:30
Laurențiu Nicola
4a6ee4517a Add back colons around inlay hints 2022-03-08 12:01:02 +02:00
Laurențiu Nicola
8e3057d0a7 Improve inlay hint padding 2022-03-07 19:18:36 +02:00
bors[bot]
49646b71d4
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>
2022-03-07 16:49:12 +00:00
Laurențiu Nicola
88a2141b77 Add inlayHints cap 2022-03-07 18:48:27 +02:00
Laurențiu Nicola
26d2e88b04 Fix parameter hint position 2022-03-07 15:24:54 +02:00
Laurențiu Nicola
b9d74fe2ed Update LSP docs 2022-03-07 15:09:31 +02:00
Luna Razzaghipour
6da1228898
Emit more detailed highlighting for %, >>, << 2022-03-07 20:16:03 +11:00
bors[bot]
5fae65dd28
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>
2022-03-06 18:31:30 +00:00
Lukas Wirth
93b09ca067 Update tidy ignore list 2022-03-06 19:18:40 +01:00
Lukas Wirth
ab21cf2f4f internal: Re-arrange ide_db modules 2022-03-06 19:04:04 +01:00
bors[bot]
b9538122f2
Merge #11637
11637: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-06 16:56:29 +00:00
Lukas Wirth
c1f91c93b2 minor: Simplify 2022-03-06 17:56:02 +01:00
Aleksey Kladov
cf70ed5eac Bring back syntax highlighting in test data
cc #11597
2022-03-06 08:43:18 +00:00
bors[bot]
fc350ead05
Merge #11631
11631: internal: Refactor syntax_highlighting r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-06 03:19:54 +00:00
Lukas Wirth
97076c074d internal: Simplify and optimize syntax_highlighting 2022-03-06 03:49:54 +01:00
bors[bot]
96c11f5fd6
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>
2022-03-05 23:48:54 +00:00
Lukas Wirth
e8edbb5d6f Add a macro case for the keyword highlighting test fixture 2022-03-06 00:26:15 +01:00
Lukas Wirth
d460b7c9d1 Fix extern crate self having self unresolved 2022-03-06 00:17:40 +01:00
Lukas Wirth
e5bb661b7a Highlight Self as a keyword by default 2022-03-06 00:13:45 +01:00
Lukas Wirth
0bb631bf71 Simplify 2022-03-05 23:53:24 +01:00
Lukas Wirth
b454f11f38 Fix hover for Self keyword 2022-03-05 23:47:44 +01:00
bors[bot]
b032993733
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>
2022-03-05 22:34:59 +00:00
Lukas Wirth
5c0aee013e Fix highlighting of Self 2022-03-05 23:34:37 +01:00
Lukas Wirth
a148c49f1c Fix test fixture 2022-03-05 23:21:20 +01:00
Lukas Wirth
c0d6471143 fix: Recognize Self as a proper keyword 2022-03-05 23:20:06 +01:00
Lukas Wirth
a548958cdf fix macro-calls always expanding to expressions in LetStmt 2022-03-05 22:04:06 +01:00
Lukas Wirth
bb47c5f56c fix: Fix macro-calls expanding to items in if/while conditions 2022-03-05 21:58:51 +01:00
bors[bot]
8f504dc873
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>
2022-03-05 11:31:29 +00:00
bors[bot]
e844b1570a
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>
2022-03-05 11:20:05 +00:00
bors[bot]
79a7ba0bdf
Merge #11623
11623: fix: Add type variable table to InferenceTableSnapshot r=flodiebold a=tysg

Fixes #11601. 

I observed that removing the `rollback` line in 6fc3d3aa4c 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>
2022-03-05 10:32:07 +00:00
Tianyi Song
c49bcc7814 Add type variable table to InferenceTableSnapshot 2022-03-05 17:59:28 +08:00
Andy Russell
49fab593ad
show variadic args in hover function signature 2022-03-04 16:44:31 -05:00
bors[bot]
908c17bfa6
Merge #11595
11595: fix: lower string literals with actual value instead of default r=lnicola a=tysg

Fixes #11582. Some questions below in the code review section.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
2022-03-04 20:21:43 +00:00
Lukas Wirth
4a866fc672 Simplify 2022-03-04 20:23:25 +01:00
Lukas Wirth
32bf7af83e Support locals with multiple declaration sites 2022-03-04 19:49:08 +01:00
hkalbasi
660fd4ab41 Resolve only type params in type ns 2022-03-04 12:30:53 +03:30
hkalbasi
4fa8749c44 Preserve order of generic args 2022-03-04 11:46:14 +03:30
Laurențiu Nicola
4b16b9b74b Fix formatting 2022-03-04 08:15:17 +02:00
Kirill Bulatov
5de5e450cb Remove debugging leftovers 2022-03-04 08:08:59 +02:00
Kirill Bulatov
b1d8dae930 Load hints for part of the file only 2022-03-04 07:45:51 +02:00
Kirill Bulatov
9c0c199e96 Clean up the redundant hints code and config 2022-03-04 07:45:51 +02:00
Laurențiu Nicola
0b69717ab6 Fixes 2022-03-04 07:45:51 +02:00
Laurențiu Nicola
5a49dbd2e0 Update inlay hints for upstream 2022-03-04 07:45:51 +02:00
Kirill Bulatov
55371be807 Add experimental VSCode api 2022-03-04 07:45:51 +02:00
Tianyi Song
89a19f57f8 Lower string literals with real val, not default 2022-03-04 10:16:35 +08:00
Lukas Wirth
464dd814ca slightly improve highlighting performance for derive annotated items 2022-03-03 22:59:34 +01:00
Lukas Wirth
8ded3ec9cf fix: Fix semantic highlighting breaking for lifetimes in macros 2022-03-03 22:53:03 +01:00
Laurențiu Nicola
7c6935eed5 Add abort to safe intrinsics list 2022-03-03 20:58:20 +02:00
bors[bot]
e949375098
Merge #11610
11610: Add a (currently failing) test for #11242 r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-03-03 17:42:33 +00:00
Florian Diebold
82fe1c77b5 Add a (currently failing) test for #11242 2022-03-03 18:32:40 +01:00
Florian Diebold
ac51eea309 Add another case to the syntax fixup code 2022-03-03 18:30:14 +01:00
Chayim Refael Friedman
10d30be331 Do not consider _ to be an expression for macro_rules! 2022-03-02 01:51:25 +00:00
Chayim Refael Friedman
d9f0731bd2 Parse destructuring assignment
The only patterns we should parse are `..` in structs and `_`: the rest are either not supported or already valid expressions.
2022-03-02 01:51:25 +00:00
bors[bot]
342c3c42bb
Merge #11433
11433: minor: Add scary warning to `onEnter` r=lnicola a=lnicola

Closes #11432

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-02-28 10:15:44 +00:00
Laurențiu Nicola
6bf97692ae Add scary warning to onEnter 2022-02-28 12:15:15 +02:00
Chayim Refael Friedman
e6a35c28cb
Future-proof against a next edition by using >= and not ==
So that we won't have a strange bug when edition 2024 will land.

rustc [also does that](427cf81206/compiler/rustc_builtin_macros/src/edition_panic.rs (L84)).
2022-02-28 11:13:55 +02:00
Moritz Vetter
96c16bc382 redirct: use iterators and knowledge about preordered arrays for more efficient merging 2022-02-28 05:56:51 +01:00
bors[bot]
4e72700e38
Merge #11573
11573: refactorings and FIXME fixes in text edit r=lnicola a=HansAuger

This is mainly me learning some rust, and only anecdotally about addressing some `fixme`s. Feel free to nope :)

There is a follow up PR in the pipeline which tackles the other two `fixme`s but it's a bit more invasive. So I wanted to get this out of the way

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2022-02-27 12:00:04 +00:00
bors[bot]
a53915c10d
Merge #11567
11567: Fix `if` in #11561 r=Veykril a=ChayimFriedman2

Fixes #11561.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2022-02-27 11:34:01 +00:00
Chayim Refael Friedman
744f0ea2e7
Remove misleading comments
They're not true anymore after #11375.
2022-02-27 09:52:11 +02:00
Moritz Vetter
ff59147d53 add two more unit tests for text_edit 2022-02-27 02:27:44 +01:00
Chayim Refael Friedman
54fe3dc0f1 Fix if in #11561 2022-02-27 00:19:45 +00:00
bors[bot]
5cade9bf33
Merge #11565
11565: fix: Fix body selection in while loops r=Veykril a=lnicola

CC #11561

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-02-26 16:49:16 +00:00
Lukas Wirth
47ce4436e4 Make hir::Local::name infallible 2022-02-26 16:36:44 +01:00
Moritz Vetter
21d497b773 refact: edit text in place in TextEdit::apply 2022-02-26 15:50:09 +01:00
Moritz Vetter
c541f3396c test: add unit test for TextEdit::apply() 2022-02-26 15:46:14 +01:00
Laurențiu Nicola
87c4a4104d Fix body selection in while loops 2022-02-26 16:45:06 +02:00
Lukas Wirth
36603e0478 Rename test highlighting output files 2022-02-26 14:52:42 +01:00
Lukas Wirth
c99fb4b1ac Split up highlighting tests a bit more 2022-02-26 14:45:09 +01:00
Lukas Wirth
48189bc1b4 Re-order and cleanup highlighting tests 2022-02-26 14:29:03 +01:00
Lukas Wirth
03d33556c9 fix: Don't emit unresolvedReference highlight tags in unlinked files 2022-02-26 13:53:54 +01:00
bors[bot]
a2cc1d6b7b
Merge #11538
11538: feat: Make private editable completions configurable, disable by default r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9885

This does disable these completions by default, as it seems that people find this behaviour surprising(due to other IDEs usually not doing this).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-25 21:17:24 +00:00
Lukas Wirth
2a7793d912 feat: Make private editable completions configurable, disable by default 2022-02-25 22:16:40 +01:00
Jonas Schievink
aec4bcf3f2 Implement the new built-in unreachable! macro 2022-02-25 19:13:04 +01:00
Jonas Schievink
a247fffdf6 Resolve $crate in HirDisplay of Path 2022-02-25 18:38:51 +01:00
bors[bot]
ab896e38e1
Merge #11550
11550: Refactor autoderef/method resolution r=flodiebold a=flodiebold

- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-25 16:11:22 +00:00
Florian Diebold
6fc3d3aa4c Avoid autoderef coercions leaking if they don't apply 2022-02-25 15:46:02 +01:00
bors[bot]
c8257488c1
Merge #11549
11549: feat: support concat_bytes r=jonas-schievink a=ihciah

Support `concat_bytes`.
Solve #11544.

Co-authored-by: ihciah <ihciah@gmail.com>
2022-02-25 13:34:18 +00:00
Florian Diebold
187e6bacac Fix unreachable pub 2022-02-25 12:09:49 +01:00