Commit Graph

1838 Commits

Author SHA1 Message Date
bors
99daf23e11 Auto merge of #13671 - Veykril:goto-decl, r=Veykril
Improve goto declaration

Closes https://github.com/rust-lang/rust-analyzer/issues/13599

- goto decl now goes to assoc items of trait declarations over the items of trait implementations
- goto decl now goes to the field declaration (opposed to goto def which shows both the field decl and binding created/local being used)
- also adds back the goto definition fallback that seems to have been dropped at some point.
2022-11-25 09:28:39 +00:00
Lukas Wirth
ae0bdffcc9 Go to declaration goes to field declaration in pattern and expression shorthands 2022-11-25 10:27:54 +01:00
Lukas Wirth
3c794a34da Go to declaration goes to assoc items of trait declarations 2022-11-25 10:27:49 +01:00
Kartavya Vashishtha
a26aef9055
fix formatting 2022-11-25 12:22:06 +05:30
Kartavya Vashishtha
91e7624de0
add hover tests 2022-11-25 12:20:38 +05:30
Kartavya Vashishtha
e86d451484
fix token method call 2022-11-25 12:20:34 +05:30
Kartavya Vashishtha
132d5ffc7d
add back [] in hover documentation 2022-11-25 12:04:14 +05:30
Kartavya Vashishtha
f64feeb11a
Correct node traversal to look at parent instead
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-11-24 22:32:15 -08:00
Kartavya Vashishtha
29951f9766
fix formatting 2022-11-19 21:23:33 +05:30
Kartavya Vashishtha
87658c8173
refactor hover
change struct_rest_pat to guarentee a HoverResult

Move token and node matching out of struct_rest_pat into hover
2022-11-19 21:22:10 +05:30
Kartavya Vashishtha
8b17681058
fix formatting
and remove unnecessary check
2022-11-19 11:34:49 +05:30
Kartavya Vashishtha
a778203db9
simplify ancestor climbing to not consider macros 2022-11-19 11:17:43 +05:30
Kartavya Vashishtha
0ffb361eb9
feat: adds hover hint to ".." in record pattern
currently only works with struct pattern
2022-11-19 11:10:47 +05:30
bors
add85397ae Auto merge of #13604 - Veykril:hover-attr, r=Veykril
fix: Fix hover in attributed items not preferring similar kinded tokens
2022-11-11 12:48:48 +00:00
Lukas Wirth
e50712cf2c fix: Fix hover in attributed items not preferring similar kinded tokens 2022-11-11 13:38:07 +01:00
Ryo Yoshida
19306c070d
Fix tests that depended on loose visibility restriction 2022-11-11 20:31:46 +09:00
Jonas Schievink
9be0615bde Don't canonicalize self type when querying FnOnce signature 2022-11-08 18:05:07 +01:00
bors
0aa0da9dda Auto merge of #13572 - Veykril:cancellable, r=Veykril
internal: Use Cancellable in favor of Result for clarity
2022-11-07 16:22:33 +00:00
Lukas Wirth
fa70b0a86e internal: Use Cancellable in favor of Result for clarity 2022-11-07 17:21:37 +01:00
bors
a27e4dad37 Auto merge of #13571 - Veykril:unique-references, r=Veykril
minor: Deduplicate reference search results

Fixes https://github.com/rust-lang/rust-analyzer/issues/13407
2022-11-07 15:49:54 +00:00
Lukas Wirth
6a06f6f724 Deduplicate reference search results 2022-11-07 16:48:50 +01:00
bors
8a633fe986 Auto merge of #13570 - Veykril:dedup-crates-for, r=Veykril
minor: Remove code duplication
2022-11-07 14:52:05 +00:00
Lukas Wirth
b169e1e5de Remove code duplication 2022-11-07 15:49:26 +01:00
bors
b0e56ef5e8 Auto merge of #13545 - Veykril:adjustment-hints, r=Veykril
Generalize reborrow hints as adjustment hints

Like reborrow hints, these are still mainly useful for teaching/learning

![image](https://user-images.githubusercontent.com/3757771/200073606-b5cd3b95-a9ad-454d-a3c4-d4d89bf45928.png)
2022-11-07 14:38:59 +00:00
Lukas Wirth
ffd7bf8bf9 Bump Cargo rust-version fields to latest stable 2022-11-07 12:59:51 +01:00
Lukas Wirth
ee2dd934ca Don't trigger adjustment hints in all inlay hint tests 2022-11-07 12:49:52 +01:00
Lukas Wirth
17619de711 fix: Fix reference searching only accounting substrings instead of whole identifiers 2022-11-05 13:00:02 +01:00
Lukas Wirth
d841ad116a Fix up adjustment hints configurations 2022-11-04 22:59:07 +01:00
Lukas Wirth
95d20fccd7 Add adjustment hint tests 2022-11-04 22:40:06 +01:00
Lukas Wirth
c98fc537e6 Generalize reborrow hints as adjustment hints 2022-11-04 21:53:23 +01:00
bors
bbcb77ea6f Auto merge of #13456 - emilio:scip-local-symbol, r=Veykril
scip: Generate symbols for local crates.

Consider something like:

```
// a.rs
pub struct Foo { .. } // Foo is "local 1"

fn something() {
    crate:🅱️:Bar::new() // Bar is "local 1", but of "b.rs"
}

// b.rs
pub struct Bar { .. } // "local 1"
```

Without this there's no way to disambiguate whether "local 1" references "Bar" or "Foo".
2022-11-03 13:58:36 +00:00
Jonas Schievink
ecad1a9a6e Create Callables for generic types implementing FnOnce 2022-11-01 16:38:19 +01:00
Ryo Yoshida
67f1d8fe2c
Test all generic args for trait when finding matching impl 2022-10-25 23:28:40 +09:00
Emilio Cobos Álvarez
8039a07a5e
ide: Generate monikers for local crates. 2022-10-22 19:33:47 +02:00
Emilio Cobos Álvarez
bd49d01906
ide: Remove unnecessary continue. 2022-10-22 15:15:10 +02:00
Lukas Wirth
de195ff97c fix: Fix DidSaveDocument requests blocking the server on startup 2022-10-20 19:55:04 +02:00
Lukas Wirth
8047512dca
Revert "feat: Diagnose some incorrect usages of the question mark operator" 2022-10-18 14:18:59 +02:00
Lukas Wirth
a762baca02 fix: Fix formatting requests hanging when r-a is still starting
The reason for that was that we were calculating the crate defmaps
of the file we are saving by accident causing us to get stuck waiting
on their expensive computation, while we only need the relevant crate
id.
2022-10-17 18:21:18 +02:00
Lukas Wirth
381366f1dd Diagnose incorrect usages of the question mark operator 2022-10-16 12:58:24 +02:00
bors
855cd5c280 Auto merge of #13418 - lnicola:bump-deps, r=lnicola
Bump deps
2022-10-15 11:27:12 +00:00
Laurențiu Nicola
792920f441 Bump pulldown-cmark-to-cmark 2022-10-15 13:00:41 +03:00
Laurențiu Nicola
97eebbfab6 Bump url 2022-10-15 12:57:30 +03:00
Laurențiu Nicola
cbce0cda08 Bump anyhow, arbitrary, itertools, semver, serde 2022-10-15 12:52:34 +03:00
DropDemBits
a69cccfc0e Underline only the intra-doc link instead of the whole doc comment 2022-10-09 21:29:31 -04:00
Maybe Waffle
1c0ec9f0c8 Fix go-to-def for #[doc = include_str!("path")] 2022-10-07 09:04:41 +00:00
bors
a415fb4c4e Auto merge of #13353 - wildbook:fix_type_inference_panic, r=Veykril
Fix assertion failure in type inference (#13352)

Fixes https://github.com/rust-lang/rust-analyzer/issues/13352
2022-10-06 12:33:50 +00:00
Maybe Waffle
a57ef6b0b1 Fix go-to-def for shadowed include*! 2022-10-06 06:16:39 +00:00
Wildbook
8862fe6ff2 Fix assertion failure in type inference (#13352) 2022-10-05 17:46:56 +02:00
bors
2293949bbf Auto merge of #13318 - Veykril:annotations, r=Veykril
Fix annotations not resolving when lens location is set to whole item

Fixes https://github.com/rust-lang/rust-analyzer/issues/13310
2022-09-30 22:31:05 +00:00
Lukas Wirth
3cd57c425a Fix annotations not resolving when lens location is set to whole item 2022-10-01 00:18:23 +02:00
Ryo Yoshida
6d8903ae5f
fix: infer for-loop item type with IntoIterator and Iterator 2022-09-29 19:48:08 +09:00
Noah Santschi-Cooney
aa093f5a58
Fix PackageInformation having the crate name instead of package name 2022-09-26 17:31:38 +01:00
bors
817a6a8609 Auto merge of #12966 - OleStrohm:master, r=Veykril
feat: Display the value of enum variant on hover

fixes #12955

This PR adds const eval support for enums, as well as showing their value on hover, just as consts currently have.

I developed these two things at the same time, but I've realized now that they are separate. However since the hover is just a 10 line change (not including tests), I figured I may as well put them in the same PR. Though if you want them split up into "enum const eval support"  and "show enum variant value on hover", I think that's reasonable too.

Since this adds const eval support for enums this also allows consts that reference enums to have their values computed now too.

The const evaluation itself is quite rudimentary, it doesn't keep track of the actual type of the enum, but it turns out that Rust doesn't actually either, and `E::A as u8` is valid regardless of the `repr` on `E`.

It also doesn't really care about what expression the enum variant contains, it could for example be a string, despite that not being allowed, but I guess it's up to the `cargo check` diagnostics to inform of such issues anyway?
2022-09-20 14:01:16 +00:00
bors
09600a3a5b Auto merge of #13268 - Veykril:simplify, r=Veykril
Simplify
2022-09-20 12:35:18 +00:00
Lukas Wirth
027bfd68ba Fix operator highlighting tags applying too broadly 2022-09-20 14:33:44 +02:00
DidiBear
cdc362e6cc
docs(inlay-hints): remove reference to Toggle inlay hints 2022-09-19 12:00:58 -04:00
bors
dbb8fedf8b Auto merge of #13221 - mdx97:mdx97/annotations-above-whole-item, r=Veykril
Allow configuration of annotation location.

I've added the ability to configure where lens annotations render relevant to the item they describe. Previously, these would render directly above the line the item is declared on. Now, there is the ability to render these annotations above the entire item (including doc comments, and attributes).

The names of the config options are up for debate, I did what seemed best to me but if anyone has better ideas let me know.

This is my first contribution so if I've missed anything please let me know.

Here's a preview of what the new option looks like:

<img width="577" alt="Screen Shot 2022-09-11 at 10 39 51 PM" src="https://user-images.githubusercontent.com/33100798/189570298-b4fcbf9c-ee49-4b79-aae6-1037ae4f26af.png">

closes https://github.com/rust-lang/rust-analyzer/issues/13218
2022-09-13 15:09:53 +00:00
Lukas Wirth
cadb01c315 Move reference imports filtering into to_proto layer 2022-09-13 14:58:50 +02:00
Mathew Horner
f57c15f3e9 Address comments and fix build. 2022-09-12 16:34:13 -05:00
OleStrohm
3931e55aee Fixed lints 2022-09-12 21:27:19 +01:00
OleStrohm
177ec82a41 Rebased 2022-09-12 21:02:30 +01:00
OleStrohm
5313bd1984 Cleaned up code based on feedback 2022-09-12 20:20:45 +01:00
OleStrohm
301b8894ea Added more consteval tests and fixed consteval result 2022-09-12 20:20:45 +01:00
OleStrohm
ad0a6bf1a3 Added consteval tests 2022-09-12 20:20:43 +01:00
OleStrohm
2f84b6e2e5 Almost there 2022-09-12 20:20:22 +01:00
OleStrohm
b63234e20b Cleaned up code 2022-09-12 20:19:49 +01:00
OleStrohm
997fc46efa Implemented basic enum const eval 2022-09-12 20:19:13 +01:00
bors
b1a4ba3e84 Auto merge of #13223 - lowr:fix/hir-proj-normalization, r=flodiebold
fix: handle lifetime variables in projection normalization

Fixes #12674

The problem is that we've been skipping the binders of normalized projections assuming they should be empty, but the assumption is unfortunately wrong. We may get back lifetime variables and should handle them before returning them as normalized projections. For those who are curious why we get those even though we treat all lifetimes as 'static, [this comment in chalk](d875af0ff1/chalk-solve/src/infer/unify.rs (L888-L908)) may be interesting.

I thought using `InferenceTable` would be cleaner than the other ways as it already has the methods for canonicalization, normalizing projection, and resolving variables, so moved goal building and trait solving logic to a new `HirDatabase` query. I made it transparent query as the query itself doesn't do much work but the eventual call to `HirDatabase::trait_solve_query()` does.
2022-09-12 14:24:57 +00:00
Ryo Yoshida
efb56160c9
fix: handle lifetime variables in projection normalization 2022-09-12 22:52:58 +09:00
bors
e38dfe5536 Auto merge of #13186 - enomado:master, r=Veykril
Filter imports on find-all-references

Attempt to #13184
2022-09-12 12:09:57 +00:00
Mathew Horner
8a2803d9ae Allow configuration of annotation location.
Previously, annotations would only appear above the name of an item (function signature, struct declaration, etc).

Now, rust-analyzer can be configured to show annotations either above the name or above the whole item (including doc comments and attributes).
2022-09-11 22:40:33 -05:00
Stanislav
f7f4792f4f fixes 2022-09-09 20:58:06 +03:00
bors
4e1a3da8f2 Auto merge of #13158 - jonas-schievink:inlayhint-links, r=jonas-schievink
feat: make clicking a closing brace inlay hint go to the opening brace
2022-09-08 16:38:40 +00:00
Jonas Schievink
064c9ef9e2 Make clicking closing brace hint go to the opening brace 2022-09-08 17:25:28 +02:00
Stanislav
9f6553e1d6 add config for import filtering 2022-09-08 01:53:20 +03:00
Stanislav
eba54c2fc9 pretty solition works 2022-09-07 04:09:25 +03:00
Stanislav
92d54f9b30 typo and draft 2022-09-07 03:24:55 +03:00
Stanislav
bd0eeb3f04
Update crates/ide/src/references.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-09-07 03:01:06 +03:00
bors
5be2e6574d Auto merge of #13185 - ChayimFriedman2:insert-ws-in-static-const-macro, r=Veykril
fix: Insert whitespaces into static & const bodies if they are expanded from macro on hover

Partially fixes #13143.

To resolve the other part we need to expand macros in unevaluated static & const bodies, and I'm not sure we want to. If for example it includes a call to `assert!()`, expanding it will lead to worse hover.
2022-09-05 11:10:40 +00:00
Stanislav
6001e7dfb1 fix 2022-09-04 19:45:50 +03:00
Stanislav
ba40aa72ac
Update crates/ide/src/references.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2022-09-04 19:41:06 +03:00
Stanislav
29729abc3c Retain imports on find-all-references 2022-09-04 19:14:52 +03:00
Chayim Refael Friedman
26b5f1f92f Do not insert a newline after ; if the next token is a }
This creates double newline.
2022-09-04 14:33:15 +00:00
Chayim Refael Friedman
e295f0c29c Insert whitespaces into static & const bodies if they are expanded from macro on hover
Macro expansion erases whitespace information, and so we end with invalid Rust code.
2022-09-04 14:33:15 +00:00
Jonas Schievink
241807dbf9 Allow multi-part inlay hint labels with location links 2022-08-31 18:34:10 +02:00
bors
56d888689b Auto merge of #12793 - lowr:fix/12739, r=Veykril
fix: sort and deduplicate auto traits in trait object types

Fixes #12739

Chalk solver doesn't sort and deduplicate auto traits in trait object types, so we need to handle them ourselves in the lowering phase, just like [`rustc`](880416180b/compiler/rustc_typeck/src/astconv/mod.rs (L1487-L1488)) and [`chalk-integration`](https://github.com/rust-lang/chalk/blob/master/chalk-integration/src/lowering.rs#L575) do.

Quoting from [the Chalk book](https://rust-lang.github.io/chalk/book/types/rust_types.html#dyn-types):

> Note that -- for this purpose -- ordering of bounds is significant. That means that if you create a `dyn Foo + Send` and a `dyn Send + Foo`, chalk would consider them distinct types. The assumption is that bounds are ordered in some canonical fashion somewhere else.

Also, trait object types with more than one non-auto traits were previously allowed, but are now disallowed with this patch.
2022-08-31 08:28:12 +00:00
Ryo Yoshida
7ecead23c8
fix: sort and deduplicate auto traits in trait object types 2022-08-30 20:52:42 +09:00
bors
ca8093e282 Auto merge of #13116 - Veykril:nohash, r=Veykril
Make use of NoHash hashing for FileId and CrateId

Both of these are mere integers so there is nothing to hash here.

Ideally we would use this for `la_arena::Idx` too, but that doesn't work due to the orphan rule, and `la_arena` is unfortunately a public library so we can't really do much here... Unless we remove the trait restriction but I'd like not to
2022-08-25 19:08:57 +00:00
Lukas Wirth
d025c5d8d6 Make use of NoHash hashing for FileId and CrateId 2022-08-25 20:41:49 +02:00
Jonas Schievink
322e7060de Resolve doc links on impl blocks 2022-08-23 17:50:45 +02:00
Lukas Wirth
f6f0516603 Add config for macro bang token highlighting, disable by default 2022-08-23 14:05:56 +02:00
Lukas Wirth
9700c95ced Make doc comment highlight injection configurable 2022-08-23 14:05:55 +02:00
Lukas Wirth
9a201873b8 Move highlight configuration from protocol into the feature 2022-08-23 14:05:55 +02:00
Lukas Wirth
16315edaee Make punctuation highlighting configurable, disable it by default 2022-08-23 14:05:55 +02:00
TJ DeVries
50ecb09da4 feat: emit SCIP via rust-analyzer 2022-08-22 15:13:46 -04:00
bors
1da9156b0d Auto merge of #12982 - jridgewell:into_future, r=Veykril
Implement IntoFuture type inference

One of my projects is using [IntoFuture](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) to make our async code a little less verbose. However, rust-analyzer can't infer the output type of an await expression if the value uses `IntoFuture` to convert into another type. So we're getting `{unknown}` types everywhere since switching.

`foo.await` itself [desugars](e4417cf020/compiler/rustc_ast_lowering/src/expr.rs (L644-L658)) into a `match into_future(foo) {}`, with every `Future` impl getting a [default](e4417cf020/library/core/src/future/into_future.rs (L131-L139)) `IntoFuture` implementation. I'm not sure if we want to disable the old `future_trait` paths, since this only recently [stabilize](https://github.com/rust-lang/rust/pull/98718).
2022-08-18 07:37:47 +00:00
Justin Ridgewell
cebf95718c Find IntoFuture::IntoFuture's poll method 2022-08-16 17:53:10 -04:00
Jonas Schievink
0616cee92b Add a setting for keyword hover popups 2022-08-16 16:51:40 +02:00
bors
6d6201299c Auto merge of #13025 - Veykril:simplify2, r=Veykril
Simplify
2022-08-15 14:40:26 +00:00
Lukas Wirth
3f149a63d2 Simplify 2022-08-15 16:40:10 +02:00