Commit Graph

25150 Commits

Author SHA1 Message Date
hkalbasi
c5ea2d7adc handle match scrutinee in closure captures 2023-05-19 12:04:12 +03:30
bors
e8ae2d3976 Auto merge of #14848 - bm-w:fix/highlight-let-else-return, r=Veykril
Fix `preorder_expr` skipping the `else` block of let-else statements

Fixes exit/yield points not getting highlighted in such blocks for `highlight_related` (#14813; and possibly other bugs in features that use `preorder_expr`).
2023-05-19 07:41:46 +00:00
Lukas Wirth
c0519daf3b
Update crates/ide-db/src/syntax_helpers/node_ext.rs
Co-authored-by: Bastiaan Marinus van de Weerd <id@bm-w.eu>
2023-05-19 09:33:57 +02:00
Bastiaan Marinus van de Weerd
5857836047
Fix preorder_expr skipping the else block of let-else statements
Fixes exit/yield points not getting highlighted in such blocks for `highlight_related` (#14813; and possibly other bugs in features that use `preorder_expr`).
2023-05-18 18:30:27 -04:00
bors
e110696118 Auto merge of #14845 - HKalbasi:layout, r=HKalbasi
Add layout info for enum variant and locals

The size of enum variant is what rustdoc shows (https://github.com/rust-lang/rust/pull/86263). I also added layout info for locals since it helps finding size of unnameable types like closures inside other structs or impl traits.
2023-05-18 19:56:16 +00:00
hkalbasi
cae9660a1d Add layout info for enum variant and locals 2023-05-18 21:03:03 +03:30
bors
54129fa113 Auto merge of #14789 - HKalbasi:mir, r=HKalbasi
Add `moved-out-of-ref` diagnostic

This is marked as experimental, since spans are terrible, there are some false positives due #14754, and it doesn't play well with unknown types. But I hope we can soon lift it.
2023-05-18 15:54:14 +00:00
hkalbasi
b55fbd3ad7 Add moved-out-of-ref diagnostic 2023-05-18 19:17:06 +03:30
bors
09d1265e1e Auto merge of #14843 - HKalbasi:mir3, r=HKalbasi
Partially support panic message in `MirEvalError`

And bring the metrics back, by using `::core` instead of `$crate` in `format_args!` (it looks like eager macros don't support them).
2023-05-18 15:15:45 +00:00
hkalbasi
4adfbbfbad partially support panic message in MirEvalError 2023-05-18 18:30:49 +03:30
bors
9ce95674e8 Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril
Support c string literals
2023-05-18 11:55:38 +00:00
Lukas Wirth
3e528b85f9 Fix cstring literals construct &CStr not &str 2023-05-18 12:03:15 +02:00
bors
034d7c8537 Auto merge of #14787 - HKalbasi:mir2, r=HKalbasi
MIR episode 5

This PR inits drop support (it is very broken at this stage, some things are dropped multiple time, drop scopes are wrong, ...) and adds stdout support (`println!` doesn't work since its expansion is dummy, but `stdout().write(b"hello world\n")` works if you use `RA_SYSROOT_HACK`) for interpreting. There is no useful unit test that it can interpret yet, but it is a good sign that it didn't hit a major road block yet.

In MIR lowering, it adds support for slice pattern and anonymous const blocks, and some fixes so that we can evaluate `SmolStr::new_inline` in const eval. With these changes, 57 failed mir body remains.
2023-05-18 09:44:26 +00:00
Lukas Wirth
eab295cc73 Fix mir CString lowering not respecting the extra 0 byte for length calc 2023-05-18 11:29:19 +02:00
bors
f9be79603a Auto merge of #14820 - HKalbasi:format-args, r=HKalbasi
Expand `format_args!` with more details
2023-05-18 09:09:06 +00:00
Lukas Wirth
4b577e2bc8 Support c string literals 2023-05-18 11:06:05 +02:00
hkalbasi
5c83e222a3 fix format_args expansion error with raw strings 2023-05-18 12:32:41 +03:30
bors
e4977e74de Auto merge of #14836 - Veykril:rustc-lexer, r=Veykril
internal: Bump rustc_lexer
2023-05-18 08:50:49 +00:00
Lukas Wirth
099b5b3b15 internal: Bump rustc_lexer 2023-05-18 10:17:40 +02:00
bors
1c0235e3ff Auto merge of #14802 - HKalbasi:layout, r=HKalbasi
Fix layout for `hir_ty::Ty` and friends
2023-05-18 08:04:06 +00:00
hkalbasi
261047d019 Fix layout for hir_ty::Ty and friends 2023-05-18 11:29:03 +03:30
bors
0a806fe7ad Auto merge of #14835 - Veykril:inlay-pad, r=Veykril
fix: Fix bind pat hint padding
2023-05-18 07:14:59 +00:00
Lukas Wirth
03fb1310c2 fix: Fix bind pat hint padding 2023-05-18 08:48:53 +02:00
bors
673008aaa2 Auto merge of #14822 - Veykril:augmentsSyntaxTokens-vscode, r=Veykril
fix: Force disable augmentsSyntaxTokens capability on VSCode

The default textmate grammar for rust in VSCode is pretty brittle, quite often coloring things very differently than we'd like to so we force full semantic highlighting by disabling that config.
2023-05-18 06:48:21 +00:00
Lukas Wirth
0028e73927 fix: Force disable augmentsSyntaxTokens capability on VSCode 2023-05-18 08:26:16 +02:00
bors
c7b03491cd Auto merge of #14834 - Veykril:ty-diag-unit, r=Veykril
internal: Less file parsing for symbol index generation
2023-05-18 06:25:40 +00:00
Lukas Wirth
d6dcfa5744 internal: Less file parsing for symbol index generation 2023-05-18 08:25:06 +02:00
bors
c06f088968 Auto merge of #14823 - Veykril:discriminant-inlays, r=Veykril
fix: Discriminant hints only render for datacarrying enums with primitive repr
2023-05-18 05:50:41 +00:00
bors
07baa176c2 Auto merge of #14828 - lowr:fix/macro_use_prelude_is_in_scope, r=Veykril
fix: process `macro_use` prelude in semantic scope resolver

Fixes #14826
2023-05-18 05:36:24 +00:00
bors
b7b026bce6 Auto merge of #14825 - HKalbasi:float-const-eval, r=Veykril
Fix evaluating negative for floating point types

fix #14704
Unary operators was missed from #14705
2023-05-18 05:22:41 +00:00
bors
a20a08f3e2 Auto merge of #14824 - Veykril:ty-diag-unit, r=Veykril
fix: Diagnose non-value return and break type mismatches

Could definitely deserve more polished diagnostics, but this at least brings the message across for now.
2023-05-18 05:03:42 +00:00
bors
c4026bf9b9 Auto merge of #14818 - poliorcetics:type-hints-after-item, r=Veykril
fix: place type inlay hints after the item and without left-padding

**Before**:

![Type hints were placed before the item and there was left-padding that accentuaded the issue](https://github.com/rust-lang/rust-analyzer/assets/7951708/006a28e9-ed7b-4d49-a7e7-3c6da8efca79)

**After**:

![Type hints are now placed after the item and without padding since there already is `: ` in front of the type](https://github.com/rust-lang/rust-analyzer/assets/7951708/330a847f-8c59-40c7-877f-bf1aaced30e2)
2023-05-18 04:50:09 +00:00
bors
72a1796615 Auto merge of #14819 - weihanglo:divided-by-zero, r=lnicola
fix(analysis-stats): divided by zero error

## What does this PR try to resolve?

2023-05-15 rust-analyzer suffers from

```
 thread 'main' panicked at 'attempt to divide by zero', crates/rust-analyzer/src/cli/analysis_stats.rs:230:56
```

This commit <51e8b8ff14> might be the culprit.

This PR uses `percentage` function to avoid the classic “division by zero” bug.

## Reproducer

```console
cargo new ra-test
pushd ra-test
echo "pub type Foo = u32;" >> src/lib.rs
rust-analyzer analysis-stats .
```
2023-05-18 02:09:55 +00:00
bors
d0768aad62 Auto merge of #14812 - Veykril:highlight-trait-assoc, r=HKalbasi
feat: Highlight used trait assoc items when cursor is on trait import or trait bound
2023-05-18 01:53:30 +00:00
bors
88d2125d2f Auto merge of #14811 - Veykril:closure-hover, r=HKalbasi
feat: Render hover actions for closure captures and sig

Also special cases closures for ranged type hover to render the closure hover instead
2023-05-18 01:32:17 +00:00
Ryo Yoshida
68a74decb6
Process macro_use prelude in semantic scope resolver 2023-05-17 17:45:44 +09:00
hkalbasi
fd034bea1a Fix evaluating negative for floating point types 2023-05-17 01:27:45 +03:30
hkalbasi
a2fba7c67e Add test for eager expanding of format_args 2023-05-17 01:15:04 +03:30
Lukas Wirth
478705baf5 fix: Diagnose non-value return and break type mismatches 2023-05-16 22:47:27 +02:00
Lukas Wirth
c12ede8c34 fix: Discriminant hints only render for datacarrying enums with primitive repr 2023-05-16 22:15:39 +02:00
hkalbasi
a6e5a912f9 Expand format_args! with more details 2023-05-16 19:12:40 +03:30
Alexis (Poliorcetics) Bourget
22599adf9b fix: place type inlay hints after the item and without left-padding 2023-05-16 15:13:48 +02:00
Weihang Lo
77be56b691
fix(analysis-stats): divided by zero error 2023-05-16 13:57:36 +01:00
Lukas Wirth
b87ee914fa feat: Highlight used trait assoc items when cursor is on trait import or trait bound 2023-05-15 20:41:35 +02:00
Lukas Wirth
ba8bcde4f5 Also render coercions for ranged type hover on closures 2023-05-15 19:45:01 +02:00
Lukas Wirth
08dc0e21af feat: Render hover actions for closure captures and sig 2023-05-15 19:35:27 +02:00
bors
2f8cd66fb4 Auto merge of #14810 - Veykril:inline-module, r=Veykril
internal: Inline handlers module
2023-05-15 10:19:21 +00:00
bors
9eb26a9375 Auto merge of #14809 - lowr:patch/macro_use-filter, r=Veykril
Support `#[macro_use(name, ...)]`

This PR adds support for another form of the `macro_use` attribute: `#[macro_use(name, ...)]` ([reference]).

Note that this form of the attribute is only applicable to extern crate decls, not to mod decls.

[reference]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2023-05-15 10:04:05 +00:00
Lukas Wirth
9e80c8571d internal: Inline handlers module 2023-05-15 11:59:09 +02:00
bors
1e6bd6cb0d Auto merge of #14794 - Veykril:inlay-kind-refac, r=Veykril
Restructure InlayHint, no longer derive properties from its kind

Closes https://github.com/rust-lang/rust-analyzer/issues/14595
2023-05-15 09:49:17 +00:00