Commit Graph

25379 Commits

Author SHA1 Message Date
bors
3713c4b949 Auto merge of #14904 - Veykril:hover-hex, r=Veykril
Render size, align and offset hover values in hex

Arguably, these values are usually almost always viewed in hex format so I think we should do the same here
2023-05-26 14:59:41 +00:00
Lukas Wirth
be9cc0baae Render size, align and offset hover values in hex 2023-05-26 16:41:45 +02:00
bors
eee6872647 Auto merge of #14901 - Veykril:errors, r=Veykril
internal: Move flycheck and config errors to status notification

cc https://github.com/rust-lang/rust-analyzer/issues/14193
2023-05-26 13:38:39 +00:00
Lukas Wirth
f876adf617 Report flycheck errors via status 2023-05-26 15:37:41 +02:00
Lukas Wirth
a2b59b110f Report config errors via status 2023-05-26 15:26:03 +02:00
Lukas Wirth
79fe11ced3 Shuffle some things around 2023-05-26 15:09:19 +02:00
bors
e963846656 Auto merge of #14816 - justahero:gh-14626, r=Veykril
feat: Assist to replace generic with impl trait

This adds a new assist named "Replace named generic with impl". It is the inverse operation to the existing "Replace impl trait with generic" assist.

It allows to refactor the following statement:

```rust
//      👇 cursor
fn new<T$0: ToString>(input: T) -> Self {}
```

to be transformed into:

```rust
fn new(input: impl ToString) -> Self {}
```

* adds new helper function `impl_trait_type` to create AST node
* add method to remove an existing generic param type from param list

Closes #14626
2023-05-26 12:03:44 +00:00
Sebastian Ziebell
e78df83e2f Integrate feedback
* pass in existing `Semantics` object to function
* pass in `Definition` for param type
* refactor iterator to use `flatten`
2023-05-26 13:43:12 +02:00
bors
8589a2d843 Auto merge of #14849 - alibektas:14557n, r=Veykril
enhancement : using doc aliases to search workspace symbols  ( fixes #14557 )

Doc aliases are now visible among symbols and can be used for searching.
2023-05-26 11:30:40 +00:00
Ali Bektas
d49924dc6e Choose & over ref, make nav target's name more intuitive. 2023-05-26 13:24:44 +02:00
Sebastian Ziebell
ce1c85317f Check param is not referenced in function
This checks the type param is referenced neither in the function body
nor as a return type.

* add tests
2023-05-26 13:24:29 +02:00
Sebastian Ziebell
95f59668e6 Fix removal of generic param from list
This removes an existing generic param from the `GenericParamList`. It
also considers to remove the extra colon & whitespace to the previous
sibling.

* change order to get all param types first and mark them as mutable
  before the first edit happens
* add helper function to remove a generic parameter
* fix test output
2023-05-26 13:13:15 +02:00
Sebastian Ziebell
59f8827a6f Implement assist to replace named generic with impl
This adds a new assist named "replace named generic with impl" to move
the generic param type from the generic param list into the function
signature.

```rust
fn new<T: ToString>(input: T) -> Self {}
```

becomes

```rust
fn new(input: impl ToString) -> Self {}
```

The first step is to determine if the assist can be applied, there has
to be a match between generic trait param & function paramter types.

* replace function parameter type(s) with impl
* add new `impl_trait_type` function to generate the new trait bounds with `impl` keyword  for use in the
  function signature
2023-05-26 13:13:11 +02:00
bors
2fd9260472 Auto merge of #14897 - HKalbasi:dev, r=HKalbasi
Insert type vars in function arguments

follow up #14891
2023-05-26 10:56:39 +00:00
hkalbasi
c21d09f3cc insert type vars in function arguments 2023-05-26 14:26:13 +03:30
bors
b4e3fec176 Auto merge of #14895 - lowr:fix/goto-type-def-tokens-in-tt, r=Veykril
fix: don't try determining type of token inside macro calls

When we're requested `Go to Type Definition`, we first downmap the token in question to tokens in every macro call expansion involved, and then determine the type of those mapped tokens by looking for the nearest ancestor node that is either expression or pattern (or a few others). This procedure has one flaw: When the downmapped token is inside another macro call, the nearest ancestor node to retrieve the type of is *that* macro call. That's not what we should return in general and therefore we should disregard it.

Notably, now that we expand built-in `format_arg!` and its family macros, we're always returning [`Arguments`] when one `Go to Type Definition` at `dbg!(variable$0)` along with the actual type of `variable` without this patch.

[`Arguments`]: https://doc.rust-lang.org/nightly/core/fmt/struct.Arguments.html
2023-05-26 10:01:11 +00:00
Ryo Yoshida
397c8e5148
fix: don't try determining type of token inside macro calls 2023-05-26 16:46:45 +09:00
bors
615aaa4751 Auto merge of #14894 - Wilfred:index_scip_path, r=lnicola
Allow users to override the .scip output file path

Previously, rust-analyzer would write to the file index.scip unconditionally.
2023-05-26 06:25:34 +00:00
Wilfred Hughes
5b0e170683 Allow users to override the .scip output file path
Previously, rust-analyzer would write to the file index.scip
unconditionally.
2023-05-25 16:54:31 -07:00
bors
06d02e0a1e Auto merge of #14893 - HKalbasi:dev, r=HKalbasi
Fix `need-mut` false positive in closure capture of match scrutinee

Fix `need-mut` false positive on self.
2023-05-25 22:48:08 +00:00
hkalbasi
780349bdaf fix need-mut false positive in closure capture of match scrutinee 2023-05-26 02:08:37 +03:30
bors
fcd3a6b037 Auto merge of #14891 - HKalbasi:dev, r=HKalbasi
Evaluate `UnevaluatedConst` in unify

fix #14844
2023-05-25 16:09:39 +00:00
hkalbasi
7ef185d65e evaluate UnevaluatedConst in unify 2023-05-25 19:37:20 +03:30
bors
efd3094aba Auto merge of #14890 - HKalbasi:dev, r=HKalbasi
use `::core` instead of `$crate` in `option_env!`

fix #14885
2023-05-25 15:19:18 +00:00
hkalbasi
b0f17668f7 use ::core instead of $crate in option_env! 2023-05-25 18:46:34 +03:30
bors
1c6561320f Auto merge of #14889 - Veykril:overly-dbg, r=Veykril
Add context to overly long loop message
2023-05-25 15:01:08 +00:00
Lukas Wirth
e3dfcf2eb2 Add context to overly long loop message 2023-05-25 16:20:28 +02:00
bors
21e5dc2af9 Auto merge of #14881 - Veykril:name-display, r=Veykril
internal: Replace Display impl for Name

This allows us to plug in interner for `Name`s that live inside the database.
2023-05-25 12:04:16 +00:00
alibektas
1222869b3e Fix #14557. Docs aliases can now be detected and used in searching for workspace symbols 2023-05-24 23:57:24 +02:00
bors
a512774fd9 Auto merge of #14752 - ponyii:fix/generate_derive_breaks_indentation, r=Veykril
fix: assists no longer break indentation

Fixes https://github.com/rust-lang/rust-analyzer/issues/14674

These are _ad hoc_ patches for a number of assists that can produce incorrectly indented code, namely:
- generate_derive
- add_missing_impl_members
- add_missing_default_members

Some general solution is required in future, as the same problem arises in many other assists, e.g.
- replace_derive_with...
- generate_default_from_enum...
- generate_default_from_new
- generate_delegate_methods
(the list is incomplete)
2023-05-24 18:58:07 +00:00
Lukas Wirth
c7ef6c25b7 internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
bors
2f840c2236 Auto merge of #14874 - Veykril:crate-cfg, r=Veykril
expand: Change how `#![cfg(FALSE)]` behaves on crate root

Closes https://github.com/rust-lang/rust-analyzer/issues/14769
2023-05-24 16:06:09 +00:00
Luna Razzaghipour
430bdd3509
Run the main thread under the User Interactive QoS class 2023-05-25 00:22:14 +10:00
Luna Razzaghipour
578d99477a
Move on-type formatting request handler onto the main thread 2023-05-25 00:16:52 +10:00
bors
8ad70e7f99 Auto merge of #14866 - AndreasBackx:feature/doc-comments-markdown, r=Veykril
[editors/code] add markdown syntax highlighting to doc comments

_This is a continuation of https://github.com/microsoft/vscode/pull/169956 and https://github.com/dustypomerleau/rust-syntax/pull/37 (that repo is no longer maintained: https://github.com/dustypomerleau/rust-syntax/issues/39#issuecomment-1427339029). The VS Code team seemed to prefer this being inside of an extension._

This adds Markdown highlighting to doc comment lines and blocks. Currently it is thus regarded both as a comment and as Markdown which leads to normally foreground text being in the colour of the comment and the rest highlighted like Markdown or its own embedded languages in code blocks.

![image](https://github.com/rust-lang/rust-analyzer/assets/1593486/c84f2e83-faea-47ca-853d-3728a07b2b66)

![image](https://github.com/rust-lang/rust-analyzer/assets/1593486/f4191425-32cd-451c-ae3a-29a0970ce7a2)

Block comments are supported, but currently not when there is a `*` at the start of the line:
![image](https://github.com/rust-lang/rust-analyzer/assets/1593486/ce3b58d5-9dca-4376-bffe-4f5a54acbe37)
![image](https://github.com/rust-lang/rust-analyzer/assets/1593486/b73a5ee6-a178-4aef-a0e4-3d75e4e7d8e5)

I'm not entirely sure if I can easily fix this, I'd need to find a way to make the content ignore the `*`. Though I'm unsure if it's important as there are [conventions against using block comments](
https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#use-line-comments) and using them without `*` does work. All of this TextMate grammar is so hard to find documentation on that _honestly_ I'd just not want to support this considering the effort.

Let me know what everyone thinks of this being in rust-analyzer. I've personally found it hard to write large amounts of Rust documentation due to the lack of Markdown syntax highlighting.

Also, thank you `@adenine-dev` as well for making this available in the interim and your enthousiasm. Wanted to get this PR out sooner, but life gets in the way.
2023-05-24 11:33:41 +00:00
bors
2df56cadcb Auto merge of #14755 - poliorcetics:clippy-fixes, r=Veykril
Fix: a TODO and some clippy fixes

- fix(todo): implement IntoIterator for ArenaMap<IDX, V>
- chore: remove unused method
- fix: remove useless `return`s
- fix: various clippy lints
- fix: simplify boolean test to a single negation
2023-05-24 11:13:52 +00:00
Lukas Wirth
74d6826858 expand: Change how #![cfg(FALSE)] behaves on crate root 2023-05-24 13:02:38 +02:00
bors
1d1a1195f3 Auto merge of #14880 - Veykril:intern-double, r=Veykril
Remove double lookups from Interned
2023-05-24 10:58:46 +00:00
Lukas Wirth
12d4355c60 Remove double lookups from Interned 2023-05-24 12:54:25 +02:00
alibektas
51ec2ced69 Improve ast::make
Add `ty_alias` and make `impl_trait` , `fn` and `impl_` have more coverage.
2023-05-23 03:12:57 +02:00
bors
2120c913c2 Auto merge of #14872 - lowr:fix/ref-pat-with-type-var, r=HKalbasi
fix: introduce new type var when expectation for ref pat is not ref

Fixes #14840

When we infer the type of ref patterns, its expected type may not be reference type: 1) expected type is an unresolved inference variable, or 2) expected type is erroneously other kind of type. In either case, we should produce a reference type with a new type variable rather than an error type so that we can continue inferring the inner patterns without further errors because of the (possible) type mismatch of this pattern.
2023-05-22 19:53:39 +00:00
Ryo Yoshida
01f42d2405
fix: introduce new type var when expectation for ref pat is not ref 2023-05-22 23:13:41 +09:00
Andreas Backx
09f624721c
[editors/code] add markdown syntax highlighting to doc comments 2023-05-21 17:34:42 +01:00
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