Commit Graph

16416 Commits

Author SHA1 Message Date
Yuri Astrakhan
1d59c7b667 Remove non-needed clones
I am not certain if this will improve performance,
but it seems having a .clone() without any need should be removed.

This was done with clippy, and manually reviewed:

```
cargo clippy --fix -- -A clippy::all -D clippy::redundant_clone
```
2022-12-23 02:20:03 -05:00
bors
a06525517b Auto merge of #13820 - Veykril:or-pat-bm-fix, r=Veykril
Fix binding mode hints always adding parentheses to or-patterns
2022-12-22 23:02:19 +00:00
Maybe Waffle
ef4c8167e8 Pass FamousDefs around in inlay hints 2022-12-22 11:00:25 +00:00
bors
eb3963b22e Auto merge of #13817 - WaffleLapkin:hide_adjustment_hints_outside_of_unsafe, r=Veykril
feat: Add an option to hide adjustment hints outside of `unsafe` blocks and functions

As the title suggests: this PR adds an option (namely `rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe`) that allows to hide adjustment hints outside of `unsafe` blocks and functions:

![2022-12-21_23-11](https://user-images.githubusercontent.com/38225716/208986376-d607de62-8290-4e16-b7fe-15b762dc5f60.png)

Requested by `@BoxyUwU` <3
2022-12-22 09:37:00 +00:00
Lukas Wirth
b9341e2fe6 Fix binding mode hints always adding parentheses to or-patterns 2022-12-22 10:35:35 +01:00
Waffle Maybe
1038db5f1d Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-12-21 23:00:12 +00:00
bors
271f7b44d3 Auto merge of #13699 - HKalbasi:inlaylink, r=Veykril
Implement location link for type inlay hints

fix #11701

This actually doesn't work due a problem in vscode: https://github.com/microsoft/vscode/issues/167564
2022-12-21 21:43:38 +00:00
bors
113f17be6e Auto merge of #13818 - Veykril:layout, r=Veykril
Simplify
2022-12-21 20:38:57 +00:00
Maybe Waffle
608dc492ea Move is_inside_unsafe to Semantics impl 2022-12-21 20:36:05 +00:00
Lukas Wirth
8f8200eb14 Simplify 2022-12-21 21:34:01 +01:00
bors
c2840c809a Auto merge of #13814 - Veykril:layout, r=Veykril
Calculate the TargetDataLayout correctly for the selected target

This fails the tests still since those don't call into rustc yet
2022-12-21 19:38:51 +00:00
Lukas Wirth
a694c342fa Fix tests not using appropriate target data 2022-12-21 20:23:43 +01:00
Maybe Waffle
3bfe7040e8 Add an option to hide adjustment hints outside of unsafe blocks 2022-12-21 19:20:42 +00:00
Maybe Waffle
4748357045 Drive-by cleanup: fully qualify ast::Expr in hir 2022-12-21 18:17:42 +00:00
hkalbasi
e1aa73ef40 Disable inlay hint location links on vscode < 1.76 2022-12-21 18:54:49 +03:30
Lukas Wirth
33591cd3f4 Calculate the TargetDataLayout correctly for the selected target 2022-12-21 15:11:24 +01:00
hkalbasi
801a2231bf Implement location link for type inlay hints 2022-12-21 02:18:02 +03:30
Maybe Waffle
874ff2bc9d Skip adjustment hints if the adjustment doesn't adjust 2022-12-20 20:04:10 +00:00
Maybe Waffle
91a89efcf2 Save source & target types in hir's expr_adjustments 2022-12-20 19:33:27 +00:00
bors
927d56a67d Auto merge of #13764 - WaffleLapkin:badassexprs, r=Veykril
fix: Correctly check for parentheses redundancy in `remove_parentheses` assist

This is quite a bunch of code and some hacks, but I _think_ this time it's correct.

I've added a lot of tests, most of which fail with the assist impl from #13733 :')
2022-12-20 18:11:54 +00:00
bors
5c8f00f835 Auto merge of #13805 - ntBre:master, r=jonas-schievink
Complete enum variants without parens when snippets are disabled

This handles the portion of #13767 that bothered me, but I can try to work on the other parts we discussed if needed.
2022-12-20 17:58:41 +00:00
Brent Westbrook
694ae77bf6 pass snippet_cap to format_literal_label, return early if None 2022-12-20 11:27:19 -05:00
Brent Westbrook
1116cc93ec return immediately from render_tuple_lit if snippet_cap is None
partially addresses #13767
2022-12-20 11:07:37 -05:00
Maybe Waffle
babd4c7f7d Don't panic in Expr::needs_parens_in 2022-12-20 15:16:26 +00:00
Maybe Waffle
046a5679e3 Add docs to make tidy tests happy :') 2022-12-20 13:30:53 +00:00
Maybe Waffle
1c8bcf0d4e Move inlay hints tests into implementation modules 2022-12-20 13:05:18 +00:00
Maybe Waffle
191cfba9d2 Split inlay hints into modules 2022-12-20 12:58:57 +00:00
Ryo Yoshida
e027ac0fbf
fix: don't let mbe expr fragments match let exprs and inline consts 2022-12-20 20:31:47 +09:00
Jonas Schievink
5706910add Use the correct edition when formatting path deps 2022-12-19 17:53:56 +01:00
Jonas Schievink
c110481dd4 Reset parser step count when bumping 2022-12-19 16:27:00 +01:00
Lukas Wirth
cf8d89e46b Add a command to clear flycheck diagnostics 2022-12-17 23:43:26 +01:00
Lukas Wirth
d8ddde27f9 Make cancelFlycheck request a notification 2022-12-17 23:29:31 +01:00
Lukas Wirth
cdfe98fe94 Make manual flycheck runs work when checkOnSave is disabled 2022-12-17 23:26:54 +01:00
bors
e0aa5afd7b Auto merge of #13785 - Veykril:run-flycheck, r=Veykril
Add command for manually running flychecks

Closes https://github.com/rust-lang/rust-analyzer/issues/13125
2022-12-16 22:06:35 +00:00
Lukas Wirth
a04feb915a Add command for manually running flychecks 2022-12-16 22:47:19 +01:00
bors
19c2ede549 Auto merge of #13784 - Veykril:bm-hints, r=Veykril
Deduplicate inserted parentheses in binding mode hints
2022-12-16 20:51:20 +00:00
Lukas Wirth
ba3e3282da Deduplicate inserted parentheses in binding mode hints 2022-12-16 21:17:10 +01:00
bors
8f6d0cd1b0 Auto merge of #13783 - Veykril:bm-hints, r=Veykril
Add parentheses for binding mode hints when they attach to an Or-pattern
2022-12-16 19:53:06 +00:00
Lukas Wirth
b6c2bb21ab Add parentheses for binding mode hints when they attach to an Or-pattern 2022-12-16 20:52:31 +01:00
Dezhi Wu
258e532434 docs: update the comment and add a test to half_open_range_pat 2022-12-16 10:44:25 +08:00
Dezhi Wu
6a295fcd3b fix: add a check for if token in patterns parser
Closes #13776
2022-12-15 12:46:02 +08:00
bors
16de9a7130 Auto merge of #13774 - lowr:fix/no-infer-vars-in-inference-result, r=Veykril
fix: resolve all inference vars in `InferenceResult::assoc_resolutions`

I think this fixes '#13773, ~but still haven't found repro. I'll try finding one so we can have a regression test~.

We should resolve every inference variable in `InferenceResult` after inference is done. We started recording `Substitution`s for each resolved associated items in #13725, but failed to do so which causes crash when analyzing source in IDE layer.
2022-12-14 14:27:32 +00:00
bors
fb4e9359d1 Auto merge of #13769 - jonas-schievink:parse-half-open-range-pat, r=jonas-schievink
feat: Parse half-open `..= X` patterns

Closes https://github.com/rust-lang/rust-analyzer/issues/13739
2022-12-14 14:14:46 +00:00
Ryo Yoshida
bb99d2a6fb
fix: resolve all inference vars in InferenceResult::assoc_resolutions 2022-12-14 23:07:43 +09:00
Jonas Schievink
9e0aaf4cf3 Parse ..= X patterns 2022-12-13 17:32:25 +01:00
Florian Diebold
ef4a9f0ac2 Fix wrong config patching logic for addCallParenthesis 2022-12-13 16:39:00 +01:00
Maybe Waffle
7ed0871ff6 Fix "needs parens" check in remove_parentheses assist 2022-12-13 00:06:00 +00:00
bors
4596847a88 Auto merge of #13746 - feniljain:fix_extract_function, r=jonas-schievink
fix: make make_body respect comments in extract_function

Possible fix for #13621

### Points to help in review:

- Earlier we were only considering statements in a block expr and hence comments were being ignored, now we handle tokens hence making it aware of comments and then preserving them using `hacky_block_expr_with_comments`

Seems like I am not able to attach output video, github is glitching for it :(
2022-12-12 14:51:03 +00:00
bors
15ff8a5a9f Auto merge of #13715 - feniljain:fix_completions, r=jonas-schievink
fix: breaking snippets on typed incomplete suggestions

Possible fix for #7929

Fix the case where if a user types `&&42.o`, snippet completion was still applying &&Ok(42). Note this was fixed previously on `&&42.` but this still remained a problem for this case

Previous relevant PR: #13517

### Points to help in review:

- The main problem why everything broke on adding an extra `o` was, earlier `dot_receiver` was `42.` which was a `LITERAL` but now `42.o` becomes a `FIELD_EXPR`

- Till now `include_references` was just checking for parent of `LITERAL` and if it was a `REF_EXPR`, but now we consider `FIELD_EXPR` and traverse all of them, finally to reach `REF_EXPR`. If `REF_EXPR` is not found we  just return the original `initial_element`

- We are constructing a new node during `include_references` because if we rely on `dot_receiver` solely we would get `&&42.o` to be replaced with, but we want `&&42` to be replaced with

### Output Video:

https://user-images.githubusercontent.com/49019259/205420166-efbdef78-5b3a-4aef-ab4b-d892dac056a0.mov

Hope everything I wrote makes sense 😅

Also interestingly previous PR's number was `13517` and this PR's number is `13715`, nicee
2022-12-12 14:37:45 +00:00
bors
e7dff7491a Auto merge of #13726 - feniljain:fix_assists, r=jonas-schievink
feat: allow unwrap block in let initializers

Possible fix for #13679

### Points to help in review:

- I just added a parent case for let statements and it seems everything else was in place already, so turned out to be a small fix
2022-12-12 14:06:45 +00:00