Commit graph

17766 commits

Author SHA1 Message Date
Ryo Yoshida
f9c1a7dcd9
fix: assignment operators are right associative 2023-06-03 19:58:35 +09:00
hkalbasi
aab7589c40 Fix string pattern matching in mir interpreter 2023-06-02 23:45:29 +03:30
bors
dfaca9398a Auto merge of #14950 - HKalbasi:render-const, r=HKalbasi
Support floating point intrinsics in const eval
2023-06-02 13:59:47 +00:00
hkalbasi
a6a27a7ff8 Support floating point intrinsics in const eval 2023-06-02 17:29:17 +03:30
bors
7738ff4927 Auto merge of #14945 - justahero:gh-14626, r=Veykril
Fix Assist "replace named generic type with impl trait"

This is a follow-up PR to fix the assist "replace named generic type with impl trait" described in #14626 to filter invalid param types. It integrates the feedback given in PR #14816 .

The change updates the logic to determine when a function parameter is safe to replace a type param with its trait implementation. Some parameter definitions are invalid & should not be replaced by their traits, therefore skipping the assist completely.

First, all usages of the generic type under the cursor are determined. These usage references are checked to see if they occur outside the function parameter list. If an outside reference is found, e.g. in body, return type or where clause, the assist is skipped. All remaining usages need to appear only in the function param list. For each usage the param type is further inspected to see if it's valid. The logic to determine if a function parameter is valid, follows a heuristic and may not cover all possible parameter definitions.

With this change the following param types (as given in [this comment](https://github.com/rust-lang/rust-analyzer/pull/14816#discussion_r1206834603)) are not replaced & therefore skip the assist.

```rust
fn foo<P: Trait>(
    _: <P as Trait>::Assoc,          // within path type qualifier
    _: <() as OtherTrait<P>>::Assoc, // same as above
    _: P::Assoc,                     // associated type shorthand
    _: impl OtherTrait<P>            // generic arg in impl trait (note that associated type bindings are fine)
    _: &dyn Fn(P)                    // param type and/or return type for Fn* traits
) {}
```
2023-06-02 13:09:31 +00:00
Sebastian Ziebell
c0e9b57371 Improve assist to filter invalid params
The change updates the logic to determine if a function parameter is
valid for replacing the type param with the trait implementation.

First all usages are determined, to check if they are used outside the function
parameter list. If an outside reference is found, e.g. in body, return type or
where clause, the assist is skipped. All remaining usages only appear in the
function param list. For each usage the param type is checked to see if
it's valid.

**Please note** the logic currently follows a heuristic and may not cover
all existing parameter declarations.

* determine valid usage references by checking ancestors (on AST level)
* split test into separate ones
2023-06-02 12:46:01 +02:00
bors
0677c204ca Auto merge of #14947 - HKalbasi:render-const, r=HKalbasi
Add enum, reference, array and slice to `render_const_scalar`
2023-06-02 10:18:36 +00:00
hkalbasi
f9e3b180b7 Add enum, reference, array and slice to render_const_scalar 2023-06-02 13:47:02 +03:30
bors
0b4c09b1d2 Auto merge of #14941 - Veykril:def-map, r=Veykril
Shrink `DefMap`, share crate level items with block def maps
2023-06-01 16:42:12 +00:00
Lukas Wirth
11b937177b Skip extern prelude path resolution in block def maps 2023-06-01 17:58:08 +02:00
bors
4458e7f190 Auto merge of #14942 - HKalbasi:for-loop-label, r=HKalbasi
fix bug in labeled for loop desugaring

fix https://github.com/rust-lang/rust-analyzer/pull/14892#discussion_r1213091393
2023-06-01 14:54:47 +00:00
hkalbasi
f4c52b40bd fix bug in labeled for loop desugaring 2023-06-01 17:51:53 +03:30
Lukas Wirth
54e3ef658a Rename nameres::CrateData to DefMapCrateData 2023-06-01 15:50:19 +02:00
Lukas Wirth
1e6406e223 Move extern prelude into CrateData 2023-06-01 15:49:05 +02:00
Lukas Wirth
bdca349573 Arc DefMap::data so the block def maps can share it 2023-06-01 15:27:05 +02:00
Lukas Wirth
5c466ccc2b Refactor out some crate wide data in DefMap into nested struct 2023-06-01 15:04:38 +02:00
Lukas Wirth
dc7c6d43c7 Slightly shrink DefMap 2023-06-01 14:46:36 +02:00
bors
117f9b7752 Auto merge of #14939 - Veykril:nav-focus-ranges, r=Veykril
fix: Fix nav target calculation discarding file ids from differing macro upmapping

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

Turns out there was the assumption that upmapping from a macro will always end in the same root file, which is no longer the case thanks to `include!`
2023-06-01 09:19:24 +00:00
Lukas Wirth
a7d604d46f fix: Fix nav target calculation discarding file ids from differing macro upmapping 2023-06-01 11:05:03 +02:00
bors
7f2ac29e28 Auto merge of #14938 - Veykril:sig-help, r=Veykril
Add signature help for tuple patterns and expressions

~~These are somewhat wonky since their signature changes as you type depending on context but they help out nevertheless.~~ should be less wonky now with added parser and lowering recoveries
2023-06-01 07:07:23 +00:00
Lukas Wirth
0e28202832 Insert missing expr/pat for leading comma tuples 2023-06-01 08:56:40 +02:00
Lukas Wirth
7d1bf7023d Recover from leading comma in tuple pat and expr 2023-06-01 08:40:50 +02:00
Lukas Wirth
42450d2511 Add signature help for tuple patterns and expressions 2023-06-01 07:45:55 +02:00
bors
bafa6c4ee5 Auto merge of #14935 - Veykril:sysroot-dedup, r=Veykril
fix: Don't duplicate sysroot crates in rustc workspace

Since we handle `library` as the sysroot source directly in the rustc workspace, we now duplicate the crates there, once as sysroot and once as just plain workspace crate. This causes a variety of issues for `vec!` macros and similar that emit `$crate` tokens across crates.
2023-05-31 13:50:53 +00:00
Lukas Wirth
ecb8616870 fix: Don't duplicate sysroot crates in rustc workspace 2023-05-31 15:37:35 +02:00
Oli Scherer
1570299af4 Remove const eval limit and implement an exponential backoff lint instead 2023-05-31 10:24:17 +00:00
bors
526507fe22 Auto merge of #14888 - lunacookies:multi-qos, r=Veykril
Prioritize threads affected by user typing

To this end I’ve introduced a new custom thread pool type which can spawn threads using each QoS class. This way we can run latency-sensitive requests under one QoS class and everything else under another QoS class. The implementation is very similar to that of the `threadpool` crate (which is currently used by rust-analyzer) but with unused functionality stripped out.

I’ll have to rebase on master once #14859 is merged but I think everything else is alright :D
2023-05-31 10:23:19 +00:00
bors
d2b3caa5b5 Auto merge of #14929 - Veykril:hover-hex, r=Veykril
Add render configs for memory layout hovers

Closes https://github.com/rust-lang/rust-analyzer/issues/14918
2023-05-30 16:47:41 +00:00
Lukas Wirth
3c862507b9 Add render configs for memory layout hovers 2023-05-30 18:36:06 +02:00
bors
e33c0b4b5e Auto merge of #14842 - alibektas:internal/ast-make-improve, r=Veykril
Improve ast::make

Add `ty_alias` and make `impl_trait` , `fn` and `impl_` have more coverage.
2023-05-30 16:09:46 +00:00
bors
76d86502f7 Auto merge of #14912 - Veykril:cargo-alltargets, r=Veykril
Don't add --all-targets to runnables for no-std crates

Fixes https://github.com/rust-lang/rust-analyzer/issues/14155
2023-05-30 12:34:28 +00:00
bors
be446c6fd7 Auto merge of #14905 - Veykril:hover-hex, r=Veykril
feat: Render niches on hover
2023-05-30 12:19:51 +00:00
bors
e8dbb8e2e0 Auto merge of #14911 - Veykril:config-cfg, r=Veykril
Allow setting cfgs

Fixes https://github.com/rust-lang/rust-analyzer/issues/14365
2023-05-30 12:00:14 +00:00
Lukas Wirth
1275adc200 Don't leak rustc Layout in hir layer 2023-05-30 13:54:30 +02:00
Lukas Wirth
3514f2f2ab Render niches on hover 2023-05-30 13:49:43 +02:00
bors
51c3ab5b85 Auto merge of #14920 - lowr:fix/overhaul-named-struct-to-tuple-struct, r=Veykril
Fix edits for `convert_named_struct_to_tuple_struct`

Two fixes:
- When replacing syntax nodes, macro files weren't taken into account. Edits were simply made for `node.syntax().text_range()`, which would be wrong range when `node` is inside a macro file.
- We do ancestor node traversal for every struct name reference to find record expressions/patterns to edit, but we didn't verify that expressions/patterns do actually refer to the struct we're operating on.

Best reviewed one commit at a time.

Fixes #13780
Fixes #14927
2023-05-30 11:45:22 +00:00
Ryo Yoshida
033e6ac57a
Verify name references more rigidly
Previously we didn't verify that record expressions/patterns that were
found did actually point to the struct we're operating on. Moreover,
when that record expressions/patterns had missing child nodes, we would
continue traversing their ancestor nodes.
2023-05-29 20:10:54 +09:00
Ryo Yoshida
ab9347542c
Consider macro files when replacing nodes 2023-05-29 19:52:31 +09:00
hkalbasi
51368793b4 MIR episode 6 2023-05-28 23:25:15 +03:30
Lukas Wirth
8bc826dd53 Add diagnostic for _ expressions (typed holes) 2023-05-28 14:55:28 +02:00
Lukas Wirth
bbd9e41606 Don't add --all-targets to runnables for no-std crates 2023-05-28 14:18:44 +02:00
Luna Razzaghipour
6b46095980
Make formatting a latency-sensitive request 2023-05-28 22:10:24 +10:00
Lukas Wirth
cea84427e0 Allow setting cfgs 2023-05-28 13:43:21 +02:00
Ryo Yoshida
0d4d1d7e3b
Implement ${count()} metavariable expression 2023-05-28 19:54:36 +09:00
Ryo Yoshida
9ebaa85d37
Split test module for metavariable expressions 2023-05-28 19:54:23 +09:00
Luna Razzaghipour
74bc2a47e0
Wrap platform-specific QoS in r-a-specific “thread intent” 2023-05-28 20:37:38 +10:00
Luna Razzaghipour
d0b001eed2
Use appropriate QoS classes throughout the codebase 2023-05-28 20:37:37 +10:00
Luna Razzaghipour
2924fd2213
Implement custom QoS-aware thread pool
This code replaces the thread pool implementation we were using
previously (from the `threadpool` crate). By making the thread pool
aware of QoS, each job spawned on the thread pool can have a different
QoS class.

This commit also replaces every QoS class used previously with Default
as a temporary measure so that each usage can be chosen deliberately.
2023-05-28 20:37:35 +10:00
bors
1b5523a8cd Auto merge of #14913 - HKalbasi:fix14844, r=HKalbasi
Evaluate `UnevalutedConst` before trait solving

cc #14844
2023-05-26 21:01:20 +00:00
hkalbasi
cd4bffdd69 Evaluate UnevalutedConst before trait solving 2023-05-27 00:28:11 +03:30
Lukas Wirth
35b208aaa7 Filter out unused cargo features from config 2023-05-26 22:16:34 +02:00
Lukas Wirth
ee8c18cb6e Fix out_dirs_check test on stable 2023-05-26 20:54:58 +02:00
jyn
aa65395c49 Update proc-macro-api for the new rustc metadata format 2023-05-26 11:59:25 -05:00
bors
6bca9f2aac Auto merge of #14859 - lunacookies:qos, r=lunacookies
Specify thread types using Quality of Service API

<details>
<summary>Some background (in case you haven’t heard of QoS before)</summary>

Heterogenous multi-core CPUs are increasingly found in laptops and desktops (e.g. Alder Lake, Snapdragon 8cx Gen 3, M1). To maximize efficiency on this kind of hardware, it is important to provide the operating system with more information so threads can be scheduled on different core types appropriately.

The approach that XNU (the kernel of macOS, iOS, etc) and Windows have taken is to provide a high-level semantic API – quality of service, or QoS – which informs the OS of the program’s intent. For instance, you might specify that a thread is running a render loop for a game. This makes the OS provide this thread with as large a share of the system’s resources as possible. Specifying a thread is running an unimportant background task, on the other hand, is cause for it to be scheduled exclusively on high-efficiency cores instead of high-performance cores.

QoS APIs allows for easy configuration of many different parameters at once; for instance, setting QoS on XNU affects scheduling, timer latency, I/O priorities, and of course what core type the thread in question should run on. I don’t know any details on how QoS works on Windows, but I would guess it’s similar.

Hypothetically, taking advantage of these APIs would improve power consumption, thermals, battery life if applicable, etc.

</details>

# Relevance to rust-analyzer

From what I can tell the philosophy behind both the XNU and Windows QoS APIs is that _user interfaces should never stutter under any circumstances._ You can see this in the array of QoS classes which are available: the highest QoS class in both APIs is one intended explicitly for UI render loops.

Imagine rust-analyzer is performing CPU-intensive background work – maybe you just invoked Find Usages on `usize` or opened a large project – in this scenario the editor’s render loop should absolutely get higher priority than rust-analyzer, no matter what. You could view it in terms of “realtime-ness”: flight control software is hard realtime, audio software is soft realtime, GUIs are softer realtime, and rust-analyzer is not realtime at all. Of course, maximizing responsiveness is important, but respecting the rest of the system is more important.

# Implementation

I’ve tried my best to unify thread creation in `stdx`, where the new API I’ve introduced _requires_ specifying a QoS class. Different points along the performance/efficiency curve can make a great difference; the M1’s e-cores use around three times less power than the p-cores, so putting in this effort is worthwhile IMO.

It’s worth mentioning that Linux does not [yet](https://youtu.be/RfgPWpTwTQo) have a QoS API. Maybe translating QoS into regular thread priorities would be acceptable? From what I can tell the only scheduling-related code in rust-analyzer is Windows-specific, so ignoring QoS entirely on Linux shouldn’t cause any new issues. Also, I haven’t implemented support for the Windows QoS APIs because I don’t have a Windows machine to test on, and because I’m completely unfamiliar with Windows APIs :)

I noticed that rust-analyzer handles some requests on the main thread (using `.on_sync()`) and others on a threadpool (using `.on()`). I think it would make sense to run the main thread at the User Initiated QoS and the threadpool at Utility, but only if all requests that are caused by typing use `.on_sync()` and all that don’t use `.on()`. I don’t understand how the `.on_sync()`/`.on()` split that’s currently present was chosen, so I’ve let this code be for the moment. Let me know if changing this to what I proposed makes any sense.

To avoid having to change everything back in case I’ve misunderstood something, I’ve left all threads at the Utility QoS for now. Of course, this isn’t what I hope the code will look like in the end, but I figured I have to start somewhere :P

# References

<ul>

<li><a href="https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/PrioritizeWorkAtTheTaskLevel.html">Apple documentation related to QoS</a></li>
<li><a href="67e155c940/include/pthread/qos.h">pthread API for setting QoS on XNU</a></li>
<li><a href="https://learn.microsoft.com/en-us/windows/win32/procthread/quality-of-service">Windows’s QoS classes</a></li>
<li>
<details>
<summary>Full documentation of XNU QoS classes. This documentation is only available as a huge not-very-readable comment in a header file, so I’ve reformatted it and put it here for reference.</summary>
<ul>
<li><p><strong><code>QOS_CLASS_USER_INTERACTIVE</code>: A QOS class which indicates work performed by this thread is interactive with the user.</strong></p><p>Such work is requested to run at high priority relative to other work on the system. Specifying this QOS class is a request to run with nearly all available system CPU and I/O bandwidth even under contention. This is not an energy-efficient QOS class to use for large tasks. The use of this QOS class should be limited to critical interaction with the user such as handling events on the main event loop, view drawing, animation, etc.</p></li>
<li><p><strong><code>QOS_CLASS_USER_INITIATED</code>: A QOS class which indicates work performed by this thread was initiated by the user and that the user is likely waiting for the results.</strong></p><p>Such work is requested to run at a priority below critical user-interactive work, but relatively higher than other work on the system. This is not an energy-efficient QOS class to use for large tasks. Its use should be limited to operations of short enough duration that the user is unlikely to switch tasks while waiting for the results. Typical user-initiated work will have progress indicated by the display of placeholder content or modal user interface.</p></li>
<li><p><strong><code>QOS_CLASS_DEFAULT</code>: A default QOS class used by the system in cases where more specific QOS class information is not available.</strong></p><p>Such work is requested to run at a priority below critical user-interactive and user-initiated work, but relatively higher than utility and background tasks. Threads created by <code>pthread_create()</code> without an attribute specifying a QOS class will default to <code>QOS_CLASS_DEFAULT</code>. This QOS class value is not intended to be used as a work classification, it should only be set when propagating or restoring QOS class values provided by the system.</p></li>
<li><p><strong><code>QOS_CLASS_UTILITY</code>: A QOS class which indicates work performed by this thread may or may not be initiated by the user and that the user is unlikely to be immediately waiting for the results.</strong></p><p>Such work is requested to run at a priority below critical user-interactive and user-initiated work, but relatively higher than low-level system maintenance tasks. The use of this QOS class indicates the work should be run in an energy and thermally-efficient manner. The progress of utility work may or may not be indicated to the user, but the effect of such work is user-visible.</p></li>
<li><p><strong><code>QOS_CLASS_BACKGROUND</code>: A QOS class which indicates work performed by this thread was not initiated by the user and that the user may be unaware of the results.</strong></p><p>Such work is requested to run at a priority below other work. The use of this QOS class indicates the work should be run in the most energy and thermally-efficient manner.</p></li>
<li><p><strong><code>QOS_CLASS_UNSPECIFIED</code>: A QOS class value which indicates the absence or removal of QOS class information.</strong></p><p>As an API return value, may indicate that threads or pthread attributes were configured with legacy API incompatible or in conflict with the QOS class system.</p></li>
</ul>
</details>
</li>

</ul>
2023-05-26 15:48:22 +00:00
Lukas Wirth
be9cc0baae Render size, align and offset hover values in hex 2023-05-26 16:41:45 +02: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
Ryo Yoshida
397c8e5148
fix: don't try determining type of token inside macro calls 2023-05-26 16:46:45 +09: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
hkalbasi
780349bdaf fix need-mut false positive in closure capture of match scrutinee 2023-05-26 02:08:37 +03:30
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
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
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
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
bors
4de8c0980e Auto merge of #14857 - Veykril:perf, r=Veykril
internal: Shrink ProcMacroExpander from 8 to 4 bytes
2023-05-20 10:00:43 +00:00
Lukas Wirth
14dc1ac3bf internal: Shrink ProcMacroExpander from 8 to 4 bytes 2023-05-20 11:31:28 +02:00
hkalbasi
92d6670f72 Consider block impls in lookup_impl_assoc_item_for_trait_ref 2023-05-20 01:11:17 +03:30
bors
bb78059be4 Auto merge of #14847 - HKalbasi:layout, r=HKalbasi
Reduce MIR memory usage
2023-05-19 12:06:11 +00:00
hkalbasi
60379dabfb resolve types in closure capture copy detection 2023-05-19 14:54:57 +03:30
hkalbasi
c5ea2d7adc handle match scrutinee in closure captures 2023-05-19 12:04:12 +03:30
bors
e8ae2d3976 Auto merge of #14848 - bm-w:fix/highlight-let-else-return, r=Veykril
Fix `preorder_expr` skipping the `else` block of let-else statements

Fixes exit/yield points not getting highlighted in such blocks for `highlight_related` (#14813; and possibly other bugs in features that use `preorder_expr`).
2023-05-19 07:41:46 +00:00
Lukas Wirth
c0519daf3b
Update crates/ide-db/src/syntax_helpers/node_ext.rs
Co-authored-by: Bastiaan Marinus van de Weerd <id@bm-w.eu>
2023-05-19 09:33:57 +02:00
Bastiaan Marinus van de Weerd
5857836047
Fix preorder_expr skipping the else block of let-else statements
Fixes exit/yield points not getting highlighted in such blocks for `highlight_related` (#14813; and possibly other bugs in features that use `preorder_expr`).
2023-05-18 18:30:27 -04:00
hkalbasi
23ce228d54 Reduce MIR memory usage 2023-05-19 00:16:52 +03:30
hkalbasi
cae9660a1d Add layout info for enum variant and locals 2023-05-18 21:03:03 +03:30
hkalbasi
b55fbd3ad7 Add moved-out-of-ref diagnostic 2023-05-18 19:17:06 +03:30
hkalbasi
4adfbbfbad partially support panic message in MirEvalError 2023-05-18 18:30:49 +03:30
bors
9ce95674e8 Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril
Support c string literals
2023-05-18 11:55:38 +00:00
Lukas Wirth
3e528b85f9 Fix cstring literals construct &CStr not &str 2023-05-18 12:03:15 +02:00
bors
034d7c8537 Auto merge of #14787 - HKalbasi:mir2, r=HKalbasi
MIR episode 5

This PR inits drop support (it is very broken at this stage, some things are dropped multiple time, drop scopes are wrong, ...) and adds stdout support (`println!` doesn't work since its expansion is dummy, but `stdout().write(b"hello world\n")` works if you use `RA_SYSROOT_HACK`) for interpreting. There is no useful unit test that it can interpret yet, but it is a good sign that it didn't hit a major road block yet.

In MIR lowering, it adds support for slice pattern and anonymous const blocks, and some fixes so that we can evaluate `SmolStr::new_inline` in const eval. With these changes, 57 failed mir body remains.
2023-05-18 09:44:26 +00:00
Lukas Wirth
eab295cc73 Fix mir CString lowering not respecting the extra 0 byte for length calc 2023-05-18 11:29:19 +02:00
bors
f9be79603a Auto merge of #14820 - HKalbasi:format-args, r=HKalbasi
Expand `format_args!` with more details
2023-05-18 09:09:06 +00:00
Lukas Wirth
4b577e2bc8 Support c string literals 2023-05-18 11:06:05 +02:00
hkalbasi
5c83e222a3 fix format_args expansion error with raw strings 2023-05-18 12:32:41 +03:30
bors
e4977e74de Auto merge of #14836 - Veykril:rustc-lexer, r=Veykril
internal: Bump rustc_lexer
2023-05-18 08:50:49 +00:00
Lukas Wirth
099b5b3b15 internal: Bump rustc_lexer 2023-05-18 10:17:40 +02:00
hkalbasi
261047d019 Fix layout for hir_ty::Ty and friends 2023-05-18 11:29:03 +03:30
bors
0a806fe7ad Auto merge of #14835 - Veykril:inlay-pad, r=Veykril
fix: Fix bind pat hint padding
2023-05-18 07:14:59 +00:00
Lukas Wirth
03fb1310c2 fix: Fix bind pat hint padding 2023-05-18 08:48:53 +02:00
bors
c7b03491cd Auto merge of #14834 - Veykril:ty-diag-unit, r=Veykril
internal: Less file parsing for symbol index generation
2023-05-18 06:25:40 +00:00
Lukas Wirth
d6dcfa5744 internal: Less file parsing for symbol index generation 2023-05-18 08:25:06 +02:00
bors
c06f088968 Auto merge of #14823 - Veykril:discriminant-inlays, r=Veykril
fix: Discriminant hints only render for datacarrying enums with primitive repr
2023-05-18 05:50:41 +00:00
bors
07baa176c2 Auto merge of #14828 - lowr:fix/macro_use_prelude_is_in_scope, r=Veykril
fix: process `macro_use` prelude in semantic scope resolver

Fixes #14826
2023-05-18 05:36:24 +00:00
bors
b7b026bce6 Auto merge of #14825 - HKalbasi:float-const-eval, r=Veykril
Fix evaluating negative for floating point types

fix #14704
Unary operators was missed from #14705
2023-05-18 05:22:41 +00:00
bors
a20a08f3e2 Auto merge of #14824 - Veykril:ty-diag-unit, r=Veykril
fix: Diagnose non-value return and break type mismatches

Could definitely deserve more polished diagnostics, but this at least brings the message across for now.
2023-05-18 05:03:42 +00:00
bors
c4026bf9b9 Auto merge of #14818 - poliorcetics:type-hints-after-item, r=Veykril
fix: place type inlay hints after the item and without left-padding

**Before**:

![Type hints were placed before the item and there was left-padding that accentuaded the issue](https://github.com/rust-lang/rust-analyzer/assets/7951708/006a28e9-ed7b-4d49-a7e7-3c6da8efca79)

**After**:

![Type hints are now placed after the item and without padding since there already is `: ` in front of the type](https://github.com/rust-lang/rust-analyzer/assets/7951708/330a847f-8c59-40c7-877f-bf1aaced30e2)
2023-05-18 04:50:09 +00:00
bors
72a1796615 Auto merge of #14819 - weihanglo:divided-by-zero, r=lnicola
fix(analysis-stats): divided by zero error

## What does this PR try to resolve?

2023-05-15 rust-analyzer suffers from

```
 thread 'main' panicked at 'attempt to divide by zero', crates/rust-analyzer/src/cli/analysis_stats.rs:230:56
```

This commit <51e8b8ff14> might be the culprit.

This PR uses `percentage` function to avoid the classic “division by zero” bug.

## Reproducer

```console
cargo new ra-test
pushd ra-test
echo "pub type Foo = u32;" >> src/lib.rs
rust-analyzer analysis-stats .
```
2023-05-18 02:09:55 +00:00
bors
d0768aad62 Auto merge of #14812 - Veykril:highlight-trait-assoc, r=HKalbasi
feat: Highlight used trait assoc items when cursor is on trait import or trait bound
2023-05-18 01:53:30 +00:00
Ryo Yoshida
68a74decb6
Process macro_use prelude in semantic scope resolver 2023-05-17 17:45:44 +09:00
hkalbasi
fd034bea1a Fix evaluating negative for floating point types 2023-05-17 01:27:45 +03:30
hkalbasi
a2fba7c67e Add test for eager expanding of format_args 2023-05-17 01:15:04 +03:30
Lukas Wirth
478705baf5 fix: Diagnose non-value return and break type mismatches 2023-05-16 22:47:27 +02:00
Lukas Wirth
c12ede8c34 fix: Discriminant hints only render for datacarrying enums with primitive repr 2023-05-16 22:15:39 +02:00
hkalbasi
a6e5a912f9 Expand format_args! with more details 2023-05-16 19:12:40 +03:30
Alexis (Poliorcetics) Bourget
22599adf9b fix: place type inlay hints after the item and without left-padding 2023-05-16 15:13:48 +02:00
Weihang Lo
77be56b691
fix(analysis-stats): divided by zero error 2023-05-16 13:57:36 +01:00
Lukas Wirth
b87ee914fa feat: Highlight used trait assoc items when cursor is on trait import or trait bound 2023-05-15 20:41:35 +02:00
Lukas Wirth
ba8bcde4f5 Also render coercions for ranged type hover on closures 2023-05-15 19:45:01 +02:00
Lukas Wirth
08dc0e21af feat: Render hover actions for closure captures and sig 2023-05-15 19:35:27 +02:00
bors
2f8cd66fb4 Auto merge of #14810 - Veykril:inline-module, r=Veykril
internal: Inline handlers module
2023-05-15 10:19:21 +00:00
bors
9eb26a9375 Auto merge of #14809 - lowr:patch/macro_use-filter, r=Veykril
Support `#[macro_use(name, ...)]`

This PR adds support for another form of the `macro_use` attribute: `#[macro_use(name, ...)]` ([reference]).

Note that this form of the attribute is only applicable to extern crate decls, not to mod decls.

[reference]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2023-05-15 10:04:05 +00:00
Lukas Wirth
9e80c8571d internal: Inline handlers module 2023-05-15 11:59:09 +02:00
bors
1e6bd6cb0d Auto merge of #14794 - Veykril:inlay-kind-refac, r=Veykril
Restructure InlayHint, no longer derive properties from its kind

Closes https://github.com/rust-lang/rust-analyzer/issues/14595
2023-05-15 09:49:17 +00:00
bors
b198815e7f Auto merge of #14775 - hecatia-elegua:doc-alias-methods, r=Veykril
feat: add #[doc(alias(..))]-based method completions

![Screenshot showing a completion when you type a doc alias instead of a real name](https://github.com/rust-lang/rust-analyzer/assets/108802164/e7c69bb9-3da6-4d8f-a09b-fece1bdd1c0e)
2023-05-15 09:32:10 +00:00
bors
bc03418127 Auto merge of #14746 - lowr:patch/associated-return-types, r=Veykril
Parse associated return type bounds

This PR implements parser support for associated return type bounds: `T: Foo<bar(): Send>`. This PR does not implement associated return types (`T::bar(): Send`) because it's not implemented even in rustc, and also removes `(..)`-style return type notation because it has been removed in rust-lang/rust#110203 (effectively reverting #14465).

I don't plan to proactively follow this unstable feature unless an RFC is accepted and my main motivation here is to remove no-longer-valid syntax `(..)` from our parser, nevertheless adding minimal parser support so anyone interested (as can be seen in #14465) can experiment it without rust-analyzer's syntax errors.
2023-05-15 09:16:51 +00:00
hkalbasi
206a0b5bc6 Add timer for new items 2023-05-14 22:34:58 +03:30
hkalbasi
431dd32f8a Unsized temporary is not an implementation error 2023-05-14 21:05:33 +03:30
Ryo Yoshida
1bc7f8a4c6
Support #[macro_use(name, ...)] 2023-05-15 00:05:44 +09:00
hkalbasi
51e8b8ff14 Add metrics for unevaluated constants, failed mir bodies, and failed data layouts 2023-05-14 17:12:28 +03:30
bors
cbd14e9840 Auto merge of #14801 - Veykril:process-changes-fix, r=Veykril
fix: Fix process-changes duplicating change events

Should fix https://github.com/rust-lang/rust-analyzer/issues/14791
2023-05-13 19:21:30 +00:00
Lukas Wirth
cace5bb35d fix: Fix process-changes duplicating change events 2023-05-13 21:21:03 +02:00
bors
daa03b0b0b Auto merge of #14800 - lowr:patch/macro-subns-and-prelude, r=Veykril
Expand more single ident macro calls upon item collection

Addresses https://github.com/rust-lang/rust-analyzer/pull/14781#issuecomment-1546201022

I believe this (almost) brings the number of unresolved names back to pre-#14781:

|r-a version|`analysis-stats compiler/rustc` (rust-lang/rust@69fef92ab2) |
|---|---|
|pre-#14781 (b069eb720b) | exprs: 2747778, ??ty: 122236 (4%), ?ty: 107826 (3%), !ty: 728 |
| #14781 (a7944a93a1) | exprs: 2713080, ??ty: 139651 (5%), ?ty: 114444 (4%), !ty: 730 |
| with this fix | exprs: 2747871, ??ty: 122237 (4%), ?ty: 108171 (3%), !ty: 676 |

(I haven't investigated on the increase in some numbers but hopefully not too much of a problem)

This is only a temporary solution. The core problem is that we haven't fully implemented the textual scope of legacy macros. For example, we *have been* failing to resolve `foo` in the following snippet, even before #14781 or after this patch. As noted in a FIXME, we need a way to resolve names in textual scope without eager expansion during item collection.

```rust
//- /main.rs crate:main deps:lib
lib::mk_foo!();
const A: i32 = foo!();
             //^^^^^^ unresolved-macro-call

//- /lib.rs crate:lib
#[macro_export]
macro_rules! mk_foo {
    () => {
        macro_rules! foo { () => { 42 } }
    }
}
```
2023-05-13 18:47:42 +00:00
Ryo Yoshida
e9ddb62c65
Expand more single ident macro calls upon their collection 2023-05-14 03:11:10 +09:00
mataha
9fff960636
Remove root from patched UNC windows path drives 2023-05-13 18:38:12 +02:00
bors
db8f39ce19 Auto merge of #14797 - Veykril:symbol-query, r=Veykril
fix: Fix perf regression from symbol index refactor

Should fix the regressions introduced by https://github.com/rust-lang/rust-analyzer/pull/14715 by partially rolling back the PR
2023-05-13 15:41:54 +00:00
Lukas Wirth
2e03b198ca fix: Fix perf regression from symbol index refactor 2023-05-13 17:41:09 +02:00
bors
a7944a93a1 Auto merge of #14735 - Veykril:forbid-relative-json, r=Veykril
internal: Forbid canonicalization of paths and normalize all rust-project.json paths

Closes https://github.com/rust-lang/rust-analyzer/issues/14728
cc https://github.com/rust-lang/rust-analyzer/pull/14430

- Removes canonicalization (and forbids it from being used in a sense, clippy could help here again with its lint in the future)
- Normalizes all paths in rust-project.json which we weren't doing in some cases
2023-05-13 10:01:03 +00:00
Lukas Wirth
f47caa666e Add AbsPath::absolutize 2023-05-13 11:51:28 +02:00
Lukas Wirth
8e116855f5 Add macro modifier for highlighting tokens in macro calls 2023-05-13 11:43:39 +02:00
Lukas Wirth
edd60f7b0d Simplify bind pat filtering 2023-05-13 11:02:57 +02:00
Lukas Wirth
730286b523 Restructure InlayHint, no longer derive properties from its kind 2023-05-13 10:42:26 +02:00
hkalbasi
cbcafd3539 MIR episode 5 2023-05-12 18:17:15 +03:30
hkalbasi
7da80d4f67 Use double reference in debug derive 2023-05-12 12:36:57 +03:30
bors
9b3387454d Auto merge of #14781 - lowr:patch/macro-subns-and-prelude, r=Veykril
Introduce macro sub-namespaces and `macro_use` prelude

This PR implements two mechanisms needed for correct macro name resolution: macro sub-namespace and `macro_use` prelude.

- [macro sub-namespaces][subns-ref]

  Macros have two sub-namespaces: one for function-like macro and the other for those in attributes (including custom derive macros). When we're resolving a macro name for function-like macro, we should ignore non-function-like macros, and vice versa.

  This helps resolve single-segment macro names because we can (and should, as rustc does) fallback to names in preludes when the name in the current module scope is in different sub-namespace.

- [`macro_use` prelude][prelude-ref]

  `#[macro_use]`'d extern crate declarations (including the standard library) bring their macros into scope, but they should not be prioritized over local macros (those defined in place and those explicitly imported).

  We have been bringing them into legacy (textual) macro scope, which has the highest precedence in name resolution. This PR introduces the `macro_use` prelude in crate-level `DefMap`s, whose precedence is lower than local macros but higher than the standard library prelude.

The first 3 commits are drive-by fixes/refactors.

Fixes #8828 (prelude)
Fixes #12505 (prelude)
Fixes #12734 (prelude)
Fixes #13683 (prelude)
Fixes #13821 (prelude)
Fixes #13974 (prelude)
Fixes #14254 (namespace)

[subns-ref]: https://doc.rust-lang.org/reference/names/namespaces.html#sub-namespaces
[prelude-ref]: https://doc.rust-lang.org/reference/names/preludes.html#macro_use-prelude
2023-05-11 14:26:59 +00:00
Ryo Yoshida
f2a35deb50
Consider macro sub-namespace during name resolution 2023-05-11 21:13:12 +09:00
Ryo Yoshida
3203ea896d
Add macro_use prelude to DefMap 2023-05-11 21:13:11 +09:00
Ryo Yoshida
96113b7b8e
Remove prelude fallback path for Rust <1.52.0
We've already removed non-sysroot proc macro server, which effectively
removed support for Rust <1.64.0, so this removal of fallback path
shouldn't be problem at this point.
2023-05-11 21:13:10 +09:00
Ryo Yoshida
34a9129333
fix: column!() and line!() built-in macros return u32 2023-05-11 21:13:05 +09:00
Ryo Yoshida
a0a7860141
Refactor 2023-05-11 18:17:16 +09:00
Lukas Wirth
91d5a689c7 Add config for disabling non standard lsp highlight tokens 2023-05-11 10:01:38 +02:00
Lukas Wirth
4b42acf617 Add basic support for augmentsSyntaxTokens 2023-05-10 20:48:51 +02:00
ponyii
49f1092f14 add_missing_impl_members and add_missing_default_members break indentation no longer 2023-05-10 22:27:05 +04:00
ponyii
e07d6382de add_missing_impl_members no longer breaks indentation 2023-05-10 16:35:48 +04:00
ponyii
a0db4781dc generate_derive no longer breaks indentation 2023-05-10 16:35:43 +04:00
hecatia-elegua
2a182f3f1f Add doc(alias)-based method completion 2023-05-10 12:51:08 +02:00
hecatia-elegua
d4b668a3bb Prepare tidy.rs 2023-05-10 12:47:05 +02:00
bors
aaed89ac04 Auto merge of #14763 - lnicola:dep-tree-fixes, r=lnicola
Fix manual formatting and remove duplicate command
2023-05-08 18:28:58 +00:00
Laurențiu Nicola
10637cf3e8 Fix formatting 2023-05-08 21:27:43 +03:00
Laurențiu Nicola
b632c7d322 Fix broken table 2023-05-08 21:27:35 +03:00
bors
d3ce333ec8 Auto merge of #14742 - Veykril:closure-capture-inlays, r=Veykril
feat: Closure capture inlay hints

I opted for a fictional `move(foo, &bar, &mut qux)` syntax here, disabled by default as these are not correct rust syntax and hence could cause confusion.
![image](https://user-images.githubusercontent.com/3757771/236447484-649a4ea6-ad61-496e-bad8-765a5236150e.png)
2023-05-08 09:52:29 +00:00
Lukas Wirth
4c5fd19ee5 Render places in capture inlay hints 2023-05-08 09:50:58 +02:00
bors
ff8b969951 Auto merge of #14727 - HKalbasi:mir, r=HKalbasi
Lazy evaluate consts in `path_to_const`

fix #14275
2023-05-08 07:14:57 +00:00
bors
833d5301d1 Auto merge of #14758 - lumenian:hover-layout-config, r=HKalbasi
Add config for disabling hover memory layout data

Requested in https://github.com/rust-lang/rust-analyzer/pull/14748#issuecomment-1537190252
2023-05-07 16:22:57 +00:00
Yury Ivanou
8e1ba7fdab Fix memory layout config not working for closures 2023-05-07 19:10:01 +03:00
Yury Ivanou
98a4c5049f Rename hover memory layout config key 2023-05-07 18:37:56 +03:00
Yury Ivanou
4ed0fa8414 Add config for disabling hover memory layout data 2023-05-07 18:21:07 +03:00
Arpad Borsos
35940bcda3 Remove identity_future from stdlib
This function/lang_item was introduced in #104321 as a temporary workaround of future lowering.
The usage and need for it went away in #104833.
After a bootstrap update, the function itself can be removed from `std`.
2023-05-07 10:52:01 +02:00
Alexis (Poliorcetics) Bourget
5411836767 fix: simplify boolean test to a single negation 2023-05-07 09:44:07 +02:00
Alexis (Poliorcetics) Bourget
d7fdf141a4 fix: various clippy lints 2023-05-07 09:43:37 +02:00
Alexis (Poliorcetics) Bourget
900d6030e7 fix: remove useless returns 2023-05-07 09:42:52 +02:00
bors
260e996140 Auto merge of #14733 - azdavis:master, r=matklad
Make line-index a lib, use nohash_hasher

These seem like they are not specific to rust-analyzer and could be pulled out to their own libraries. So I did.

https://github.com/azdavis/millet/issues/31
2023-05-06 23:37:02 +00:00
bors
a10fd83120 Auto merge of #14748 - lumenian:type-alias-layout, r=HKalbasi
Show type alias layout

This PR expands on #13490 to allow displaying layout data on hover for type aliases.
2023-05-06 19:18:30 +00:00
Ryo Yoshida
9360adccda
Ignore impls with #[rustc_reservation_impl] 2023-05-07 01:31:36 +09:00
Alexis (Poliorcetics) Bourget
3d70ba7f94 chore: remove unused method 2023-05-06 16:02:34 +02:00
Yury Ivanou
ecc081d625 Show type alias layout on hover 2023-05-06 16:58:57 +03:00
Ryo Yoshida
fa2340a4df
Parse associated return type bounds 2023-05-06 20:31:11 +09:00
Ryo Yoshida
d7d8971203
Remove (..)-style return type notation 2023-05-06 20:30:17 +09:00
Ariel Davis
02e8bb0c6e Return Option 2023-05-06 00:57:57 -07:00
Ariel Davis
fcbe73ec1c Refactor position 2023-05-06 00:52:32 -07:00
Ariel Davis
1ad0779a00 Make WideEncoding non-exhaustive 2023-05-06 00:49:23 -07:00
Ariel Davis
4a1922fd1a Depend on nohash-hasher individually 2023-05-06 00:49:23 -07:00
Ariel Davis
b26cded8d1 Swap 2023-05-06 00:49:23 -07:00
Ariel Davis
4b28ad92e9 Make text-size a workspace dep 2023-05-06 00:49:23 -07:00
Ariel Davis
85dd7b22b4 Use nohash_hasher, rm comment 2023-05-06 00:49:23 -07:00
Ariel Davis
7e1992a0d9 Make line-index an external lib 2023-05-06 00:49:23 -07:00
Ariel Davis
29256f22e4 Make non-hash an external lib 2023-05-06 00:49:23 -07:00
Lukas Wirth
abcdb4bc7d Fix test fixtures 2023-05-05 14:18:27 +02:00
Lukas Wirth
8081a654da feat: Closure capture inlay hints 2023-05-05 13:38:22 +02:00
hkalbasi
aafe9b1e06 Lazy evaluate consts in path_to_const 2023-05-05 01:17:11 +03:30
Ryo Yoshida
2a509d0eb2
Parse bare dyn types with leading lifetime 2023-05-05 04:30:37 +09:00
bors
0dd94d3b07 Auto merge of #14738 - Veykril:def-map-fix, r=Veykril
fix: Fix body lowering not using block def maps

Fixes the issue in the comment here https://github.com/rust-lang/rust-analyzer/issues/10084#issuecomment-1534320254, not the general issue unfortunately.
2023-05-04 18:47:04 +00:00
Lukas Wirth
9419fcb109 fix: Fix body lowering not using block def maps 2023-05-04 20:46:05 +02:00
bors
0d5773e04e Auto merge of #14725 - HKalbasi:derive-impls, r=HKalbasi
Emit function bodies in expanding builtin derives

fix #14235
2023-05-04 15:01:44 +00:00
Lukas Wirth
939ebb4454 Forbid canonicalization of paths and normalize all rust-project.json paths 2023-05-04 14:51:35 +02:00
hkalbasi
36c9d5ce17 Fix pattern type mismatch in tuples 2023-05-04 16:03:36 +03:30
hkalbasi
d9f4cbbe8f Emit function bodies in expanding builtin derives 2023-05-03 14:14:47 +03:30
Laurențiu Nicola
7197a27028 Use triomphe Arc 2023-05-02 20:02:43 +03:00
bors
a7168a8c6f Auto merge of #14712 - Veykril:metadata-extra-args, r=Veykril
fix: Only pass unstable flags to cargo metadata from extra args config
2023-05-02 16:34:39 +00:00
bors
c9b4116a5e Auto merge of #14662 - Ddystopia:open_locally_built_documentatin_instead_of_docs_dot_rs, r=Ddystopia
Provide links to locally built documentation for `experimental/externalDocs`

This pull request addresses issue #12867, which requested the ability to provide links to locally built documentation when using the "Open docs for symbol" feature. Previously, rust-analyzer always used docs.rs for this purpose. With these changes, the feature will provide both web (docs.rs) and local documentation links without verifying their existence.

Changes in this PR:

   - Added support for local documentation links alongside web documentation links.
   - Added `target_dir` path argument for external_docs and other related methods.
   - Added `sysroot` argument for external_docs.
   - Added `target_directory` path to `CargoWorkspace`.

API Changes:

   - Added an experimental client capability `{ "localDocs": boolean }`. If this capability is set, the `Open External Documentation` request returned from the server will include both web and local documentation links in the `ExternalDocsResponse` object.

Here's the `ExternalDocsResponse` interface:

```typescript
interface ExternalDocsResponse {
    web?: string;
    local?: string;
}
```

By providing links to both web-based and locally built documentation, this update improves the developer experience for those using different versions of crates, git dependencies, or local crates not available on docs.rs. Rust-analyzer will now provide both web (docs.rs) and local documentation links, leaving it to the client to open the desired link. Please note that this update does not perform any checks to ensure the validity of the provided links.
2023-05-02 15:57:19 +00:00
Lukas Wirth
16b3febcf5 Only pass unstable flags to cargo metadata from extra args config 2023-05-02 17:33:58 +02:00
Ddystopia
2025f17ac3
Workspace without sysroot could be possible 2023-05-02 17:24:00 +02:00
Ddystopia
7e19d99d4f
Add a localDocs capability 2023-05-02 17:13:21 +02:00
Ddystopia
4ac39f0c98
Propagating sysroot down + Refactoring 2023-05-02 17:08:56 +02:00
Ddystopia
67e58c5ba6
Add sysroot 2023-05-02 17:08:56 +02:00
Ddystopia
396934860c
Getting cargo workspace from file_id and refactoring 2023-05-02 17:08:56 +02:00
Oleksandr Babak
0913809ac8
Update crates/ide/src/doc_links.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2023-05-02 17:08:55 +02:00
Ddystopia
8317c8db1a
Test for Builtin Type 2023-05-02 17:08:55 +02:00
Ddystopia
b64c31c40a
Solve platform-specific issues 2023-05-02 17:06:39 +02:00
Ddystopia
12292e445a
Tests for externalDocs 2023-05-02 17:06:39 +02:00
Ddystopia
2503fbefde
Small improvements and fixes 2023-05-02 17:06:39 +02:00
Ddystopia
3fbb48907e
Add doc strings 2023-05-02 17:06:39 +02:00
Ddystopia
c47a34fddc
Add target_dir path argument for external_docs and other methods 2023-05-02 17:06:38 +02:00
Ddystopia
f2d933ecaf
Add support for local documentation links alongside web documentation links, pending for target_dir path and tests 2023-05-02 17:06:38 +02:00
Ddystopia
fc888b583d
Add target_directory path to CargoWorkspace 2023-05-02 17:06:31 +02:00
bors
4ecd7e6c0d Auto merge of #14720 - Veykril:boxed-slices, r=Veykril
internal: Use boxed slices instead ovecs in decl macros

saves another 10 mb on self (since we didn't shrink the vecs)
2023-05-02 15:05:28 +00:00
Lukas Wirth
90499d4390 Use boxed slices instead ovecs in decl macros 2023-05-02 17:04:53 +02:00
Bruno Ortiz
ecfe7c0488 last fixes after rebase 2023-05-02 11:24:08 -03:00
Bruno Ortiz
bcb21311ea Accepting review suggestions 2023-05-02 11:06:25 -03:00
Bruno Ortiz
800b3b6323 adding doc and simplifying function 2023-05-02 11:03:32 -03:00
Bruno Ortiz
072f69e4c1 fixing ts linting and rust test 2023-05-02 11:01:53 -03:00
Bruno Ortiz
66fe84d936 accepting review suggestions 2023-05-02 11:01:41 -03:00
Bruno Ortiz
c372fb3495 fixing tests for windows 2023-05-02 10:59:31 -03:00
Bruno Ortiz
a3081a6774 Adding crate_root_path to crate_graph 2023-05-02 10:59:31 -03:00
Bruno Ortiz
8e687f7afb improving code to work with multi-workspaces 2023-05-02 10:59:31 -03:00
Bruno Ortiz
1b8288ff96 Fixing naming from graph to list 2023-05-02 10:59:29 -03:00
Bruno Ortiz
e2535926e9 Fixing tests 2023-05-02 10:56:50 -03:00
Bruno Ortiz
440889edec fixing main_loop.rs 2023-05-02 10:56:13 -03:00
Lukas Wirth
299382dacd WIP: Add lsp-ext scaffold 2023-05-02 10:56:13 -03:00
Bruno Ortiz
09e0a00d36 fetching dependencies from the server 2023-05-02 10:56:09 -03:00