Commit graph

18140 commits

Author SHA1 Message Date
Lukas Wirth
abe8f1ece4 Implement builtin#format_args, using rustc's format_args parser 2023-09-05 19:19:46 +02:00
bors
caeea45999 Auto merge of #15557 - Veykril:builtin-syntax, r=Veykril
Parse builtin# syntax and add typechecking for builtin#offset_of expression

Also removes box syntax, fixes https://github.com/rust-lang/rust-analyzer/issues/14504

cc https://github.com/rust-lang/compiler-team/issues/580 https://github.com/rust-lang/rust-analyzer/issues/15082
2023-09-05 12:10:31 +00:00
Lukas Wirth
3431d586e5 Insert builtin#asm into asm! expansion 2023-09-05 14:00:49 +02:00
Lukas Wirth
15048304e3 Implement offset_of in hir-def and hir-ty 2023-09-05 12:27:52 +02:00
Lukas Wirth
9b8eb807a3 Parse builtin# syntax 2023-09-05 10:36:35 +02:00
Roberto Bampi
4f22e1a187 Update notify to 6.1.1
Unlike version 6.0.1, this does not pull windows-sys 0.4.5 as observed in #15077.

$ cargo tree --target=x86_64-pc-windows-gnu --charset=ascii | grep windows-sys

|           |   `-- windows-sys v0.42.0
|   |   |   |   |   |       `-- windows-sys v0.42.0 (*)
|       `-- windows-sys v0.48.0
    |   |   `-- windows-sys v0.48.0 (*)
    |   `-- windows-sys v0.48.0 (*)
|   `-- windows-sys v0.48.0 (*)
|   `-- windows-sys v0.42.0 (*)
2023-09-04 18:00:12 +02:00
Kirill Bulatov
7f450da39e Omit hint resolve data better
Omit sending inlay hint resolve data if inlay has no properties that
client resolve capabilities support.
2023-09-02 23:56:48 +03:00
Kirill Bulatov
7b3dba5d77 Provide resolve data only when it can actually be resolved 2023-09-02 22:14:08 +03:00
Kirill Bulatov
caf018507a Ensure resolved hint's file exists 2023-09-02 18:28:36 +03:00
Kirill Bulatov
10464c7c42 Simplify InlayFieldsToResolve handling 2023-09-02 18:28:36 +03:00
Kirill Bulatov
e07fbabcfe Resolve inlay hint data
Skip every propery set in inlay hint client resolve capabilities,
reducing overall json footprint.
2023-09-02 18:28:35 +03:00
bors
99686d56a8 Auto merge of #15551 - Veykril:docs, r=Veykril
Move doc comment handling into ide-db
2023-09-02 15:28:07 +00:00
Lukas Wirth
81f0108067 Remove markdown module from rust-analyzer crate 2023-09-02 17:27:52 +02:00
Lukas Wirth
8eddc64f86 Simplify 2023-09-02 17:12:57 +02:00
Lukas Wirth
b1575528c0 Move doc comment handling into ide-db 2023-09-02 16:27:26 +02:00
bors
0e002fe5c6 Auto merge of #15549 - Veykril:unwind-if-cancelled, r=Veykril
Add a few more `db.unwind_if_cancelled()` calls

Judging from a profile sent by a friend, the borrowck query took up a significant amount of time in their project which might be the cause for some unresponsiveness as nothing in the mir stack currently unwinds on cancellation
2023-09-02 12:40:44 +00:00
Lukas Wirth
0bf0563a00 Add a few more db.unwind_if_cancelled() calls 2023-09-02 14:39:19 +02:00
bors
8a29d0776f Auto merge of #15548 - Veykril:r-a-restructure, r=Veykril
Restructure some modules in rust-analyzer crate
2023-09-02 12:22:06 +00:00
Lukas Wirth
2dbc7e3e1a Restructure some modules in rust-analyzer crate 2023-09-02 14:16:04 +02:00
cui fliter
056b6b9416 remove the repetitive word
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-02 14:18:10 +08:00
bors
60182f7043 Auto merge of #15544 - Veykril:locks, r=Veykril
Shuffle some locking around

The main thread is still occasionally blocking on something and I am unsure what the cause might be. This will hopefully help somewhat
2023-09-01 19:55:03 +00:00
Lukas Wirth
c19390992c Reduce semantic token cache lock scopes 2023-09-01 21:54:29 +02:00
Kirill Bulatov
da786170f8 Use proper assertion in on-type formatting edits
Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2023-09-01 21:49:51 +03:00
Kirill Bulatov
0f1cde709a On type format '(', by adding closing ')' automatically 2023-09-01 21:49:50 +03:00
Lukas Wirth
cc8b78601d Shuffle some locking around 2023-09-01 20:45:46 +02:00
bors
074c66882f Auto merge of #15543 - Veykril:less-alloc, r=Veykril
Remove some allocations in borrowck
2023-09-01 18:28:42 +00:00
Lukas Wirth
70e21dc30b Remove some allocations in borrowck 2023-09-01 19:17:57 +02:00
bors
ce650ce19d Auto merge of #15542 - Veykril:std-once, r=Veykril
Less `once_cell` more `std`
2023-09-01 16:05:24 +00:00
Lukas Wirth
c09f175d59 Less once_cell more std 2023-09-01 17:30:59 +02:00
vsrs
1eb6d2e9a9 Rollback changes in remove_unused_param.rs 2023-08-29 23:06:12 +07:00
vsrs
6b559c4a9a Better trait implementation support 2023-08-29 22:56:31 +07:00
Kirill Bulatov
62d189702c Only send inlay hint refresh requests on initial load
Editor itself is able to invalidate hints after edits, and /refresh was
sent after editor reports changes to the language server.
This forces the editor to either query & invalidate the hints twice
after every edit, or wait for /refresh to come before querying the
hints.

Both options are rather useless, so instead, send a request on server
startup only: client editors do not know when the server actually starts
up, this will help to query the initial hints after editor was open and
the server was still starting up.
2023-08-29 13:04:04 +03:00
bors
b06503b6ec Auto merge of #15465 - Wilfred:command_handle_fixes, r=Veykril
Fix cargo handle logging in flycheck

This PR has two commits, so it's probably easier to review them separately:

(1) Rename `CargoHandle` to `CommandHandle`, as the command may not be a cargo command.

(2) Logging should format the current command, rather than calling `check_command()` again. This ensures that any later configuration changes don't cause us to log incorrect information.
2023-08-29 07:16:20 +00:00
vsrs
6b20c1b091 Apply suggestions. 2023-08-29 13:39:56 +07:00
hkalbasi
514fefab9c Respect #[allow(unused_braces)] 2023-08-28 22:22:28 +03:30
vsrs
19e99941b6 Add cov_mark tests 2023-08-28 16:41:08 +07:00
vsrs
e457759cbb Add bind_unused_param assistant. 2023-08-28 15:23:20 +07:00
xffxff
204bc2cb60 fix: diagnostics for 'while let' loop with label in condition 2023-08-26 10:41:19 +08:00
hkalbasi
fa76f60cc1 Run cargo fmt on 1.72 2023-08-25 22:24:41 +03:30
hkalbasi
3864b43d28 Update offset intrinsic to match 1.72 2023-08-25 22:24:40 +03:30
bors
f5b7c60ff7 Auto merge of #15385 - inferiorhumanorgans:explicit-cross-target, r=Veykril
proc-macro-test: Pass target to cargo invocation

When cross compiling macos → dragonfly the dist build fails in the proc-maro-test-impl crate with the following error:

`ld: unknown option: -z\nclang: error: linker command failed with exit code 1 (use -v to see invocation)`

This appears to be a wart stemming from using an Apple host for cross compiling.  Passing the target along to cargo allows it to pick up a linker that it understands and DTRT.
2023-08-23 07:29:30 +00:00
Laurențiu Nicola
a4b25034d6 Merge branch 'master' into sync-from-rust 2023-08-23 10:06:55 +03:00
Wilfred Hughes
bc42b9911d SCIP: Report the correct version of rust-analyzer in the metadata
Previously this was hard coded to "0.1". The SCIP protocol allows this
to be an arbitrary string:

```
message ToolInfo {
  // Name of the indexer that produced this index.
  string name = 1;
  // Version of the indexer that produced this index.
  string version = 2;
  // Command-line arguments that were used to invoke this indexer.
  repeated string arguments = 3;
}
```

so use the same string reported by `rust-analyzer --version`.
2023-08-22 18:51:39 -07:00
Michael Goulet
ce0eeee400 Rollup merge of #115011 - compiler-errors:warn-on-elided-assoc-ct-lt, r=cjgillot
Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`)

Elided lifetimes in associated constants (in impls) erroneously resolve to fresh lifetime parameters on the impl since #97313. This is not correct behavior (see #38831).

I originally opened #114716 to fix this, but given the time that has passed, the crater results seem pretty bad: https://github.com/rust-lang/rust/pull/114716#issuecomment-1682091952

This PR alternatively implements a lint against this behavior, and I'm hoping to bump this to deny in a few versions.
2023-08-22 09:00:49 -07:00
Michael Goulet
7012fff9ab Fix elided lifetimes in rust-lang/rust 2023-08-21 23:53:09 +00:00
Laurențiu Nicola
6caf79c36e Allow internal_features in test 2023-08-21 22:15:56 +03:00
Laurențiu Nicola
a4cf40537a Merge branch 'master' into sync-from-rust 2023-08-21 16:16:04 +03:00
Laurențiu Nicola
30d8aa1bec Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-from-ra 2023-08-21 12:44:09 +03:00
bors
9b3d03408c Auto merge of #15490 - RalfJung:check-invocation-help, r=Veykril
fix help text for rust-analyzer.check.invocation{Strategy,Location}

I highly doubt that `check.invocationLocation` only has an effect if `cargo.buildScripts.overrideCommand` is set -- looks like a copy-paste mistake from `buildScripts.invocationLocation` to me.
2023-08-21 08:06:50 +00:00
Ralf Jung
887cc48ba8 fix help text for rust-analyzer.check.invocation{Strategy,Location} 2023-08-21 09:54:24 +02:00
Jessie Chatham Spencer
37e0e8af10 Implement extern crate completion 2023-08-20 16:36:59 +00:00
Ralf Jung
883f16d805 fix RA build 2023-08-20 18:31:22 +02:00
Ralf Jung
59f9c95ec0 give some unwind-related terminators a more clear name 2023-08-20 15:52:38 +02:00
bors
c0f6ece3c4 Auto merge of #15434 - alibektas:deunwrap/generate_derive, r=lnicola
minor : Deunwrap generate_derive

#15398 subtask 1. Since the editing closure has arms, I did something *experimental* ( in this case just a clever term for bad code ) to bypass creating an `Option` but I am ready to change this.
2023-08-18 16:16:27 +00:00
Lukas Wirth
eb6244c5f9 Record import aliases in symbol index 2023-08-18 11:46:35 +02:00
Lukas Wirth
637f496a81 fix: Fix auto-import (and completions) importing #[doc(hidden)] items 2023-08-17 12:30:19 +02:00
bors
49716e681a Auto merge of #15472 - Veykril:import-ide-support, r=Veykril
internal: Record import origins in ItemScope and PerNS

This records the import items definitions come from in the module scope (as well as what an import resolves to in an ItemScope). It does ignore glob imports as thats a lot more work for little to no gain, glob imports act as if the importing items are "inlined" into the scope which suffices for almost all use cases I believe (to my knowledge, attributes on them have little effect).

There is still a lot of work needed to make this available to the IDE layer, but this lays out the ground work for havin IDE layer support.

cc https://github.com/rust-lang/rust-analyzer/issues/14079
2023-08-17 09:56:42 +00:00
Lukas Wirth
a17d73ad36 Thread imports through the resolver 2023-08-17 10:52:13 +02:00
Lukas Wirth
c4e9b5ac64 Add import info to item scope dumps 2023-08-17 09:33:15 +02:00
Lukas Wirth
af8048266c Prepare ItemScope for IDE import resolution 2023-08-16 11:33:42 +02:00
Lukas Wirth
53b292478d internal: Add offset param to token descending API 2023-08-16 10:07:18 +02:00
Wilfred Hughes
e2866404ef Format the existing command in logging 2023-08-15 16:07:06 -07:00
Wilfred Hughes
14078ed303 Rename CargoHandle to CommandHandle
This handle wraps an arbitrary command, which might be a rustc command
rather than cargo.
2023-08-15 16:06:25 -07:00
Ali Bektas
2a78173ff8 v2 2023-08-16 00:22:08 +02:00
bors
b14770934a Auto merge of #15463 - ponyii:fix/start-hovering-default-values-of-generic-const, r=HKalbasi
fix: start hovering default values of generic constants

It's just a kind of a postscriptum for [my last PR](https://github.com/rust-lang/rust-analyzer/pull/15179) adding default values of const generics to `hir::ConstParamData`. Here I patch other pieces of code which used to ignore const default values and which I managed to find (you're welcome to show me more)
2023-08-15 20:34:48 +00:00
Ali Bektas
eed1b3b652 v2 2023-08-15 19:37:23 +02:00
ponyii
fec5ff9890 start hovering default values of generic constants 2023-08-15 20:26:42 +04:00
Laurențiu Nicola
4c67becd44 Always collect memory usage info in analysis-stats 2023-08-15 18:22:37 +03:00
bors
b771de3fdc Auto merge of #15179 - ponyii:fix/default-values-of-const-params-are-ignored, r=HKalbasi
the "add missing members" assists: implemented substitution of default values of const params

To achieve this, I've made `hir::ConstParamData` store the default values
2023-08-15 10:17:43 +00:00
bors
7ca45dcf04 Auto merge of #15410 - alibektas:15240/invalid-demorgan, r=Veykril
internal : rewrite DeMorgan assist

fixes #15239 , #15240 . This PR is a rewrite of the DeMorgan assist that essentially rids of all the string manipulation and modifies syntax trees to apply demorgan on a binary expr. The main reason for the rewrite is that I wanted to use `Expr::needs_parens_in` method to see if the expr on which the assist is applied would still need the parens it had once the parent expression's operator had equal precedence with that of the expression. I used `.clone_(subtree|for_update)` left and right and probably more than I should have, so I would also be happy to hear how I could have prevented redundant cloning.
2023-08-15 07:29:28 +00:00
bors
c18ce9a08b Auto merge of #15429 - alibektas:deunwrap/generate_delegate_methods, r=Veykril
minor : Deunwrap generate_delegate_methods

#15398 subtask 8
2023-08-15 07:15:25 +00:00
bors
0b2a241b57 Auto merge of #15426 - alibektas:deunwrap/convert_to_guarded_return, r=Veykril
minor : Deunwrap convert_to_guarded_return

Closes subtask 12 of #15398
2023-08-15 07:00:03 +00:00
bors
f73cd39f7b Auto merge of #15383 - max-heller:issue-12568, r=Veykril
Suggest type completions for type arguments and constant completions for constant arguments

When determining completions for generic arguments, suggest only types or only constants if the corresponding generic parameter is a type parameter or constant parameter.

Closes #12568
2023-08-15 06:39:50 +00:00
bors
0fa822dfe1 Auto merge of #15418 - oxalica:fix/sig-from-macro, r=Veykril
Fix signature help of methods from macros

Currently the receiver type is copied from AST instead re-formatting through `HirDisplay`. Macro generated functions seem to have no spaces and their signature help are rendered like `fn foo(&'amutself)` instead of `fn foo(&'a mut self)`.
2023-08-15 06:25:13 +00:00
dirreke
d6b97e64fc Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
dirreke
465aaed1cf fix the wrong number in const KNOWN_ARCH 2023-08-14 23:02:37 +08:00
Dirreke
93b6838158 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
bors
2fbe69d117 Auto merge of #15438 - Veykril:eager-parser-stuck, r=Veykril
fix: Fix parser being stuck in eager macro inputs

Fixes https://github.com/rust-lang/rust-analyzer/issues/15437
2023-08-12 14:30:38 +00:00
Lukas Wirth
9ac88d8d36 Fix parser being stuck in eager macro inputs 2023-08-12 08:27:27 +02:00
bors
6cf06c1675 Auto merge of #15445 - Veykril:worl-symbols-traits, r=Veykril
fix: Fix `only_types` config filtering out traits from world symbols

It is a bit confusing that this apparently did not filter every trait out though...

Closes https://github.com/rust-lang/rust-analyzer/issues/15444
Closes https://github.com/rust-lang/rust-analyzer/issues/15200
2023-08-12 04:55:17 +00:00
Lukas Wirth
d6d188fce2 fix: Fix only_types config filtering out traits from world symbols 2023-08-12 06:40:49 +02:00
bors
39ebc378c2 Auto merge of #15436 - Veykril:temp-alloc, r=Veykril
Preserve `resolve_obligations_as_possible` temporary allocation across calls

This saves ~20ms in the highlihting bench on my machine
```
  284ms - highlight
      150ms - infer:wait @ per_query_memory_usage
          150ms - infer_query
                0   - PerNs::filter_visibility (436 calls)
                0   - crate_def_map:wait (336 calls)
                2ms - deref_by_trait (909 calls)
                0   - generic_params_query (1 calls)
                0   - inherent_impls_in_block_query (1 calls)
              107ms - resolve_obligations_as_possible (17013 calls)
                0   - trait_solve::wait (1017 calls)
        0   - PerNs::filter_visibility (13 calls)
       17ms - Semantics::analyze_impl (19 calls)
        0   - SourceBinder::to_module_def (30 calls)
        0   - attrs_query (6 calls)
        0   - classify_lifetime (1 calls)
        0   - classify_lifetime_ref (4 calls)
       35ms - classify_name (28 calls)
       54ms - classify_name_ref (452 calls)
        0   - crate_def_map:wait (375 calls)
        7ms - descend_into_macros (776 calls)
        0   - generic_params_query (5 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       17ms - infer:wait (32 calls)
        0   - resolve_obligations_as_possible (1 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (1 calls)
```
to
```

  256ms - highlight
      121ms - infer:wait @ per_query_memory_usage
          121ms - infer_query
                0   - PerNs::filter_visibility (436 calls)
                0   - crate_def_map:wait (336 calls)
                2ms - deref_by_trait (909 calls)
                0   - generic_params_query (1 calls)
                0   - inherent_impls_in_block_query (1 calls)
               81ms - resolve_obligations_as_possible (17013 calls)
                0   - trait_solve::wait (1017 calls)
        0   - PerNs::filter_visibility (13 calls)
       17ms - Semantics::analyze_impl (19 calls)
        0   - SourceBinder::to_module_def (30 calls)
        0   - attrs_query (6 calls)
        0   - classify_lifetime (1 calls)
        0   - classify_lifetime_ref (4 calls)
       35ms - classify_name (28 calls)
       56ms - classify_name_ref (452 calls)
        0   - crate_def_map:wait (375 calls)
        7ms - descend_into_macros (776 calls)
        0   - generic_params_query (5 calls)
        0   - impl_data_with_diagnostics_query (1 calls)
       16ms - infer:wait (32 calls)
        0   - resolve_obligations_as_possible (1 calls)
        0   - source_file_to_def (1 calls)
        0   - trait_solve::wait (1 calls)
```
2023-08-12 04:38:32 +00:00
Lukas Wirth
c1c8e787d2 Preserve resolve_obligations_as_possible temporary allocation across calls 2023-08-12 06:36:31 +02:00
bors
1fde334195 Auto merge of #15433 - alibektas:deunwrap/remove_unused_imports, r=lnicola
minor : Deunwrap remove_unused_imports

#15398 Subtask 3
2023-08-11 11:14:45 +00:00
bors
de28baf874 Auto merge of #15424 - lnicola:remove-remove-dbg-unwrap, r=lnicola
minor: Remove `unwrap` from `Remove dbg!`

Part of #15398.
2023-08-11 07:56:10 +00:00
Lukas Wirth
9adff006e8 Simplify 2023-08-10 20:10:19 +02:00
Lukas Wirth
bfad781a77 Memoize block_item_tree_query 2023-08-10 19:24:39 +02:00
Lukas Wirth
fde2d9b47c Deduplicate FileId field in ModuleOrigin 2023-08-10 19:04:46 +02:00
Lukas Wirth
e5b23e3bc1 Derive block attributes from block item tree 2023-08-10 18:52:27 +02:00
Ali Bektas
94b3481808 Deunwrap generate_derive 2023-08-10 01:46:51 +02:00
Ali Bektas
423b00a83a Deunwrap remove_unused_imports 2023-08-10 01:22:26 +02:00
Ali Bektas
a46eebbc9f Deunwrap wrap_return_type_in_result 2023-08-09 23:51:27 +02:00
Ali Bektas
c81a0681a2 Deunwrap generate_delegate_methods 2023-08-09 23:42:52 +02:00
bors
05b0612051 Auto merge of #15428 - Veykril:lsp-types-pin, r=Veykril
Fix pinned version of lsp-types

lsp-types published a new patch version that breaks semver with the proposed feature set (this is intended and documented), we unfortunately forgot to specify the patch version for the pinned version so this breaks us.
2023-08-09 18:07:44 +00:00
Lukas Wirth
7e04142f25 Fix pinned version of lsp-types 2023-08-09 20:06:08 +02:00
Ali Bektas
ebf27058cd minor : Deunwrap convert_to_guarded_return 2023-08-09 17:17:43 +02:00
bors
b78d69c795 Auto merge of #15422 - Veykril:import-sources, r=Veykril
internal: Record import source IDs

cc https://github.com/rust-lang/rust-analyzer/issues/14079
2023-08-09 15:09:15 +00:00
Lukas Wirth
63aba76735 Remove unnecessary ItemTreeId field in ImportSource 2023-08-09 17:06:52 +02:00
Laurențiu Nicola
b658f9a954 Remove unwrap from Remove dbg 2023-08-09 17:54:34 +03:00
bors
b6ee96c3b5 Auto merge of #15423 - alibektas:deunwrap/convert_named_struct_to_tuple_struct, r=lnicola
internal : Deunwrap convert_named_struct_to_tuple_struct

Replaces `unwrap`s with `?` for the mentioned assist.
2023-08-09 14:52:09 +00:00