Commit Graph

13146 Commits

Author SHA1 Message Date
Aleksey Kladov
c0556bd8c1 minor: improve readability 2021-09-18 15:56:26 +03:00
Aleksey Kladov
ed84717869 internal: better naming 2021-09-18 15:55:07 +03:00
Aleksey Kladov
3dc2aeea0f internal: parser cleanup 2021-09-18 15:46:28 +03:00
Aleksey Kladov
af9fd37cd9 internal: minimize use_tree parser tests
The code here is intentionally dense and does exactly what is written.
Explaining semantic difference between Rust 2015 and 2018 doesn't help
with understanding syntax. Better to just add more targeted tests.
2021-09-18 15:22:49 +03:00
bors[bot]
dd12521ac9
Merge #10275
10275: internal: parser cleanups r=Veykril a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-18 12:20:55 +00:00
Aleksey Kladov
1d2e9818d6 internal: parser cleanups 2021-09-18 14:53:46 +03:00
Aleksey Kladov
aaadaa40bd internal: more focused trait item parsing tests 2021-09-18 14:34:29 +03:00
Lukas Wirth
6465868449 Make inlay hints work in attributed items 2021-09-18 13:19:29 +02:00
Lukas Wirth
11a17c803f Add multi-token mapping test for goto_definition 2021-09-18 12:00:12 +02:00
bors[bot]
a435e49d34
Merge #10252
10252: fix: make `goto_definition` multi-token mapping aware r=Veykril a=XFFXFF

Implement #10070 in  [`goto_definition`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_definition.rs)

Co-authored-by: zhoufan <1247714429@qq.com>
2021-09-18 01:21:43 +00:00
zhoufan
227450f9b9 do comment handling on the original token 2021-09-18 08:22:57 +08:00
bors[bot]
7c03200d70
Merge #10267
10267: Narrow "if-let to match" assist available range r=Veykril a=rainy-me

ref: https://github.com/rust-analyzer/rust-analyzer/issues/10220

Co-authored-by: rainy-me <github@rainy.me>
2021-09-17 22:44:39 +00:00
Aleksey Kladov
3474e3b3b1 intenral: more local tests for statics 2021-09-18 01:02:43 +03:00
Aleksey Kladov
1feb8e89d5 minor: cleanup const parsing 2021-09-18 00:58:35 +03:00
Aleksey Kladov
46326b8db7 minor: better test placement 2021-09-18 00:54:03 +03:00
Aleksey Kladov
2195ecd7e7 internal: cleanup adt parsing 2021-09-18 00:50:27 +03:00
Aleksey Kladov
d890c767c4 internal: cleanup item parsing 2021-09-18 00:33:42 +03:00
Aleksey Kladov
ec2043a082 minor: parser cleanup 2021-09-18 00:14:20 +03:00
Aleksey Kladov
4d2956e775 minor: simplify 2021-09-17 23:31:37 +03:00
rainy-me
11fbafdee3 Narrow "if-let to match" assist available range 2021-09-18 05:28:52 +09:00
Aleksey Kladov
366d3d7544 minor: cleanup 2021-09-17 23:27:26 +03:00
bors[bot]
4badd2faf8
Merge #10265
10265: internal: parser cleanups r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-17 19:27:32 +00:00
Aleksey Kladov
329b01ca67 minor: simplify 2021-09-17 22:26:39 +03:00
Aleksey Kladov
77e8421d0f internal: more local parsing tests for macros 2021-09-17 22:21:57 +03:00
Aleksey Kladov
073d5f7733 internal: more focused parsing tests 2021-09-17 22:15:12 +03:00
Aleksey Kladov
55078c81e0 internal: more local test for mod item 2021-09-17 21:53:24 +03:00
Aleksey Kladov
715cd8d938 internal: more local parsing tests 2021-09-17 21:49:01 +03:00
Aleksey Kladov
f632b5e481 internal: parser cleanups 2021-09-17 21:40:28 +03:00
bors[bot]
d44779f8a5
Merge #10260
10260: fix: fix names generation in `Generate function` r=Veykril a=iDawer

- Improve fn name computation (close #10176).
- Handle tuple indexing expressions in argument position (should close  #10241)

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-17 18:35:36 +00:00
Dawer
0ff271d38f fix completion handler trying to seek outside of character boundaries.
With this patch, in these examples
```rust
fn main() {
    "⊞$0";
}
```

```rust
struct S {
д$0 u8
}
```
entering ':' character in `$0` places shouldn't cause panics.
2021-09-17 23:04:20 +05:00
bors[bot]
00b19846c9
Merge #10257
10257: assists: turn while into loop r=Veykril a=agluszak

Implements an assist to turn a `while` loop into a `loop` loop, as requested in #10214. 
I'm not sure sure what the guidelines are regarding naming assists convert_x_to_y vs replace_x_with_y.

This is my first commit to rust-analyzer :D Thank you `@matklad` for your awesome Explaining rust-analyzer series <3

Closes #10214 

Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2021-09-16 21:04:42 +00:00
Andrzej Głuszak
11a56f886b assists: turn while into loop 2021-09-16 22:20:27 +02:00
Dawer
1d94e234d5 Handle tuple indexing expression in argument position in Generate function 2021-09-16 23:45:41 +05:00
Dawer
4dc33140a3 Imrove fn name computation in Generate function 2021-09-16 21:03:37 +05:00
teor
e0a501424c
Fix a comment typo in autoderef.rs 2021-09-16 13:47:01 +10:00
zhoufan
ea3535cefc fix: multi-token mapping aware goto definition 2021-09-16 09:44:22 +08:00
bors[bot]
959c7ef563
Merge #10250
10250: internal: Improve call_hierarchy and incoming/outgoing_calls r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-16 00:26:32 +00:00
Lukas Wirth
d777eddf0d Improve call_hierarchy and incoming/outgoing_calls 2021-09-16 02:25:02 +02:00
bors[bot]
c577e128fc
Merge #10248
10248: internal: remove dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-15 18:23:46 +00:00
Aleksey Kladov
73b0f9dc04 internal: remove dead code 2021-09-15 21:22:06 +03:00
bors[bot]
911659a166
Merge #10048
10048: fix: correctly complete macro call if cursor at `!` r=Veykril a=unexge

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

Co-authored-by: unexge <unexge@gmail.com>
2021-09-15 18:13:09 +00:00
bors[bot]
4c9eef7ede
Merge #10233
10233: fix: add multi-token mapping support to hovers r=Veykril a=spookyvision

implement #10070 in [`hover`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/hover.rs)

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-09-15 16:36:33 +00:00
Anatol Ulrich
45090e4f4b add multi-token mappings for hover 2021-09-15 18:05:53 +02:00
Anatol Ulrich
b251a30819 # This is a combination of 3 commits.
# This is the 1st commit message:

add multi-token mappings for hover

# The commit message #2 will be skipped:

# make fallback an Option instead of vec

# The commit message #3 will be skipped:

# fix indentation
2021-09-15 18:04:45 +02:00
Lukas Wirth
33cdc21832 Don't highlight unsafe traits as unsafe in safe impls 2021-09-15 15:46:45 +02:00
Lukas Wirth
64fb7be247 Revert attributed items inlay hints 2021-09-14 20:30:28 +02:00
Lukas Wirth
747f2d1719 fix: Do not wrap inlined local in parens when at block tail position 2021-09-14 18:29:34 +02:00
bors[bot]
f750eebd0d
Merge #10232
10232: internal: Add more tests for ide functionality in attributed items r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/9868

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-14 12:54:00 +00:00
Lukas Wirth
0f4463e45e fix source_to_def trying to use attribute macro calls as containers 2021-09-14 14:42:14 +02:00
Lukas Wirth
d1e489185f Pick smaller node ancestors first when descending at offset 2021-09-14 14:10:59 +02:00
Lukas Wirth
538ac599d2 Add some more attribute ide tests 2021-09-14 03:57:29 +02:00
Lukas Wirth
6f9de71402 fix: Use original definition ranges for ide_db::search instead of the expanded ranges 2021-09-14 02:49:06 +02:00
bors[bot]
e896def412
Merge #10204
10204: feat: Show the type of what is being dereferenced in a deref expression. r=theo-lw a=theo-lw

Addresses issue #10106.

In-progress - I'm trying to figure out why `hover_deref_expr_with_coercion` is failing.

Co-authored-by: Teddy_Wang <wangtheo662@gmail.com>
2021-09-14 00:41:17 +00:00
Teddy_Wang
8de5d66e25 Improve hover over derference message 2021-09-13 20:19:30 -04:00
bors[bot]
e08b3bf70b
Merge #10231
10231: feat: Make inlay hints work in attributed items r=Veykril a=Veykril

![image](https://user-images.githubusercontent.com/3757771/133172697-8563329f-e77e-46e4-86ab-99b50040dfd5.png)
Note the lack of chaining hints, this is currently due to macro expansion lacking the input whitespace. We might be able to recover this from the input somehow in the future.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10043
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-14 00:07:50 +00:00
Lukas Wirth
e193e3b076 feat: Make inlay hints work in attributed items 2021-09-14 01:59:45 +02:00
Teddy_Wang
4d9728ccb2 Fix hover tests 2021-09-13 19:47:53 -04:00
bors[bot]
42617231bd
Merge #10230
10230: fix: fix expansion order for fn-like macros and attributes in token descending r=Veykril a=Veykril

Second attempt(now with a test 🎉).
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10115

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-13 23:24:33 +00:00
Lukas Wirth
8f76e41e18 Enable attribte macros in ide fixtures 2021-09-14 01:23:13 +02:00
Lukas Wirth
bb946f78f6 fix: fix expansion order for fn-like macros and attributes in token descending 2021-09-14 01:20:43 +02:00
Teddy_Wang
0c6a993f59 Fix spelling 2021-09-13 19:16:10 -04:00
bors[bot]
249ebdd076
Merge #10229
10229: fix: do not complete builtin attributes for qualified paths r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-13 22:31:39 +00:00
Lukas Wirth
845904f0bb fix: do not complete builtin attributes for qualified paths 2021-09-14 00:31:14 +02:00
bors[bot]
6eecd84771
Merge #10126
10126: feat: Speculatively expand attributes in completions r=Veykril a=Veykril

![j1OjBt5Nca](https://user-images.githubusercontent.com/3757771/133163858-91930072-1441-4ce4-9979-b0ad2727b47f.gif)

Fixes #9866

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-13 22:22:08 +00:00
Lukas Wirth
dfb94d09d4 Exclude test file from rust tidy check 2021-09-14 00:21:16 +02:00
Lukas Wirth
aa1b36dc6d Downmap the token in attribute inputs when expanding speculatively 2021-09-14 00:04:04 +02:00
bors[bot]
bcf0072bb4
Merge #10199
10199: fix: Fix Cargo.toml change detection r=lnicola a=lnicola

Maybe fixes #9546

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-13 18:14:20 +00:00
Laurențiu Nicola
4d7a3bb5c7 Shuffle code around to avoid an allocation 2021-09-13 21:06:31 +03:00
Lukas Wirth
2b907652ee Speculatively expand attributes in completions 2021-09-13 19:30:23 +02:00
bors[bot]
c3eb646487
Merge #10225
10225: internal: Add proc-macro fixture directive r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-13 17:07:23 +00:00
Lukas Wirth
a044175412 Simplify 2021-09-13 18:50:19 +02:00
Lukas Wirth
edc915fbb6 Add proc-macro fixture directive 2021-09-13 18:37:50 +02:00
Laurențiu Nicola
8875f2c8aa Fix Cargo.toml change detection 2021-09-13 19:15:17 +03:00
Aleksey Kladov
46cdde75f8 internal: document tribal knowledge of how to assist 2021-09-13 14:19:10 +03:00
Aleksey Kladov
076c972e3b internal: prevent possible bugs when adding magical comments 2021-09-13 13:43:13 +03:00
Aleksey Kladov
c56f041477 internal: simplify 2021-09-13 13:35:31 +03:00
Aleksey Kladov
940b3afd00 internal: fix bugs in tests by simplifying code 2021-09-13 13:29:27 +03:00
Aleksey Kladov
80991356e1 minore: improve readability
Tuples are hard to understand
2021-09-13 12:34:05 +03:00
Lukas Wirth
95746a99b4 Use correct file syntax node for decl_access computation in find_all_refs 2021-09-12 23:19:23 +02:00
bors[bot]
3e056b9e90
Merge #10213
10213: minor: Improve resilience of match checking r=flodiebold a=iDawer

In bug condition the match checking strives to recover giving false no-error diagnostic.

Suggested in https://github.com/rust-analyzer/rust-analyzer/pull/9105#discussion_r644656085

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-12 12:23:56 +00:00
Dawer
68dfe190ab Improve resilience of match checking
In bug condition the match checking strives to recover giving false no-error diagnostic.
2021-09-12 16:03:12 +05:00
Florian Diebold
a2d9f7d7bb Avoid type inference panic on bitslice methods
Should fix #10090, #10046, #10179.
This is only a workaround, but the proper fix requires some bigger
refactoring (also related to fixing #10058), and this at least prevents
the crash.
2021-09-12 10:49:40 +02:00
bors[bot]
317059985a
Merge #10202
10202: fix: Type param hover shows correct sized bounds. r=flodiebold a=iDawer

Closes  #9949

This adds implicit `: Sized` bound to type parameters at lowering step.

Hovering on type parameter does not show it's `: Sized` bound be it set explicitly or implicitly. This is because it doesn't track that the bound was set implicitly.

### Perf

```rust
./target/rust-analyzer-baseline-3dae94bf -q analysis-stats --memory-usage .
Database loaded:     4.51s, 311minstr, 110mb (metadata 1.08s, 22minstr, 743kb; build 3.20s, 8730kinstr, -237kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.63s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           118.25s, 284ginstr, 601mb
Total:               147.88s, 370ginstr, 973mb

./target/rust-analyzer-hover-ty-param-dfb15292 -q analysis-stats --memory-usage .
Database loaded:     4.53s, 311minstr, 110mb (metadata 1.10s, 22minstr, 743kb; build 3.20s, 8672kinstr, -189kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.59s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           121.69s, 296ginstr, 601mb
Total:               151.28s, 382ginstr, 974mb

```

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-12 07:54:56 +00:00
longfangsong
cafc7e3501 Fix doc test 2021-09-12 11:20:28 +08:00
longfangsong
3edc25dc26 Add docs strings 2021-09-12 10:53:56 +08:00
longfangsong
fede1a3beb Add promote_mod_file assist 2021-09-12 10:45:14 +08:00
Aleksey Kladov
9b2bac621e minor: make code clearer with ControlFlow 2021-09-11 20:49:10 +03:00
bors[bot]
abdb75912c
Merge #10207
10207: minor: improve readability r=matklad a=matklad

It's important that module interface doesn't depend on features. Better
hide features in bodies.

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-11 15:46:36 +00:00
Aleksey Kladov
e5b813b566 minor: improve readability
It's important that module interface doesn't depend on features. Better
hide features in bodies.
2021-09-11 18:42:38 +03:00
Teddy_Wang
1d4d9a1e1a Fix tests by importing core::ops::Deref 2021-09-11 11:40:16 -04:00
Giles Cope
15312aab58
removing seemingly unused dev deps. 2021-09-11 16:26:36 +01:00
Giles Cope
4ccd90af81
remove unused deps 2021-09-11 16:20:04 +01:00
Dawer
964c7b3211 minor: fix tests. 2021-09-10 23:02:37 +05:00
Dawer
dfb15292c2 fix: Type param hover shows correct sized bounds. 2021-09-10 20:48:39 +05:00
Dawer
9ce3c075ad internal: add implicit : Sized bound to type parameters. 2021-09-10 20:41:53 +05:00
bors[bot]
07fb5db3dc
Merge #10177
10177: fix: Treat path dependencies like workspace members r=jonas-schievink a=jonas-schievink

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

Fixes diagnostics not showing up in path dependencies.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-10 14:14:02 +00:00
Teddy_Wang
67a9c457e6 Add tests. The tests with coercion fail, but I have no clue why. 2021-09-09 23:31:13 -04:00
Jonas Schievink
9a320bcf38 Support the new rustc_builtin_macro syntax 2021-09-09 21:32:41 +02:00
bors[bot]
8e47e359fa
Merge #10190
10190: minor: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-09 18:13:26 +00:00
Laurențiu Nicola
c930dcca13 Bump chalk 2021-09-09 21:12:38 +03:00
Jörg Sommer
c87b860d3d Use todo!() instead of () for missing fields
The generated code with `()` doesn't compile in most of the cases. To signal
the developer there's something to do, fill in `todo!()`.

Because the file *missing_fields.rs* contains the string `todo!()` it needs
an exception for the test *check_todo*.
2021-09-09 18:04:50 +02:00
bors[bot]
92ce768ea3
Merge #10188
10188: fix: add multi-token mapping support to runnables r=jonas-schievink a=lnicola

Closes #10184


changelog fix (first contribution) add multi-token mapping support to runnables

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-09-09 15:07:43 +00:00
Anatol Ulrich
5d08ac20d9 implement #10070 in runnables
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-09 18:02:53 +03:00
Teddy_Wang
cf696c0ed6 Show the type of what is being dereferenced in a deref expression 2021-09-08 22:28:52 -04:00
Jonas Schievink
85993171e5 minor: include ImplLoc in panic context 2021-09-09 02:20:55 +02:00
bors[bot]
6a8062092b
Merge #10174
10174: fix: path display error when start with `crate` r=flodiebold a=dzvon

Fixes  #10172

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2021-09-08 14:40:54 +00:00
Yotam Ofek
ebb891246c Split and document array method resolution logic. 2021-09-08 13:15:40 +03:00
Yotam Ofek
9593fe684d Fix resolution of inherent array methods. 2021-09-08 11:49:05 +03:00
Yotam Ofek
1785493cae Add (failing) test for inherent array method resolution. 2021-09-08 11:00:55 +03:00
Jonas Schievink
e241015a75 Rename is_member to is_local 2021-09-07 17:29:58 +02:00
Jonas Schievink
8a4c35a068 Treat path dependencies like workspace members 2021-09-07 17:26:21 +02:00
Dezhi Wu
87436a08fa fix super path wrong display 2021-09-07 17:49:46 +08:00
Dezhi Wu
880af425d4 fix path wrong display 2021-09-07 16:54:02 +08:00
Dezhi Wu
6d2154e409 cargo fmt 2021-09-07 14:50:33 +08:00
Dezhi Wu
82ae228d98 fix: path display error when start with crate 2021-09-07 14:44:30 +08:00
Aleksey Kladov
682fbbbd5a minor: modernize 2021-09-06 18:54:16 +03:00
Aleksey Kladov
104cd0ce88 internal: make name consistent with usage 2021-09-06 18:34:03 +03:00
bors[bot]
7d9eb4fd73
Merge #10167
10167: minor: Avoid extra allocation in completion rendering r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-06 15:15:10 +00:00
Laurențiu Nicola
d27ed8c243 Avoid extra allocation in completion rendering 2021-09-06 17:55:07 +03:00
David Barsky
184fbf24f0 update to tracing-tree 0.1.10, which does not pull in syn. 2021-09-06 10:33:08 -04:00
bors[bot]
cbc13ae6bd
Merge #10152
10152: feat: Add completion for raw identifiers r=matklad a=nabakin

![rust_analyzer_pr](https://user-images.githubusercontent.com/894305/132110362-c21b713d-acaf-4a6d-9749-ff812172cbce.gif)
Adds support for valid Rust completion of raw identifiers.

Previously, code completion of fields made via raw identifiers would not re-insert those raw identifiers, resulting in invalid Rust code. Now, code completion of fields made via raw identifiers do re-insert those raw identifiers, resulting in valid Rust code.

The same is true for all code completion instances for fields and compatible Rust identifiers.

Co-authored-by: Blake Wyatt <894305+nabakin@users.noreply.github.com>
2021-09-06 10:54:18 +00:00
bors[bot]
0bc8e2acb8
Merge #10154
10154: feat: Complete `#![recursion_limit = "N"]` instead of `#![recursion_limit = N]` r=lnicola a=hkmatsumoto

Currently ra emits `#![recursion_limit = 128]`, but this should rather be `#![recursion_limit = "128"]`

Co-authored-by: Hirochika Matsumoto <git@hkmatsumoto.com>
2021-09-06 10:38:41 +00:00
Jonas Schievink
8e736da456 Recover from statement macro expansion errors 2021-09-06 00:16:12 +02:00
Aleksey Kladov
dbb702cfc1 internal: remove accidental code re-use
FragmentKind played two roles:

* entry point to the parser
* syntactic category of a macro call

These are different use-cases, and warrant different types. For example,
macro can't expand to visibility, but we have such fragment today.

This PR introduces `ExpandsTo` enum to separate this two use-cases.

I suspect we might further split `FragmentKind` into `$x:specifier` enum
specific to MBE, and a general parser entry point, but that's for
another PR!
2021-09-05 22:36:36 +03:00
Jonas Schievink
d6a12b491f Don't dump DefMaps to build the panic context 2021-09-05 20:42:22 +02:00
Jonas Schievink
7d67c71c34 Add panic info for impl_trait/trait_data 2021-09-05 19:19:34 +02:00
bors[bot]
487078feb5
Merge #10155
10155: Minor: replace old name `CrateDefMap` in comments r=jonas-schievink a=toyboot4e

This PR replaces the old name `CrateDefMap` in comments with the new name `DefMap`. The renaming was done in [57a82fb0](https://github.com/rust-analyzer/rust-analyzer/commit/57a82fb0) (Jan 2021).

I didn't touch the working code ([CrateDefMapQueryQuery][QQ]). Thank you.

[QQ]: https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/apply_change.rs#L126


Co-authored-by: toyboot4e <toyboot4e@gmail.com>
2021-09-05 16:57:46 +00:00
Jonas Schievink
65bb5d7511 Add crate name to nameres panic context 2021-09-05 18:48:34 +02:00
toyboot4e
89e46b40c3 Minor: replace old name CrateDefMap 2021-09-05 19:22:34 +09:00
Hirochika Matsumoto
1f238b3bb5 Complete #![recursion_limit = "N"] over #![recursion_limit = N] 2021-09-05 18:05:06 +09:00
Blake Wyatt
6c51ecad5b Add completion for raw identifiers 2021-09-04 19:28:59 -04:00
bors[bot]
fd30bd179c
Merge #10146
10146: fix: use placeholder as default type in `Generate function` and `Extract into function`. r=matklad a=iDawer

Closes #10123 

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-04 14:04:30 +00:00
bors[bot]
5fb2eb2314
Merge #10147
10147: fix: don't panic if the client sends invalid request r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-04 13:56:47 +00:00
Aleksey Kladov
2d2c4e7c22 internal: deduplicate 2021-09-04 16:56:23 +03:00
Dawer
535761e63f minor: update test 2021-09-04 15:19:44 +05:00
Aleksey Kladov
33199b7e43 fix: don't panic if the client sends invalid request 2021-09-04 12:27:27 +03:00
Dawer
3d9d10be39 fix: use placeholder as default type in Extract into function. 2021-09-04 14:25:17 +05:00
Dawer
a6c650edf6 fix: use placeholder as default type in Generate function. 2021-09-04 14:24:54 +05:00
Jade
1857b2b5d6 Update dependency minor versions 2021-09-04 00:27:05 -07:00
bors[bot]
5506e0dfaf
Merge #10139
10139: Fix replacing for loops over ranges with for_each. r=yotamofek a=yotamofek

Previously, the assist would turn this:
```rust
for x in 0..92 {
    ...
}
```
into the syntactically incorrect code below:
```rust
0..92.for_each(|x| ...)
```

This fixes the assist by parenthesizing range expressions.

Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com>
2021-09-03 18:03:52 +00:00
Yotam Ofek
dd9433cc63
Update crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-09-03 21:02:48 +03:00
bors[bot]
7234f943aa
Merge #10130
10130: fix error message for when DidChangeTextDocument path doesn't exist r=matklad a=alidn

Fixes #10129

Co-authored-by: Ali <59405723+alidn@users.noreply.github.com>
2021-09-03 17:49:23 +00:00
Yotam Ofek
0d453cc2be Fix replacing for loops over ranges with for_each. 2021-09-03 19:43:40 +03:00
bors[bot]
ac2520128d
Merge #10135
10135: minor: fix some clippy lints r=lnicola a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-03 14:28:27 +00:00
Lukas Wirth
36a5ce9790 minor: fix some clippy lints 2021-09-03 16:00:50 +02:00
Ali
1fd153a24e
fix error message for when DidChangeTextDocument path doesn't exist 2021-09-02 15:19:47 -07:00
Lukas Wirth
0fee14bfdd When descending tokens don't bail on failed macro call expansions 2021-09-02 19:12:08 +02:00
Lukas Wirth
e2ede38d47 Use correct search scopes for macros 2021-09-02 17:30:55 +02:00
bors[bot]
48f84a7b60
Merge #10114
10114: fix: Deduplicate imports for qualify_path r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-01 19:53:10 +00:00
Lukas Wirth
8e8ea537ab Deduplicate imports for qualify_path 2021-09-01 21:51:28 +02:00
Jonas Schievink
bdba35cc93 fix: multi-token mapping aware find references 2021-09-01 19:19:16 +02:00
bors[bot]
81ab52c6ca
Merge #10109
10109: fix: Enable flyimport for ident patterns r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-01 14:17:47 +00:00
Lukas Wirth
40a2faee65 Enable flyimport for ident patterns 2021-09-01 16:13:53 +02:00
Lukas Wirth
68bf359363 fix: make goto_implementation multi-token mapping aware 2021-09-01 14:51:37 +02:00
bors[bot]
25368d2430
Merge #9954
9954: feat: Show try operator propogated types on ranged hover  r=matklad a=Veykril

Basically this just shows the type of the inner expression of the `?` expression as well as the type of the expression that the `?` returns from:
![Code_wIrCxMqLH9](https://user-images.githubusercontent.com/3757771/130111025-f7ee0742-214a-493b-947a-b4a671e4be92.png)

Unless both of these types are `core::result::Result` in which case we show the error types only.
![Code_Xruw5FCBNI](https://user-images.githubusercontent.com/3757771/130111024-f9caef82-92e4-4070-b3dd-f2ff9e5d87a9.png)

If both types are `core::option::Option` with different type params we do not show this special hover either as it would be pointless(instead fallback to default type hover)

Very much open to changes to the hover text here(I suppose we also want to show the actual type of the `?` expression, that is its output type?).

Fixes #9931

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-01 09:26:10 +00:00
Lukas Wirth
8bbfd45d97 Minor fixes 2021-09-01 11:25:42 +02:00
Daiki Ihara
4d005e529b Fix extract_function with macro arg 2021-09-01 11:11:57 +02:00
unexge
e0e7f0c170 Move "complete macro call if cursor at ! token" logic to MacroRender 2021-09-01 09:11:20 +03:00
bors[bot]
535f0726f1
Merge #10101
10101: internal: reduce coupling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 16:15:44 +00:00
Aleksey Kladov
81602f8a5d internal: reduce coupling
tt is a data structure, data structures cant' go wrong, they shouldn't
have the knowledge that the world outside of them has all kinds of
errors.
2021-08-31 19:14:33 +03:00
bors[bot]
e8f0f234c3
Merge #10100
10100: internal: cleanup proc macro server error handlig r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 16:04:54 +00:00
Aleksey Kladov
d8a3d6f378 internal: cleanup proc macro server error handlig
When dealing with proc macros, there are two very different kinds of
errors:

* first, usual errors of "proc macro panicked on this particular input"
* second, the proc macro server might day if the user, eg, kills it

First kind of errors are expected and are a normal output, while the
second kind are genuine IO-errors.

For this reason, we use a curious nested result here: `Result<Result<T,
E1>, E2>` pattern, which is 100% inspired by http://sled.rs/errors.html
2021-08-31 19:01:39 +03:00
bors[bot]
2c538e9c8c
Merge #10099
10099: minor: improve readability r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 13:58:16 +00:00
bors[bot]
aa1cdc0cce
Merge #10095
10095: internal: Augment panic context when resolving path r=jonas-schievink a=jonas-schievink

Should help with debugging https://github.com/rust-analyzer/rust-analyzer/issues/10084 and similar issues.

Might have a perf impact since the string is created on every function call.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-08-31 12:47:33 +00:00
Aleksey Kladov
722a2a4690 minor: improve readability
naming, layout & comments help!
2021-08-31 15:46:00 +03:00
bors[bot]
4786a22787
Merge #10098
10098: minor: dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 12:27:27 +00:00
Aleksey Kladov
f1222e8085 minor: dead code 2021-08-31 15:26:59 +03:00
bors[bot]
bda50a1b46
Merge #10097
10097: fix: Allow inherent impls for arrays r=jonas-schievink a=jonas-schievink

Part of https://github.com/rust-analyzer/rust-analyzer/issues/9992 (method resolution of these methods still does not work)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-08-31 12:17:50 +00:00
Jonas Schievink
418b163a4b Allow inherent impl for arrays 2021-08-31 14:15:39 +02:00
Aleksey Kladov
51b955ec8a internal: simplify 2021-08-31 15:09:46 +03:00
Jonas Schievink
b1a4784c95 Augment panic context when resolving path 2021-08-31 13:42:46 +02:00
bors[bot]
f70086203b
Merge #10094
10094: internal: split database loading time in anaysis-stats into components r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 11:39:34 +00:00
Aleksey Kladov
8dbf3832b2 internal: split database loading time in anaysis-stats into components 2021-08-31 14:38:52 +03:00
bors[bot]
545cdf955e
Merge #10091
10091: fix: fix "disjunction in conjunction" panic r=matklad a=jonas-schievink

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

The DNF construction code created expressions that were combined in a way that made us "forget" to make their contents valid DNF again. This PR fixes that by flattening nested `any(any())` and `all(all())` predicates. There was also a typo that led to a redundant call to `make_nnf` instead of the correct recursive call to `make_dnf` (but this didn't seem to break/fix anything).

This also adds some light property testing, though I'm not really sure this is the best way to do it.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-08-31 11:24:30 +00:00
Jonas Schievink
8c9de51fa3 Simplify int_in_range 2021-08-31 13:11:17 +02:00
Jonas Schievink
8969cbb22f Depend on both crates individually 2021-08-31 13:10:16 +02:00
bors[bot]
70dbf35712
Merge #10092
10092: feat: Improve `extract_struct_from_enum_variant` output r=matklad a=DropDemBits

Improves the struct generated by `extract_struct_from_enum_variant`.

Summary of changes:

- Indent the generated struct and enum to the same indent level
- Preserve comments & attributes from the enum variant (something I missed when doing the same thing for the variant fields)
- Use enum's visibility for fields without any visibility, instead of filling it in with `pub`

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2021-08-31 09:11:53 +00:00
DropDemBits
3bafb5f025
feat: Use enum's visibility for extracted struct fields 2021-08-30 21:33:19 -04:00
DropDemBits
95bf89d3c8
fix: Keep comments & attrs from enum variant 2021-08-30 21:33:12 -04:00
DropDemBits
681efe6dcb
feat: Properly indent extracted struct and enum 2021-08-30 21:26:21 -04:00
Jonas Schievink
e6255356d2 Fix DNF construction, add proptest 2021-08-30 22:26:35 +02:00
bors[bot]
20f3792d10
Merge #10089
10089: Fix minor mispelling r=bjorn3 a=NerdyPepper

`find_map` misspelt as `wind_map` in test identifier. 

Co-authored-by: Akshay <nerdy@peppe.rs>
2021-08-30 19:35:00 +00:00
bors[bot]
02a3d898e4
Merge #10076
10076: Use struct init shorthand when applicable in fill struct fields assist r=matklad a=nathanwhit

This PR tweaks the fill struct fields assist to use the struct init shorthand when a local variable with a matching name and type is in scope.

For example:
```rust
struct Foo {
    a: usize,
    b: i32,
    c: char,
}

fn main() {
    let a = 1;
    let b = 2;
    let c = 3;
    let foo = Foo { <|> };
}
```
Before we would insert
```rust
Foo {
    a: (),
    b: (),
    c: (),
}
```
now we would insert
```rust
Foo {
    a,
    b,
    c: ()
}
```

Co-authored-by: nathan.whitaker <nathan.whitaker01@gmail.com>
2021-08-30 18:55:18 +00:00
nathan.whitaker
e1d86a42fe Add coverage mark for struct init shorthand test 2021-08-30 14:37:03 -04:00
Akshay
e304a623ad fix minor mispelling
find_map misspelt as wind_map
2021-08-30 22:51:14 +05:30
Aleksey Kladov
53d2050085 feat: improve CPU usage
closes #9922

Turned out to be trivial after preliminary refactor.

The intended behavior is that we schedule cache priming once ws become
quiescent (that is, we fully load cargo project), and we continue to
rschedule it until it completes (priming might get cancelled by user
typing into a file).
2021-08-30 19:48:16 +03:00
Aleksey Kladov
9e0203bd69 internal: make scheduling control flow more obvious
There should be only one place where we need to check if we want to
start background activities.
2021-08-30 19:39:08 +03:00
Aleksey Kladov
a59f344c4f internal: improve consistency
Let's have only one place where we start delayed ops
2021-08-30 19:24:31 +03:00
Aleksey Kladov
6317292cd5 internal: more obviously correct code for cache priming progerss
It doesn't make sense for the prime_caches itself send begin/end events
-- the caller knows perfectly fine when they happen!
2021-08-30 19:18:48 +03:00
bors[bot]
bb1987b45e
Merge #10085
10085: fix: avoid panic when parsing extern block r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 12:57:39 +00:00
Aleksey Kladov
4452f9ec48 internal: improve style
Group related stuff together, use only on path for parsing extern blocks
(they actually have modifiers).

Perhaps we should get rid of items_without_modifiers altogether? Better
to handle these kinds on diagnostics in validation layer...
2021-08-30 15:55:40 +03:00
Aleksey Kladov
8dc3b46017 fix: avoid panic when parsing extern block
closes #10083
2021-08-30 15:40:47 +03:00
Mario Carneiro
b22eb02f8b
fail -> failed 2021-08-30 02:47:10 -07:00
Mario Carneiro
2d349aed2e
Update crates/hir_expand/src/db.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-08-30 02:43:13 -07:00
Mario Carneiro
6e8dedadcd
Fix error message
I'm not entirely sure if the message is still correct, it seems to have survived a number of refactors, but it is mangled english anyway.
2021-08-30 02:36:21 -07:00
bors[bot]
1636f61a15
Merge #10005
10005: Extend `CargoConfig.unset_test_crates`  r=matklad a=regexident

This is to allow for efficiently disabling `#[cfg(test)]` on all crates (by passing `unset_test_crates: UnsetTestCrates::All`) without having to first load the crate graph, when using rust-analyzer as a library.

(FYI: The change doesn't seem to be covered by any existing tests.)

Co-authored-by: Vincent Esche <regexident@gmail.com>
2021-08-30 08:42:13 +00:00
bors[bot]
d250aa77ec
Merge #10015
10015: internal: more declarative re-indentation API r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 08:34:49 +00:00
bors[bot]
ceecf853ee
Merge #10080
10080: internal: don't shut up the compiler when it says the code's buggy r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 07:58:59 +00:00
Aleksey Kladov
a833fba98a internal: don't shut up the compiler when it says the code's buggy
Wrapping state-modifying functions into a `catch_unwind` is wrong -- to
do retry after failure, you need to have transactional semantics!
2021-08-30 10:58:39 +03:00
bors[bot]
b3452dd379
Merge #10079
10079: internal: make upstream bug less annoying r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 07:39:34 +00:00