Commit Graph

25272 Commits

Author SHA1 Message Date
bors
7ac161ce77 Auto merge of #14863 - lowr:fix/extract-fn-nested-tt, r=lnicola
fix: consider all tokens in macro expr when analyzing locals

Fixes #14687

2 fixes for `extract_function` assist (related closely enough that I squashed into one commit):

- Locals in macro expressions have been analyzed only when they are in the top-level token tree the macro call wraps. We should consider all descendant tokens.
- `self` in macro expressions haven't been analyzed.
2023-05-21 12:40:29 +00:00
Ryo Yoshida
7b70988d48
fix: consider all tokens in macro expr when analyzing locals
Also consider `self` token along with ordinary identifiers.
2023-05-21 20:07:36 +09:00
bors
a04d8456be Auto merge of #14855 - HKalbasi:mir, r=HKalbasi
Consider block impls in `lookup_impl_assoc_item_for_trait_ref`

fix #14782
2023-05-20 20:55:22 +00:00
Luna Razzaghipour
a416248296
Extract platform-specific QoS code into module 2023-05-21 02:48:30 +10:00
Luna Razzaghipour
bb02ae7532
Add doc comments for QoSClass 2023-05-21 02:02:30 +10:00
Luna Razzaghipour
91f4fbe596
Improve comments 2023-05-21 02:02:21 +10:00
Luna Razzaghipour
ca6461c143
Add proof-of-concept QoS implementation 2023-05-20 22:29:32 +10:00
bors
4de8c0980e Auto merge of #14857 - Veykril:perf, r=Veykril
internal: Shrink ProcMacroExpander from 8 to 4 bytes
2023-05-20 10:00:43 +00:00
Lukas Wirth
14dc1ac3bf internal: Shrink ProcMacroExpander from 8 to 4 bytes 2023-05-20 11:31:28 +02:00
hkalbasi
92d6670f72 Consider block impls in lookup_impl_assoc_item_for_trait_ref 2023-05-20 01:11:17 +03:30
bors
bb78059be4 Auto merge of #14847 - HKalbasi:layout, r=HKalbasi
Reduce MIR memory usage
2023-05-19 12:06:11 +00:00
bors
ce936177f9 Auto merge of #14851 - HKalbasi:mir, r=HKalbasi
Handle match scrutinee in closure captures

fix #14754
2023-05-19 11:25:40 +00:00
hkalbasi
60379dabfb resolve types in closure capture copy detection 2023-05-19 14:54:57 +03:30
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
hkalbasi
23ce228d54 Reduce MIR memory usage 2023-05-19 00:16:52 +03:30
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