Commit Graph

16445 Commits

Author SHA1 Message Date
Lukas Wirth
e3d144d17f Diagnose private field accesses 2022-12-31 14:20:59 +01:00
Lukas Wirth
ec125fe46a Improve exit point highlighting for non-loop loops in tail position 2022-12-31 12:08:25 +01:00
Lukas Wirth
1d782a9095 Add test for private method inference fallback 2022-12-31 11:42:44 +01:00
Lukas Wirth
5d54c550e7 Fallback to invisible associated functions and constants if no visible resolutions are found 2022-12-30 23:56:08 +01:00
bors
0d76b94c90 Auto merge of #13866 - Nilstrieb:rustc_safe_intrinsic, r=Veykril
Use `rustc_safe_intrinsic` attribute to check for intrinsic safety

Instead of maintaining a list that is poorly kept in sync we can just use the attribute.

This will make new RA versions unusable with old toolchains that don't have the attribute yet. Should we keep maintaining the list as a fallback or just don't care?
2022-12-30 22:14:31 +00:00
bors
09bc37c849 Auto merge of #13861 - danieleades:derive-hash, r=Veykril
derive 'Hash'

clippy doesn't like that `PartialEq` is derived, and `Hash` is manually implemented. This PR resolves that by deriving the `Hash` implementation.
2022-12-30 22:01:20 +00:00
bors
20b0ae4afe Auto merge of #13857 - WaffleLapkin:yeet, r=Veykril
feat: Implement yeeting

See tracking issue: https://github.com/rust-lang/rust/issues/96373

Before:
![2022-12-29_03-19](https://user-images.githubusercontent.com/38225716/209884634-e34e98fb-615d-4954-9614-7f9ce6291678.png)
After:
![2022-12-29_03-21](https://user-images.githubusercontent.com/38225716/209884633-4bba5eba-6dcc-4714-86cb-5c0d1f358364.png)
2022-12-30 21:48:23 +00:00
bors
ea8897c9be Auto merge of #13856 - WaffleLapkin:typeck_try{}, r=Veykril
fix: Type check unstable `try{}` blocks

![Peek 2022-12-29 01-40](https://user-images.githubusercontent.com/38225716/209875594-8bf9c9e2-9998-40b0-8820-28c7f2d9bae4.gif)

Fixes https://github.com/rust-lang/rust-analyzer/issues/11843
2022-12-30 21:35:46 +00:00
Nilstrieb
72afcf2cad Use rustc_safe_intrinsic attribute to check for intrinsic safety
Instead of maintaining a list that is poorly kept in sync we can just
use the attribute.
2022-12-30 20:29:37 +01:00
Laurențiu Nicola
3aae785693 Avoid useless format 2022-12-30 16:10:07 +02:00
Daniel Eades
da7ce6f810 derive 'Hash' 2022-12-30 11:14:15 +00:00
Maybe Waffle
346bf5fb5b Implement do yeet expression 2022-12-28 23:17:13 +00:00
Maybe Waffle
4a16afa264 Parse do yeet expressions 2022-12-28 22:42:26 +00:00
Maybe Waffle
aaa682c534 Implement try{} block type inference 2022-12-28 21:25:47 +00:00
Maybe Waffle
ef303f224f Actually test closures in closures_are_borders 2022-12-28 20:56:58 +00:00
Maybe Waffle
797da9e8da Actually test async{} blocks in async_blocks_are_borders 2022-12-28 20:56:58 +00:00
Maybe Waffle
eecab99dec Allow break and co to go through try{} blocks 2022-12-28 20:56:58 +00:00
Maybe Waffle
16264a3a53 fixup a doc comment 2022-12-28 20:43:12 +00:00
bors
3033c3ddbf Auto merge of #13841 - nyurik:lints2, r=lnicola
Moar linting: needless_borrow, let_unit_value, ...

* There are a few needless borrows that don't seem to be needed. I even did a quick assembly comparison and posted a q to stackoveflow on it. See [here](https://stackoverflow.com/questions/74910196/advantages-of-pass-by-ref-val-with-impl-intoiteratoritem-impl-asrefstr)
* removed several `let _ = ...` when they don't look necessary (even a few ones that were not suggested by clippy (?))
* some unneeded assignment+return - keep the code a bit leaner
* a few `writeln!` instead of `write!`, or even consolidate write!
* a nice optimization to use `ch.is_ascii_digit` instead of `ch.is_digit(10)`
2022-12-27 19:46:03 +00:00
bors
74ae2dd303 Auto merge of #13840 - lowr:fix/hir-callable-sig-escaping-boundvars, r=lowr
fix: handle lifetime variables in `CallableSig` query

Fixes #13838

The problem is similar to #13223: we've been skipping non-empty binders, letting lifetime bound variables escape.

I ended up refactoring `hir_ty::callable_sig_from_fnonce()`. Like #13223, I chose to make use of `InferenceTable` which is capable of handling variables (I feel we should always use it when we solve trait-related stuff instead of manually building obligations/queries).

I couldn't make up a test that crashes without this patch (since the function I'm fixing is only used *outside* `hir-ty`, simple `hir-ty` test wouldn't cause crash), but at least I tested with my local build and made sure it doesn't crash with the code in the original issue. I'd appreciate any help to find a regression test.
2022-12-25 14:53:16 +00:00
Ryo Yoshida
a1a408367e
Add regression test 2022-12-25 23:29:33 +09:00
Yuri Astrakhan
d3dbf9c194 Moar linting: needless_borrow, let_unit_value, ...
* There are a few needless borrows that don't seem to be needed. I even did a quick assembly comparison and posted a q to stackoveflow on it. See [here](https://stackoverflow.com/questions/74910196/advantages-of-pass-by-ref-val-with-impl-intoiteratoritem-impl-asrefstr)
* removed several `let _ = ...` when they don't look necessary (even a few ones that were not suggested by clippy (?))
* there were a few `then(|| ctor{})` that clippy suggested to replace with `then_some(ctor{})` -- seems reasonable?
* some unneeded assignment+return - keep the code a bit leaner
* a few `writeln!` instead of `write!`, or even consolidate write!
* a nice optimization to use `ch.is_ascii_digit` instead of `ch.is_digit(10)`
2022-12-25 05:07:47 -05:00
Ryo Yoshida
a639917b66
fix: handle lifetime variables in CallableSig query 2022-12-25 05:07:44 +09:00
Yuri Astrakhan
e16c76e3c3 Inline all format arguments where possible
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
bors
1927c2e1d8 Auto merge of #13830 - nyurik:lints, r=lnicola
Minor manual cleanup

* use default derive
* use `strip_prefix` where possible to avoid dup work
2022-12-24 17:58:32 +00:00
bors
fb0db2a420 Auto merge of #13831 - bvanjoi:fix_bound_type_in_trait_insert, r=Veykril
fix(completion): remove bound insert of type in trait

Fixed https://github.com/rust-lang/rust-analyzer/issues/13819
2022-12-23 12:27:44 +00:00
bvanjoi
67cbd8f7c1 fix(completion): remove bound insert of type in trait 2022-12-23 18:45:25 +08:00
Yuri Astrakhan
ec55dd1d7b Minor manual cleanu
* use default derive
* use `strip_prefix` where possible to avoid dup work
2022-12-23 03:11:53 -05:00
Yuri Astrakhan
e341e996f7 Clippy-fix explicit auto-deref
Seems like these can be safely fixed. With one, I was particularly
surprised -- `Some(pats) => &**pats,` in body.rs?

```
cargo clippy --fix -- -A clippy::all -D clippy::explicit_auto_deref
```
2022-12-23 02:52:14 -05:00
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