Commit graph

15904 commits

Author SHA1 Message Date
Lukas Wirth
cadb01c315 Move reference imports filtering into to_proto layer 2022-09-13 14:58:50 +02: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
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
ice1000
37e20decad Address comments 2022-09-02 21:18:36 +00:00
ice1000
277df02ff5 This should work, but I got mysterious errors 2022-09-02 21:18:36 +00:00
ice1000
79e5c366cd Extract shared logic 2022-09-02 21:18:36 +00:00
ice1000
fcc61337a8 Remove alias definition naively 2022-09-02 21:18:36 +00:00
Lukas Wirth
894aa0ed0d Clarify the state of (extern) preludes for block def maps 2022-09-02 17:43:20 +02:00
Lukas Wirth
8828049b23 Lift out the module scope into a field in the Resolver
A Resolver *always* has a module scope at the end of its scope stack,
instead of encoding this as an invariant we can just lift this scope
out into a field, allowing us to skip going through the scope vec
indirection entirely.
2022-09-02 17:02:12 +02:00
bors
2bb6635a85 Auto merge of #13173 - Veykril:synthetic, r=Veykril
Don't store SyntheticSyntax in the reverse maps in BodySourceMap

They are ZSTs which we can just create on missing access instead.
2022-09-02 13:17:16 +00:00