Commit graph

1238 commits

Author SHA1 Message Date
Milo
35e5daacc3 more clippy fixes 2021-10-16 12:32:55 +01:00
Milo
35de195c41 a few clippy fixes 2021-10-14 19:57:21 +01:00
bors[bot]
8619058d3d
Merge #10538
10538: fix: matching brace should prefer brace on cursor's right r=Veykril a=codgician

I observed a brace matching issue with the following Rust code:

```rust
let x = (1 + (2 + 3)) * 4;
```

In a situation like `<|>(1 + (2 + 3)) * 4`, the cursor will go to `(1 + (2 + 3)<|>) * 4`, and if user tries to match bracket again it will go like  `(1 + <|>(2 + 3)) * 4` while logically the expected result should be `<|>(1 + (2 + 3)) * 4`. This behavior exists in both line cursor style and block cursor style.

This PR fixes this by letting `matching_brace` prefer the brace to cursor's right when the cursor lies between multiple consecutive braces. It **does NOT** fix #1942 but could be related. Please review.


Co-authored-by: codgician <15964984+codgician@users.noreply.github.com>
2021-10-14 11:50:14 +00:00
codgician
7e68db3670 Matching brace prefers brace on cursor's right 2021-10-14 14:15:56 +08:00
bors[bot]
f185d1c533
Merge #10423
10423: Internal: refactor for mdbook plugin r=Veykril a=HKalbasi

This PR is for upstreaming changes that I made for mdbook plugin. Changes are adding inlay hints to `StaticIndex` and changing some functions for working around privacy of crates.

Aside this, is it okay if I bring the plugin in tree? It is a simple binary crate. I feel it will better maintained here and become resistant to api changes.

Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-10-12 18:35:03 +00:00
Mirko Rainer
eccfa1645b Saw a FIXME comment and decided to fix it.
This renames `descend_into_macros` to  `descend_into_macros_single` and `descend_into_macros_many` into `descend_into_macros`.
 However, this does not touch a function in `SemanticsImpl` of same name.
2021-10-12 11:52:31 -04:00
hamidreza kalbasi
0f49c97e93 internal changes for mdbook 2021-10-12 11:54:00 +03:30
bors[bot]
64ca0f63bf
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa

## Why

Delete clones for efficiency

## What

- I erased unnecessary clones


Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:17:52 +00:00
k-nasa
b50cb5c261 Remove neesless clone 2021-10-10 10:50:51 +09:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
bors[bot]
fd3f4c50da
Merge #10467
10467: Optimize CodeLens for references/impls r=Veykril a=ericsampson

Don't do unnecessary work.
Followup to #10447 . cc `@Veykril` 

Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-06 21:47:22 +00:00
Eric Sampson
efca421c43 Refactor to eliminate a vector allocation. 2021-10-06 16:43:37 -05:00
bors[bot]
f30b62b751
Merge #10479
10479: fix: fix "index out of bounds" panic in name resolution r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10084
Closes https://github.com/rust-analyzer/rust-analyzer/issues/9163

This is really just a salsa update to a version that removes the problematic code (see https://github.com/rust-analyzer/rust-analyzer/issues/10084#issuecomment-934445711)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-06 20:54:27 +00:00
Jonas Schievink
cda9668289 Update salsa 2021-10-06 22:42:54 +02:00
Eric Sampson
0d77be67f7 Don't do work and then throw it away. 2021-10-06 01:16:31 -05:00
bors[bot]
5ff992465e
Merge #10447
10447: Add enum variant references CodeLens. r=Veykril a=ericsampson



Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-05 22:03:23 +00:00
Eric Sampson
6d05b07f7d Refactor according to PR comments to remove allocations. 2021-10-05 15:42:45 -05:00
bors[bot]
c409cf0e26
Merge #10458
10458: feat: Implement custom user snippets r=Veykril a=Veykril

![Y24dX7fOWX](https://user-images.githubusercontent.com/3757771/136059454-ceccfc2c-2c90-46da-8ad1-bac9c2e83ec1.gif)

Allows us to address the following issues:
    - `.arc / .rc / .pin, similar to .box?` https://github.com/rust-analyzer/rust-analyzer/issues/7033
    - `Add unsafe snippet` https://github.com/rust-analyzer/rust-analyzer/issues/10392, would allow users to have this without the diagnostic)
    - `.ok() postfix snippet is annoying` https://github.com/rust-analyzer/rust-analyzer/issues/9636, allows us to get rid of the `ok` postfix and similar ones
    - `Postfix vec completion` https://github.com/rust-analyzer/rust-analyzer/issues/7773

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

Zulipd discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Custom.20Postfix.20snippets

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-05 16:41:11 +00:00
Lukas Wirth
77cbf4adbc Bring the implementation closer to VSCode snippet definitions 2021-10-05 17:18:40 +02:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
Eric Sampson
160a7b097a initialize vector to required size. 2021-10-04 16:14:01 -05:00
Lukas Wirth
454ecd167c Make multiple import edits work for completions 2021-10-04 21:44:33 +02:00
Lukas Wirth
046c85ef0c Add custom non-postfix snippets 2021-10-04 19:22:41 +02:00
Lukas Wirth
88f213eadd Initial implementation of custom postfix snippets 2021-10-04 17:49:21 +02:00
Eric Sampson
5df6259996 tweak variable names. 2021-10-04 02:42:13 -05:00
Eric Sampson
a0bb31587e Add enum variant references CodeLens. 2021-10-04 02:18:31 -05:00
bors[bot]
10eaa5a0af
Merge #10441
10441: feat: Hide type inlay hints for constructors r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/3022
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 13:35:47 +00:00
Lukas Wirth
a31bc668f5 Hide generic constructors if appropriate 2021-10-03 15:35:26 +02:00
Lukas Wirth
992b4648d9 feat: Hide type inlay hints for constructors 2021-10-03 14:53:18 +02:00
bors[bot]
ebe6c38a44
Merge #10438
10438: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 11:06:06 +00:00
Lukas Wirth
0943c4be8b minor: Simplify 2021-10-03 13:05:42 +02:00
Lukas Wirth
86e5406539 Fix rename trying to edit the same range multiple times 2021-10-02 18:50:21 +02:00
Aleksey Kladov
12103b16de internal: untangle usages of ReferenceCategory somewhat
Not everything that can be read or write is a reference, let's try to
use more precise types.
2021-10-02 13:02:06 +03:00
Aleksey Kladov
46eb03d99a internal: use naming that matches intended use-case 2021-10-02 12:18:18 +03:00
nathan.whitaker
a3661b3900 Add whitespace b/w lifetime and mut in expansion 2021-10-01 15:29:26 -04:00
Cassandra McCarthy
d5cf9f4add
docs: add note about vscode-vim in on_enter
I found myself search for this, so building off of #3013 and #3308, I
hope this note is useful.
2021-10-01 14:12:32 -04:00
bors[bot]
0646d5cf9e
Merge #10413
10413: fix: Fix format highlighting with `concat!` and `unreachable!` r=jonas-schievink a=jonas-schievink

Last item in https://github.com/rust-analyzer/rust-analyzer/issues/10394, closes https://github.com/rust-analyzer/rust-analyzer/issues/10394

Also documents why/how `is_format_string` even works, since I found that nontrivial.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-01 11:31:32 +00:00
Jonas Schievink
3bc0d89ade Fix format highlighting with concat! 2021-10-01 13:28:05 +02:00
bors[bot]
47c079a037
Merge #10403
10403: feat: Add semantic token modifier for crate root r=Veykril a=lhvy

Resolves #9073

I managed to implement crate root highlighting for crates mentioned specifically by name (e.g. `serde` in `use serde::Serialize;`), but not for crates referred to with `crate` or `super`. How could I implement this?

> P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks!

Co-authored-by: lhvy <me@lhvy.dev>
2021-10-01 11:18:52 +00:00
lhvy
dbb02370a4
Add semantic token modifier for crate root 2021-10-01 20:52:13 +10:00
Jonas Schievink
cca6ee5757 Expand asm! to format_args! 2021-10-01 12:33:18 +02:00
Lukas Wirth
c5ceaefa09 Restructure syntax element highlighting 2021-09-30 21:44:56 +02:00
Lukas Wirth
a33939565d Simplify 2021-09-30 19:12:37 +02:00
bors[bot]
529b7a4167
Merge #10398
10398: Give defaultLibrary semantic token modifier to items from standard library r=Veykril a=lhvy

Fixes #8999, fixes #2155

`builtInCrates` could be an alternate name to `defaultLibrary`, which one is better?

> P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks!

Co-authored-by: lhvy <me@lhvy.dev>
Co-authored-by: Lucas <me@lhvy.dev>
2021-09-30 16:10:23 +00:00
lhvy
0b2ba8be68
Fix builtin_crates return type change 2021-10-01 02:05:00 +10:00
lhvy
64cbdf6d55
Add comment 2021-10-01 01:58:11 +10:00
Jonas Schievink
4465685878 Work around tidy check 2021-09-30 17:32:18 +02:00
lhvy
2b3baa8503
Give defaultLibrary semantic token modifier to items from standard library 2021-10-01 01:19:24 +10:00