Commit graph

16919 commits

Author SHA1 Message Date
Jonas Marcello
f494d1199d Remove empty line 2023-02-27 18:10:20 +01:00
Jonas Marcello
7abcc7d862 Add const to doctest runnable definition
Refactor method to get type parameters to add const parameters
Remove unused methods
2023-02-27 18:08:20 +01:00
Jonas Marcello
4ee2e469a2 Rename the method that returns struct paramaters 2023-02-27 18:08:20 +01:00
Jonas Marcello
9957bb361d Add const generics to doctest names for structt 2023-02-27 18:08:20 +01:00
Jonas Marcello
8bc75c4c28 return Iterator instead of Vec for combined lifetime and argument parameters 2023-02-27 18:08:20 +01:00
Jonas Marcello
9942cc425b Fix 14142: Annotate lifetime paramaters in doctest runnables 2023-02-27 18:08:17 +01:00
Lukas Wirth
29a4453d55 Merge the two autoref vecs into one in autoderef_method_receiver 2023-02-27 16:01:16 +01:00
Lukas Wirth
9e5fa74279 Simplify 2023-02-27 15:51:45 +01:00
bors
b38fcde3ba Auto merge of #14213 - swarnimarun:raw-ptr-ty, r=Veykril
add: clean api to get `raw_ptr` type

There doesn't seem to be an API to fetch the type of `raw_ptr`, which is helpful for a project I work on.

Notes:

- I am unsure about the function name, do let me know if I should use something else.
- Also unsure about where to add tests, for hir changes. Will fix it as needed.
2023-02-27 10:45:29 +00:00
Swarnim Arun
832f8bfe2b
rename: as_raw_ptr_ty to remove_raw_ptr 2023-02-27 15:57:26 +05:30
bors
2e479158bb Auto merge of #14208 - Kohei316:master, r=Veykril
fix:add a case in which remainig is None in resolveing types when resolving hir path.

fix #14030 The variable type is being determined incorrectly
This PR fixed a problem in which `go to definition` is jumping to the incorrect position because it was failing to resolve the type in case it defined in the module when resolving hir.
In addition, I added a test for this issue and refactored the related code.
This is my first PR and I am using a translation tool to write this text. Let me know if you have any problems.
2023-02-27 08:40:39 +00:00
Swarnim Arun
9a481d1ecf
add: clean api to get raw_ptr type 2023-02-27 10:59:20 +05:30
morine0122
aa877645a6 Fix resolving types when resolving HIR and add a related test 2023-02-26 21:50:39 +09:00
Tomoki Nakagawa
e4b184a776 Respect $CARGO_HOME when looking up toolchains. 2023-02-26 15:37:04 +09:00
shilangyu
44e47fe408 Add check for extra path segments after an angled one 2023-02-25 16:16:49 +01:00
Ryo Yoshida
cf0c8fe000
minor: import Either from either 2023-02-25 21:55:11 +09:00
bors
f5401f6206 Auto merge of #14175 - jmviz:openDocs-context-menu, r=lnicola
add openDocs command to context menu in VS Code extension

This adds the `openDocs` command to the VS Code context menu. I believe there are probably many user who are unaware of this command existing in the rust analyzer extension, and that this should enhance the discoverability of the command. Additionally, even if people are aware of this capability, it's helpful to have this in the context menu anyway; for example, one might forget the name of the command, or the keybinding they have assigned to it. I think that opening docs is a common enough action to warrant the extra line added to the context menu.

This makes a few other small changes as well. There are two minor style changes to increase style consistency. First, it changes the titles of the two commands that the rust analyzer extension will contribute to the context menu to title case. All standard VS Code commands that appear in the context menu are in title case. Second, it shortens the title of the `openDocs` command from `Open docs under cursor` to `Open Docs`. The implicit assumption in the standard VS Code context menu command titles is that the action applies to the symbol under the cursor: `Go to Definition`, `Find All References`, etc. Note that since these are changes to the command titles, rather than the command names themselves, these changes will not break any users' existing keybindings for these commands.

Second, this adds further restrictions to the `where` clauses of the two commands that the rust analyzer extension will contribute to the context menu, so that the two commands will appear in the context menu only when in a Rust project **and** within a Rust file. Say you have a Python or bash script inside your Rust project. Having these commands appear in the context menu when you right click a symbol in such a non-Rust file is extraneous and potentially confusing.

![demonstration](https://user-images.githubusercontent.com/6609145/219976062-b46ab21b-5753-48f5-a1da-562566cae71c.gif)
2023-02-24 06:55:02 +00:00
Laurențiu Nicola
563bd9c24a Try to improve the rustfmt.overrideCommand docs 2023-02-21 12:43:22 +02:00
Laurențiu Nicola
f40526b949 Remove file added by mistake 2023-02-21 09:05:19 +02:00
jmviz
dd92e4a507 add to manual 2023-02-20 11:38:33 -05:00
Ryo Yoshida
d4166234ef
Adjust block-local impl item visibility rendering 2023-02-20 00:44:51 +09:00
Ryo Yoshida
83e24fec98
Fix associated item visibility in block-local impls 2023-02-19 23:55:55 +09:00
Ryo Yoshida
443801755c
Refactor
- Remove unnecessary references and derefs
- Manual formatting
2023-02-19 23:55:49 +09:00
bors
b881deb66a Auto merge of #14165 - Veykril:completion-item, r=Veykril
internal: Make CompletionItem more POD-like
2023-02-16 08:30:56 +00:00
Lukas Wirth
404a51f26a internal: Make CompletionItem more POD-like 2023-02-16 09:29:55 +01:00
Azriel Hoh
a6f54d6c5f Conditionally add snippet marker. 2023-02-16 10:50:27 +13:00
bors
1f2d33fb40 Auto merge of #14160 - Veykril:hover-call, r=Veykril
fix: Bring back hovering call parens for return type info
2023-02-15 17:59:31 +00:00
Lukas Wirth
e550e553e0 fix: Bring back hovering call parens for return type info 2023-02-15 18:58:59 +01:00
bors
dd582dac67 Auto merge of #14157 - Veykril:inlay, r=Veykril
Adjust binding mode inlay hints to render better with @ patterns
2023-02-15 13:47:29 +00:00
Lukas Wirth
5859190066 Adjust binding mode inlay hints to render better with @ patterns 2023-02-15 14:47:02 +01:00
bors
a04054ac39 Auto merge of #14156 - Veykril:completion-pod, r=Veykril
internal: Don't reconstruct ref match completion in to_proto manually

cc https://github.com/rust-lang/rust-analyzer/issues/12571
2023-02-15 13:17:27 +00:00
Lukas Wirth
23fc596e40 Don't reconstruct ref match completion in to_proto manually 2023-02-15 14:15:22 +01:00
Lukas Wirth
026a8c976d Simplify 2023-02-15 13:38:42 +01:00
Laurențiu Nicola
6e5ec0b3ce Fix a pair of typos 2023-02-15 14:11:11 +02:00
Rune Tynan
853f047245
Cargo fmt 2023-02-14 14:45:05 -05:00
Rune Tynan
bc81d582c9
Add v7 support to rust-analyzer 2023-02-14 12:29:33 -05:00
bors
37608f306c Auto merge of #14152 - Veykril:path-opt, r=Veykril
Replace some often empty `Vec`s with boxed slices
2023-02-14 16:58:58 +00:00
bors
523fea8f25 Auto merge of #14149 - Veykril:completion, r=Veykril
Trigger call info for more completions of signature having things
2023-02-14 16:42:30 +00:00
Lukas Wirth
4aee911ce4 Slim down GenericArgs by one usize once more 2023-02-14 17:41:16 +01:00
Lukas Wirth
853ae1927d Slim down GenericArgs by one usize 2023-02-14 17:40:24 +01:00
Lukas Wirth
4c2aef650a Slim down AssociatedTypeBinding by one usize 2023-02-14 17:40:24 +01:00
bors
41db8c2b59 Auto merge of #14151 - Veykril:smallvec, r=Veykril
internal: Enable smallvec's `union` feature
2023-02-14 16:24:21 +00:00
Lukas Wirth
cade9f7020 Trigger call info for more completions of signature having things 2023-02-14 17:05:07 +01:00
bors
9548388534 Auto merge of #14150 - Veykril:path, r=Veykril
internal: Don't allocate the generic_args vec in `hir_def::Path` if it consists only of `None` args

Saves roughly 5mb on self
2023-02-14 16:02:02 +00:00
Lukas Wirth
a18ebf40cb Don't allocate the generic_args vec in hir_def::Path if it consists only of None args 2023-02-14 17:01:38 +01:00
Lukas Wirth
3c0f20a7bd internal: Enable smallvec's union feature 2023-02-14 17:01:01 +01:00
Lukas Wirth
38144fd914 Bump lsp-types 2023-02-14 14:59:50 +01:00
Lukas Wirth
95fa278f30 Don't assume VSCode internal commands in the server 2023-02-14 14:45:48 +01:00
bors
44568007d1 Auto merge of #14128 - Veykril:parser, r=Veykril
internal: Improve parser recovery for delimited lists

Closes https://github.com/rust-lang/rust-analyzer/issues/11188, https://github.com/rust-lang/rust-analyzer/issues/10410, https://github.com/rust-lang/rust-analyzer/issues/10173

Should probably be merged after the stable release as this might get the parser stuck if I missed something
2023-02-14 12:59:39 +00:00
Lukas Wirth
4f6b5f41d4 Recover better for more delimited sequences 2023-02-14 13:52:15 +01:00
bors
88b3d9f6f4 Auto merge of #14144 - lowr:fix/find-occurrence-of-raw-ident, r=Veykril
fix: Search raw identifiers without prefix

When we find references/usages of a raw identifier, we should disregard `r#` prefix because there are keywords one can use without the prefix in earlier editions (see #13034; this bug is actually fallout from the PR). `name`, the text we're searching for, has already been stripped of the prefix, but the text of nodes we compare it to hasn't been.

The second commit is strictly refactoring, I can remove it if it's not much of value.
2023-02-14 11:15:55 +00:00
bors
31486a639d Auto merge of #14141 - matklad:utf-32, r=lnicola
Support UTF-32 position encoding

Looks like this is a native encoding for Emacs at least!
2023-02-14 10:53:35 +00:00
Ryo Yoshida
60fa8fefa6
refactor: reduce nesting 2023-02-14 17:34:19 +09:00
Ryo Yoshida
098d9d77b4
Search raw identifiers without prefix 2023-02-14 17:34:14 +09:00
Alex Kladov
9fdcf5787d
Update crates/ide-db/src/line_index.rs
Co-authored-by: Stig Brautaset <stig@brautaset.org>
2023-02-14 08:19:58 +00:00
bors
2a57b01980 Auto merge of #14122 - lowr:patch/abort-macro-expansion-on-overflow, r=Veykril
fix: Don't expand macros in the same expansion tree after overflow

This patch fixes 2 bugs:

- In `Expander::enter_expand_id()` (and in code paths it's called), we never check whether we've reached the recursion limit. Although it hasn't been reported as far as I'm aware, this may cause hangs or stack overflows if some malformed attribute macro is used on associated items.
- We keep expansion even when recursion limit is reached. Take the following for example:

  ```rust
  macro_rules! foo { () => {{ foo!(); foo!(); }} }
  fn main() { foo!(); }
  ```

  We keep expanding the first `foo!()` in each expansion and would reach the limit at some point, *after which* we would try expanding the second `foo!()` in each expansion until it hits the limit again. This will (by default) lead to ~2^128 expansions.

  This is essentially what's happening in #14074. Unlike rustc, we don't just stop expanding macros when we fail as long as it produces some tokens so that we can provide completions and other services in incomplete macro calls.

This patch provides a method that takes care of recursion depths (`Expander::within_limit()`) and stops macro expansions in the whole macro expansion tree once it detects recursion depth overflow. To be honest, I'm not really satisfied with this fix because it can still be used in unintended ways to bypass overflow checks, and I'm still seeking ways such that misuses are caught by the compiler by leveraging types or something.

Fixes #14074
2023-02-14 07:37:53 +00:00
bors
381295144e Auto merge of #14123 - dqkqd:discard-postfix-completion-for-indivisble-expr, r=Veykril
fix: Don't trigger postfix completion in `if` block which has an `else` block

Fix #14096
2023-02-14 07:24:47 +00:00
Laurențiu Nicola
354b1aaa50 Merge branch 'master' into sync-from-rust 2023-02-14 08:40:55 +02:00
Aleksey Kladov
0da27376cf Support UTF-32 position encoding
Looks like this is a native encoding for Emacs at least!
2023-02-14 01:09:50 +00:00
Laurențiu Nicola
bc45c7659a ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
bors
c97aae38f2 Auto merge of #14138 - lowr:fix/rename-raw-ident-mod, r=Veykril
fix: don't include `r#` prefix in filesystem changes

Fixes #14131

In addition to fix for #14131, this PR adds raw ident validity checks in rename functionality that we've been missing.
2023-02-13 11:38:32 +00:00
Duong Quoc Khanh
0285acc5f7
Find next_non_trivia_token of name_ref. 2023-02-13 20:11:04 +09:00
bors
23871f9dd1 Auto merge of #14140 - Veykril:proc-macro-srv-fix, r=Veykril
fix: Fix proc-macro-server incorrectly stripping delimiters

🙄
2023-02-13 11:08:23 +00:00
Lukas Wirth
1c2292e5c6 fix: Fix proc-macro-server incorrectly stripping delimiters 2023-02-13 12:07:31 +01:00
Lukas Wirth
244a48d13d Cleanup signature help a bit 2023-02-13 11:25:45 +01:00
Ryo Yoshida
57f0e9c100
Disallow invalid raw ident names 2023-02-13 18:45:19 +09:00
Ryo Yoshida
9b0daf20c9
fix: don't include r# prefix in filesystem changes 2023-02-13 18:44:53 +09:00
Ryo Yoshida
92fdfb548e
Make is_raw_identifier() public util function 2023-02-13 18:43:59 +09:00
Lukas Wirth
9738f97f8c Fix active parameter analysis once more 2023-02-12 17:32:11 +01:00
Lukas Wirth
d2cf8c234a Make else autocompletion work in more places 2023-02-12 10:49:57 +01:00
Lukas Wirth
33cacde04b Fix active parameter analysis 2023-02-12 10:26:19 +01:00
Lukas Wirth
1be24e0899 internal: Improve parser recovery a bunch 2023-02-11 20:28:36 +01:00
Lukas Wirth
5fdf640fb3 fix: Fix bind pat inlay hints rendering for constant patterns 2023-02-11 16:29:54 +01:00
Duong Quoc Khanh
e1396bde73
Don't trigger postfix completion if block which has an else block
Discard postfix completion if the next_non_trivia_sibling of dot_token
is an ELSE_KW.
2023-02-11 21:26:00 +09:00
Ryo Yoshida
ae7e62c50f
Don't expand macros in the same expansion tree after overflow 2023-02-11 18:19:08 +09:00
Lukas Wirth
7677f41f41 Preallocate some vecs 2023-02-10 16:42:09 +01:00
Lukas Wirth
79492cb8ae internal: Revert castable expectation and simplify 2023-02-10 16:08:47 +01:00
Lukas Wirth
8f5deb4ff2 Remove a few allocations in hir-ty::utils 2023-02-10 14:57:03 +01:00
bors
f11cff8976 Auto merge of #14116 - Veykril:inlay-hints-disc, r=Veykril
Render discriminant inlay hints for mixed variants if at least one discriminant is specified
2023-02-10 08:59:17 +00:00
Lukas Wirth
557aa1e378 Render discriminant inlay hints for mixed variants if at least one discriminant is specified 2023-02-10 09:57:03 +01:00
lh123
626dc651ff fix: Insert spaces when inlining macros 2023-02-10 14:22:56 +08:00
bors
7e17b98d17 Auto merge of #14111 - lnicola:squash-proc-macro-server-warning, r=Veykril
fix: Hide proc macro server version detection errors

These are harmless, but users tend to blame other things on them.
2023-02-09 10:29:28 +00:00
Laurențiu Nicola
8828f3494e Hide proc macro server version detection errors 2023-02-09 10:46:36 +02:00
Duong Quoc Khanh
74cd8ecc7e
Add completion without body.
Add completion for Fn, Const, TypeAlias without body.
2023-02-09 17:37:11 +09:00
Duong Quoc Khanh
58136b01ba
Add more tests for completion without body.
Add tests for Fn, Const, TypeAlias without body inside Trait.
2023-02-09 17:32:55 +09:00
bors
eaed19c539 Auto merge of #14104 - Veykril:castable-expect, r=Veykril
fix: Implement Expactation::Castable and add a test case for it

Fixes https://github.com/rust-lang/rust-analyzer/issues/11571
2023-02-08 12:08:15 +00:00
Lukas Wirth
f8f1cb93e0 fix: Implement Expactation::Castable and add a test case for it 2023-02-08 13:07:59 +01:00
bors
5341a6fa7f Auto merge of #14103 - Veykril:typing-semi, r=Veykril
fix: Don't insert a semicolon when typing = if parse errors are encountered

Fixes https://github.com/rust-lang/rust-analyzer/issues/11005
2023-02-08 11:14:58 +00:00
Lukas Wirth
5e6208b1df fix: Don't insert a semicolon when typing = if parse errors are encountered 2023-02-08 12:06:35 +01:00
bors
885c1ad578 Auto merge of #14102 - Veykril:bump-lexer, r=Veykril
minor: Bump `rustc-ap-rustc_lexer`

Closes https://github.com/rust-lang/rust-analyzer/issues/9554
2023-02-08 11:01:32 +00:00
Lukas Wirth
4788c7a056 Bump rustc-ap-rustc_lexer 2023-02-08 11:42:14 +01:00
bors
512a93ac94 Auto merge of #14100 - Veykril:load_cargo-proc-macro-srv-config, r=Veykril
Allow specifying what proc-macro server to run in rust_analyzer::load_cargo API

Closes https://github.com/rust-lang/rust-analyzer/issues/10516
2023-02-08 10:12:31 +00:00
Lukas Wirth
f03fb262f7 Allow specifying what proc-macro server to run in rust_analyzer::load_cargo API 2023-02-08 11:05:34 +01:00
bors
6effb26062 Auto merge of #14095 - dqkqd:master, r=Veykril
Add postfix completion for `unsafe`.

Fix #13779.

Hi, this is my first PR. Please tell me if there is anything I should do.
2023-02-08 09:44:22 +00:00
bors
a05ce5a3e7 Auto merge of #13986 - MariaSolOs:limit-completions, r=Veykril
Add setting for limiting number of completions

For #13911.
2023-02-08 09:31:35 +00:00
bors
3c89945e78 Auto merge of #14098 - pascalkuthe:did_change_workspace_folder, r=Veykril
Support DidChangeWorkspaceFolders notifications

This PR enables the `WorkspaceFoldersServerCapabilities` capability for rust-analyzer and implemented support for the associated [`DidChangeWorkspaceFolders`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeWorkspaceFolders) notification to allow clients to update the list of `workspaceFolders` sent during initialization.

## Motivation

This allows clients which lazily autodiscover their workspace roots (like the [helix editor](https://github.com/helix-editor/helix) once [my PR](https://github.com/helix-editor/helix/pull/5748) lands) avoid spawning multiple instances of RA. Right now such clients are forced to either:

* greedily discover all LSP roots in the workspace (precludes the ability to respond to new workspace roots)
* spawn multiple instance of rust-analyzer (one for each root)
* restart rust-analyzer whenever a new workspace is added

Some example use-cases are shown [here](https://github.com/helix-editor/helix/pull/5748#issuecomment-1421012523).

This PR will also improve support for VSCode (and Atom) multi workspaces.

## Implementation

The implementation was fairly straightforward as `rust-analyzer` already supports dynamically reloading workspaces, for example on configuration changes. Furthermore, rust-analyzer also already supports auto-discovering internal workspace from the `workspaceFolders` key in the initialization request. Therefore, the necessary logic just needed to be moved to a central place and reused.
2023-02-08 09:14:01 +00:00
bors
b7836e44d3 Auto merge of #14099 - Veykril:inlay-hint-loc, r=Veykril
Properly use location links for type hints of impl Future and its assoc type
2023-02-08 08:43:10 +00:00
Maria José Solano
064fcfa016 Sort and truncate final response 2023-02-07 18:41:28 -08:00
Lukas Wirth
2b4a5374ee Properly use location links for type hints of impl Future and its assoc type 2023-02-07 22:42:03 +01:00
Pascal Kuthe
c7010eda1b
Support DidChangeWorkspaceFolders capability 2023-02-07 22:40:40 +01:00
Duong Quoc Khanh
2666e6eda8
Add test for LetElse case.
Postfix completion is not triggered.
2023-02-08 04:04:10 +09:00
Duong Quoc Khanh
8535f2bb1b
Handle edge cases.
Handle case when BlockExpr is child of IfExpr, WhileExpr, LoopExpr,
ForExpr.
An additional { } will be added when:
- It is not a BlockExpr
- It is a BlockExpr and a child of IfExpr, WhileExpr, LoopExpr, ForExpr.
2023-02-08 03:37:20 +09:00
bors
7f1234492e Auto merge of #14084 - Veykril:float-parse, r=Veykril
fix: Fix parsing of nested tuple field accesses in a cursed way

This is absolutely terrible but seems to work. Macro fragment parsing comes next.
2023-02-07 17:25:31 +00:00
bors
57ea9826b5 Auto merge of #13991 - vasilev-alex:add-braces-assist, r=Veykril
feat: add braces assist

This assist adds support for adding braces where it may be appropriate (e.g. lambda expressions)

![ex](https://user-images.githubusercontent.com/4973437/213783924-7c8a8ab5-6a52-4d80-837c-cf2a9b56f061.gif)
2023-02-07 17:12:01 +00:00
Lukas Wirth
a756c9ad08 Fixup comments 2023-02-07 18:08:05 +01:00
Duong Quoc Khanh
370ba94ca2
Add more tests.
Add tests for control flows and `let`.
2023-02-08 01:50:09 +09:00
Lukas Wirth
27cd509558 fix jointess for floats not being set properly 2023-02-07 17:41:16 +01:00
Lukas Wirth
e59487de38 Add tests for float access macro call inputs 2023-02-07 17:12:24 +01:00
Duong Quoc Khanh
a7df61f1d3
Add postfix completion for unsafe.
Wrap receiver_text with { } if it's not a BlockExpr.
2023-02-07 23:55:44 +09:00
Lukas Wirth
f6539b139e fix depth check for float split step 2023-02-07 15:44:00 +01:00
Lukas Wirth
c6e7917d6e Fix up token_tree_to_syntax_node float split handling 2023-02-07 15:21:37 +01:00
bors
1d32a7b7c6 Auto merge of #14094 - HKalbasi:layout, r=flodiebold
Reuse fetching target data layout from rustc function

fix https://github.com/rust-lang/rust-analyzer/pull/14087?notification_referrer_id=NT_kwDOArGpCLM1NTEyMDQ5MjU3OjQ1MTk3NTc2#discussion_r1097850915
2023-02-06 22:35:37 +00:00
hkalbasi
40cf8b45ac reuse fetching target data layout from rustc function 2023-02-06 23:48:20 +03:30
bors
e9ce02ce63 Auto merge of #14087 - HKalbasi:layout, r=Veykril
Support computing layout of RPIT

And some refactoring to make code more type safe.
2023-02-06 19:42:58 +00:00
hkalbasi
443bc7f193 Support layout of RPIT 2023-02-06 20:50:25 +03:30
bors
62523024d3 Auto merge of #14091 - Veykril:workspace-sysroot, r=Veykril
Support sysroot library source being defined inside the workspace

With this you can now specify `cargo.sysrootSrc`. This is required for the rust workspace such that the `library` folder inside the workspace can be used as the sysroot library sources. We now also recognize if these sources are inside the workspace, tagging the as workspace members.

This does duplicate the sysroot crates still, but I don't think that causes too many problems.
2023-02-06 14:24:51 +00:00
Lukas Wirth
c6305c5659 fix: Don't panic on broken syntax trees in adjustment inlay hints 2023-02-06 12:38:57 +01:00
Lukas Wirth
cb9a5b9549 Support sysroot library source being defined inside the workspace 2023-02-06 12:07:33 +01:00
Ryo Yoshida
a4d0b5c522
Add regression tests 2023-02-05 22:28:03 +09:00
Ryo Yoshida
0ec2911857
fix: consider relative offset to fake ident token in expansion for completion 2023-02-05 22:27:52 +09:00
Lukas Wirth
9053bcc65c Make mbe compile with parser changes 2023-02-03 21:39:24 +01:00
Lukas Wirth
6fa6efe90f fix: Fix parsing of nested tuple field accesses in a cursed way 2023-02-03 17:18:48 +01:00
bors
3bc33c7e9f Auto merge of #14010 - silvergasp:ci, r=lnicola
fuzz: Fixes broken Cargo.toml for fuzz tests

Fixes broken Cargo.toml for fuzz tests and adds building of fuzz tests to the CI.
2023-02-03 11:15:54 +00:00
Lukas Wirth
dab685dd87 De-magic number parser::Output encoding 2023-02-03 11:47:33 +01:00
bors
6133e27b83 Auto merge of #14070 - Veykril:proc-macro-api, r=Veykril
Implement proc-macro-api versioning

So as it stands, we can't really change the proc-macro-api protocol at all without breaking all proc-macro servers again. To somewhat alleviate this we can move the supported ABI mess over to the proc-macro-api now by supporting multiple versions there (versions defined by us at least, not by rustc). Since the proc-macro-api protocol has no versioning scheme at the moment though, the best we can do here is add a new request to query the version from a server. Due to how the server currently works though, if it encounters an unknown request it will exit, meaning we can check if it is a server without support by checking if it exited after our version check request, that way we can support the current circulating server as well.

We need this since our span type will change from `TokenId` to something else at some point, but for that to work we need to comply with that the server expects. So knowing the version the server is using we can decide whether to send our new span data, or the tokenid (assuming we keep that information with our span data as well, alternatively we send irrelevant tokenids). That way we can keep old servers working while the user installations slowly migrate to newer servers that support the new spandata.
2023-02-03 09:41:24 +00:00
Lukas Wirth
8e998c4aa7 Fail spawning proc-macro servers when their api version is newer than r-a's 2023-02-03 10:38:38 +01:00
Ryo Yoshida
98c8077495
fix: support non-ascii characters in case conversion 2023-02-03 18:11:11 +09:00
bors
eeceba7480 Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril
Support generic function in `generate_function` assist

Part of #3639

This PR adds support for generic function generation in `generate_function` assist. Now the assist looks for generic parameters and trait bounds in scope, filters out irrelevant ones, and generates new function with them.

See `fn_generic_params()` for the outline of the procedure, and see comments on `filter_unnecessary_bounds()` for criteria for filtering. I think it's good criteria for most cases, but I'm open to opinions and suggestions.

The diff is pretty big, but it should run in linear time w.r.t. the number of nodes we operate on and should be fast enough.

Some notes:
- When we generate function in an existing impl, generic parameters may cause name conflict. While we can detect the conflict and rename conflicting params, I didn't find it worthwhile mainly because it's really easy to resolve on IDE: use Rename functionality.
- I've implemented graph structure myself, because we don't have graph library as a dependency and we only need the simplest one.
  - Although `petgraph` is in our dependency graph and I was initially looking to use it, we don't actually depend on it AFAICT since it's only used in chalk's specialization graph handling, which we don't use. I'd be happy to replace my implementation with `petgraph` if it's okay to use it though.
- There are some caveats that I consider out of scope of this PR. See FIXME notes on added tests.
2023-02-02 09:06:22 +00:00
Ryo Yoshida
493cabbde7
Treat scope info retrieval failure as assist failure 2023-02-02 17:47:11 +09:00
bors
ccd142c616 Auto merge of #14058 - gftea:master, r=Veykril
fix negative trait bound in outline view (#14044)

try to fix and close #14044
2023-02-01 20:00:19 +00:00
Laurențiu Nicola
ff340f9c21 Bump zip 2023-02-01 19:24:32 +02:00
bors
7acc434f46 Auto merge of #14071 - Veykril:inlay-hints, r=Veykril
fix: Don't render fieldless discriminant inlay hints for datacarrying enums
2023-02-01 10:39:15 +00:00
Lukas Wirth
14f19c73e9 fix: Don't render fieldless discriminant inlay hints for datacarrying enums 2023-02-01 11:38:39 +01:00
bors
bfe82cda48 Auto merge of #14036 - Veykril:write-method-resolution, r=Veykril
Record method resolution for remaining operator expressions

This allows goto def and future substituted hover to work for the concrete impls.
2023-02-01 10:23:33 +00:00
Lukas Wirth
c40b0895f0 Implement proc-macro-api versioning 2023-02-01 11:04:20 +01:00
hkalbasi
0bf0d937b8 unsize cast array only on pointer type 2023-01-31 20:23:38 +03:30
Lukas Wirth
41a46a78f2 Make tt generic over the span data 2023-01-31 14:58:16 +01:00
Ryo Yoshida
3edde6fcc1
Support generic function in generate_function assist 2023-01-31 21:05:25 +09:00
Ryo Yoshida
32955c30cd
Add method to get generic parameters in a type 2023-01-31 21:05:23 +09:00
Ryo Yoshida
0df70d37fc
Minor refactoring 2023-01-31 21:05:04 +09:00
bors
577e839c0d Auto merge of #14063 - Veykril:proc-macro-abi-1-58, r=Veykril
feat: Remove support for 1.58 proc-macro abi

This seems old enough that we can drop the support for it now, the less ABIs we have the less work it is adjusting our span implementation.

Extracted from https://github.com/rust-lang/rust-analyzer/pull/14061, will rebase that over this once merged.
2023-01-31 11:17:29 +00:00
bors
06981d4b10 Auto merge of #14062 - WaffleLapkin:сurrent_edition, r=Veykril
internal: Set "current" edition to 2021

:p
2023-01-31 11:03:49 +00:00
Lukas Wirth
183f171263 Remove support for 1.58 proc-macro abi 2023-01-31 11:56:12 +01:00
Maybe Waffle
249ea9502d Set "current" edition to 2021 2023-01-31 10:51:43 +00:00
bors
b4832b3d00 Auto merge of #14056 - Veykril:allow_internal_unsafe, r=Veykril
Parse macros `allow_internal_unsafe` attribute

We don't use it for anything yet but it might become part of hygiene
2023-01-31 10:50:47 +00:00
bors
be76f357af Auto merge of #14034 - lnicola:tweak-change-collapsing, r=Veykril
internal: Tweak change collapsing

CC https://github.com/rust-lang/rust-analyzer/pull/14025#discussion_r1087946555.
2023-01-31 10:37:50 +00:00
gftea
fd1a9a93fe tidy by rustfmt 2023-01-30 20:34:07 +01:00
gftea
04a4ac1cff trim trailing whitespaces 2023-01-30 20:17:12 +01:00
gftea
5356a8b157 trim trailing whitespaces (#14044) 2023-01-30 20:03:50 +01:00
gftea
75676ebe86
Update crates/ide/src/file_structure.rs
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2023-01-30 19:17:48 +01:00