Commit Graph

15911 Commits

Author SHA1 Message Date
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
bors
ba15f75c39 Auto merge of #13225 - lowr:fix/hir-proj-normalization, r=Veykril
fixup: remove unnecessary `Option`

Fixup for #13223, two things:

- `normalize_projection_query()` (and consequently `HirDatabase::normalize_projection()`) never returns `None` (well, it used to when I first wrote it...), so just return `Ty` instead of `Option<Ty>`
- When chalk cannot normalize projection uniquely, `normalize_trait_assoc_type()` used to return `None` before #13223, but not anymore because of the first point. I restored the behavior so its callers work as before.
2022-09-13 14:52:58 +00:00
bors
125d43cb2c Auto merge of #13227 - Veykril:core-pref, r=Veykril
Restructure `find_path` into a separate functions for modules and non-module items

Follow up to https://github.com/rust-lang/rust-analyzer/pull/13212
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc

This PR turned into a slight rewrite, so it unfortunately does a few more things that I initially planned to (including a bug fix for enum variant paths)
2022-09-13 13:16:57 +00:00
Lukas Wirth
a8ecaa1979 Restructure find_path into a separate functions for modules and non-module items
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc
2022-09-13 15:15:27 +02: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
Ryo Yoshida
d223c28c7d
Remove unnecessary Option 2022-09-13 02:20:35 +09:00
bors
f64c95600c Auto merge of #13216 - DesmondWillowbrook:move_format_string_arg, r=DesmondWillowbrook
New assist: move_format_string_arg

The name might need some improving.

```rust
fn main() {
    print!("{x + 1}");
}
```
to
```rust
fn main() {
    print!("{}"$0, x + 1);
}
```

fixes #13180

ref to #5988 for similar work

* extracted `format_like`'s parser to it's own module in `ide-db`
* reworked the parser's API to be more direct
* added assist to extract expressions in format args
2022-09-12 15:50:42 +00: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
Kartavya Vashishtha
54e9324e93
Update crates/ide-assists/src/handlers/move_format_string_arg.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-09-12 05:45:11 -07:00
bors
7a704f2cc7 Auto merge of #13147 - lowr:fix/dyn-ty-inherent-methods, r=Veykril
fix: handle trait methods as inherent methods for trait-related types

Fixes #10677

When resolving methods for trait object types and placeholder types that are bounded by traits, we need to count the methods of the trait and its super traits as inherent methods. This matters because these trait methods have higher priority than the other traits' methods.

Relevant code in rustc: [`assemble_inherent_candidates_from_object()`](0631ea5d73/compiler/rustc_typeck/src/check/method/probe.rs (L783-L792)) for trait object types, [`assemble_inherent_candidates_from_param()`](0631ea5d73/compiler/rustc_typeck/src/check/method/probe.rs (L838-L847)) for placeholder types. Notice the second arg of `push_candidate()` is `is_inherent`.
2022-09-12 12:19:14 +00: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
bors
352a5b8625 Auto merge of #13212 - Veykril:no-std-config, r=Veykril
Add config to unconditionally prefer core imports over std

Fixes https://github.com/rust-lang/rust-analyzer/issues/12979
2022-09-12 11:51:31 +00:00
Borys Minaiev
32603baac3 Remove redundant 'resolve_obligations_as_possible' call 2022-09-12 11:03:44 +01: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
Kartavya Vashishtha
fb5ae9906b
suggest ExtractRefactor if no expressions found
Added `Ident` variant to arg enum.
2022-09-11 10:39:25 +05:30
Kartavya Vashishtha
a5cbee4d11
remove false positive 2022-09-10 21:04:25 +05:30
Kartavya Vashishtha
cc7200891b
new lint: move_format_string_arg
The name might need some improving.

extract format_like's parser to it's own module in ide-db

reworked the parser's API to be more direct

added assist to extract expressions in format args
2022-09-10 20:13:46 +05:30
Kartavya Vashishtha
2584d48508
wip 2022-09-10 20:13:46 +05:30
Lukas Wirth
7d19971666 Add config to unconditionally prefer core imports over std
Fixes https://github.com/rust-lang/rust-analyzer/issues/12979
2022-09-09 20:04:56 +02:00
Stanislav
f7f4792f4f fixes 2022-09-09 20:58:06 +03:00
Peh
bd3feea8bc fix: removed swap file 2022-09-08 22:44:10 +01:00
Peh
c7fefd5223 fix: add semicolon completion to mod 2022-09-08 22:37:31 +01:00
Stanislav
0240294759 fix comment round 2 2022-09-08 22:47:39 +03:00
Stanislav
1764c42518 fix comment 2022-09-08 22:36:36 +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
c4eadab016
Update crates/rust-analyzer/src/to_proto.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-09-08 18:33:53 +02: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
Joseph Ryan
5d126a18b4 Use proc-macro-srv from sysroot in rust-project.json 2022-09-06 18:27:17 -07: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
6dfd8aebdf Auto merge of #13192 - lowr:fix/dyn-sort-all-bounds, r=Veykril
fix: sort all bounds on trait object types

Fixes #13181

#12793 allowed different ordering of trait bounds in trait object types but failed to account for the ordering of projection bounds. I opted for sorting all the bounds at once rather than splitting them into `SmallVec`s so it's easier to do the same thing for other bounds when we have them.
2022-09-05 11:24:54 +00: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
bors
4790916876 Auto merge of #13139 - Austaras:enum, r=Veykril
Suggest struct when completing enum

closes #13107
2022-09-05 10:59:38 +00:00
bors
a1c26530ec Auto merge of #13091 - ice1k:hey, r=Veykril
Remove type alias definition on inline

Fix #13079
2022-09-05 10:49:19 +00:00
Ryo Yoshida
265c75c53f
fix: sort all bounds on trait object types 2022-09-05 19:13:32 +09:00
austaras
748567cba5 complete full struct in enum varaint 2022-09-05 03:36:14 +08:00
Aleksey Kladov
d7ef3f51ec fix: correct broken logic for return complition
It seems that we've accidentally deleted the tests here couple of years
ago, and then fairly recently made a typo during refactor as well.

Reinstall tests, with coverage marks this time :-)
2022-09-04 18:12:55 +01: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
Lukas Wirth
020f6895e5 Fix nested break expressions, expecting unknown types 2022-09-03 17:32:21 +02:00
ice1000
364d9c4910 Fmt 2022-09-02 21:18:36 +00:00
ice1000
68eabf1bf1 Fix test 2022-09-02 21:18:36 +00:00
ice1000
a695e900f6 Create trait Removable, replace ted APIs with builder APIs 2022-09-02 21:18:36 +00:00