Commit graph

13570 commits

Author SHA1 Message Date
Lukas Wirth
7b456552b8 Don't discard PathKind::Abs information in lower_use::convert_path 2020-12-02 09:54:03 +01:00
bors[bot]
13025ae2a1
Merge #6676
6676: Minor cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-30 10:48:05 +00:00
Aleksey Kladov
8c3472b6f9 Minor cleanup 2020-11-30 13:47:38 +03:00
bors[bot]
ac30710ada
Merge #6665
6665: Support self in reference search r=matklad a=Veykril

The approach here is simply checking the descendants of the function body for `PathExpr` then checking whether it only contains a single `self` `PathSegment`, this is to prevent us from picking up `self` tokens from local `UseTree`s.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 20:03:44 +00:00
Lukas Wirth
de4ada22d4 Support self in reference search 2020-11-29 20:54:17 +01:00
bors[bot]
25ebcca224
Merge #6599
6599: Add attribute highlight modifier to all tokens inside attributes r=matklad a=Veykril

This has the side effect that we also emit `attribute.attribute` highlights now, as in, the tokens that get the attribute semantic type also get the attribute modifier. I personally don't think it's really a problem but maybe it is to some? It's just that it was really simple to implement it this way, which is why I just went this route for now.

Fixes #6536

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 19:35:12 +00:00
bors[bot]
f8726d781a
Merge #6601
6601: add let and letm postfix to turn expressions into variables r=matklad a=bnjjj

Partially resolve #6426 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-11-29 19:21:25 +00:00
bors[bot]
68910d2f34
Merge #6670
6670: Allow renaming between self and first param with owned parameters r=matklad a=Veykril

This fixes renaming owned SelfParams turning the parameter into a reference, as in, for a type `Foo`, `fn foo(self) {}` became `fn foo(renamed_name: &Foo) {}` prior to this.

Similarly for the other way around, we now support renaming non-ref parameters to `self`. Additionally we do more checks now than before. We check:
- that the function has an impl block
- that we are renaming the first parameter(prior we ignored which parameter was renamed and always picked the first nevertheless)
- that the parameter's type aligns with the impl block(minus one level of reference abstraction to account for `&self`/`&mut self`)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 19:07:04 +00:00
Lukas Wirth
4c33ae33e9 Reject more cases of invalid parameter to self renames 2020-11-29 19:02:59 +01:00
Lukas Wirth
f4a77f34da Fix renaming owned self to parameter emitting ref 2020-11-29 17:56:44 +01:00
bors[bot]
65a789368a
Merge #6669
6669: Align default importMergeBehaviour with VSCode r=lnicola a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-11-29 15:46:08 +00:00
Florian Diebold
21d256de72 Align default importMergeBehaviour with VSCode 2020-11-29 16:43:46 +01:00
bors[bot]
05f75d601f
Merge #6666
6666: Support 'go to definition' for self r=jonas-schievink a=Veykril

Also reverts #6660, instead of showing the type it now works like it does for names by returning the declaration we are already on. This for example enables VSCode to show all references(#6665) when executing `go to definition` on the declaration.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-29 14:35:38 +00:00
Lukas Wirth
37438c3335 Support 'go to definition' for self 2020-11-29 12:28:47 +01:00
bors[bot]
c8a2ff6ecc
Merge #6664
6664: Show type of self param on hover r=jonas-schievink a=Veykril

Show the type of `self` when hovering the token in a `SelfParam`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-28 23:38:18 +00:00
Lukas Wirth
ee8afff714 Show type of self param on hover 2020-11-28 22:59:24 +01:00
Benjamin Coenen
474ebd60d1 add let and letm postfix to turn expressions into variables
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-11-28 17:38:16 +01:00
bors[bot]
a6f26ded00
Merge #6660
6660: Support "go to definition" for SelfParams r=jonas-schievink a=Veykril

Fixes #6657

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-28 16:04:35 +00:00
bors[bot]
e437e38d7a
Merge #6659
6659: Explain how we get precise spans for diagnostics. r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-28 15:16:33 +00:00
Aleksey Kladov
5a42e6bff5 Explain how we get precise spans for diagnostics. 2020-11-28 18:14:08 +03:00
bors[bot]
7f3ba7d57f
Merge #6645
6645: Publish diagnostics for macro expansion errors r=matklad a=jonas-schievink

This adds 2 new diagnostics, emitted during name resolution:

* `unresolved-proc-macro`, a weak warning that is emitted when a proc macro is supposed to be expanded, but was not provided by the build system. This usually means that proc macro support is turned off, but may also indicate setup issues when using rust-project.json. Being a weak warning, this should help set expectations when users see it, while not being too obstructive. We do not yet emit this for attribute macros though, just custom derives and `!` macros.
* `macro-error`, which is emitted when any macro (procedural or `macro_rules!`) fails to expand due to some error. This is an error-level diagnostic, but currently still marked as experimental, because there might be spurious errors and this hasn't been tested too well.

This does not yet emit diagnostics when expansion in item bodies fails, just for module-level macros.

Known bug: The "proc macro not found" diagnostic points at the whole item for custom derives, it should just point at the macro's name in the `#[derive]` list, but I haven't found an easy way to do that.

Screenshots:

![screenshot-2020-11-26-19:54:14](https://user-images.githubusercontent.com/1786438/100385782-f8bc2300-3023-11eb-9f27-e8f8ce9d6114.png)
![screenshot-2020-11-26-19:55:39](https://user-images.githubusercontent.com/1786438/100385784-f954b980-3023-11eb-9617-ac2eb0a0a9dc.png)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-11-28 15:10:00 +00:00
Lukas Wirth
b006856381 Support goto definition for ADT-SelfParams 2020-11-28 16:07:07 +01:00
bors[bot]
b7ece77af4
Merge #6650
6650: Make completion and assists module independent r=matklad a=SomeoneToIgnore

A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/6553#discussion_r524402907

Move the common code for both assists and completion modules into a separate crate.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-11-28 14:33:57 +00:00
Kirill Bulatov
3f612d37c6 Move the helpers into ide_db 2020-11-28 16:30:39 +02:00
bors[bot]
fe2ac4480b
Merge #6656
6656: Coalesce flycheck events r=matklad a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-11-28 13:56:28 +00:00
Jonas Schievink
f52abbe62d Coalesce flycheck events 2020-11-27 22:52:22 +01:00
bors[bot]
59c4975b54
Merge #6653
6653: Downgrade "failed to load" error to warning r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6596

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-11-27 17:36:07 +00:00
Jonas Schievink
e49ba0d1df Downgrade "failed to load" error to warning 2020-11-27 18:35:22 +01:00
bors[bot]
b6dd2c6cbd
Merge #6652
6652: Add/Fix macro expansion profiling r=jonas-schievink a=jonas-schievink

bors r+ 🤖

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-11-27 17:08:22 +00:00
Jonas Schievink
ec7d2bbe42 Add/Fix macro expansion profiling 2020-11-27 18:07:16 +01:00
Kirill Bulatov
7b145bd99c Rustdocs fixes 2020-11-27 19:05:10 +02:00
Kirill Bulatov
f75f07019b Group import data in a struct 2020-11-27 18:30:10 +02:00
Kirill Bulatov
f4ae3650d8 Extract the import code into the shared module 2020-11-27 18:28:41 +02:00
bors[bot]
0993f9067c
Merge #6651
6651: Profile completions better r=SomeoneToIgnore a=SomeoneToIgnore

During https://github.com/rust-analyzer/rust-analyzer/issues/6612 investigation, had added a few more profiling points and considered that they can be useful later, ergo the PR.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-11-27 16:14:04 +00:00
Kirill Bulatov
04cd4b17bb
Fix the profiling string
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-11-27 18:13:02 +02:00
Kirill Bulatov
b2e6ca46ca Profile completions better 2020-11-27 18:00:03 +02:00
Jonas Schievink
d171838d63 More accurately place proc-macro diagnostic 2020-11-27 16:29:40 +01:00
Jonas Schievink
0432aa0ed7 Publish diagnostics for macro expansion errors 2020-11-27 13:50:22 +01:00
Jonas Schievink
1b26520971 Add dedicated error for "proc macro not found" 2020-11-27 13:50:20 +01:00
bors[bot]
c66d477f5a
Merge #6648
6648: Avoid allocation in ast::String::value if the string needs no unescaping r=lnicola a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-27 11:14:14 +00:00
Lukas Wirth
347da74eda Avoid allocation in ast::String::value if the string needs no unescaping 2020-11-27 12:03:58 +01:00
bors[bot]
572081f1c4
Merge #6586
6586: Don't call a closure a function in the infer_function_return_type assist label r=lnicola a=Veykril

`Add this function's return type` becomes `Add this closure's return type` for closures. This makes it more obvious that we are indeed planning on modifying the closure and not its containing function.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-27 09:49:37 +00:00
bors[bot]
bb2c6ceee7
Merge #6646
6646: Remove single r#trait identifer usage r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-26 20:50:16 +00:00
Lukas Wirth
6501c9445e Don't use raw identifiers 2020-11-26 21:44:17 +01:00
bors[bot]
fc0354b280
Merge #6635
6635: Complete struct in irrefutable let r=Veykril a=Veykril

Fixes #6210

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-26 20:30:16 +00:00
Lukas Wirth
ee06c07f50 Complete struct in irrefutable let 2020-11-26 21:28:43 +01:00
bors[bot]
38d595c36f
Merge #6644
6644: Simplify error formatting r=lnicola a=lnicola

CC jonas-schievink

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-11-26 19:18:40 +00:00
Laurențiu Nicola
3aca697511 Simplify error formatting 2020-11-26 21:07:15 +02:00
bors[bot]
deb3550fea
Merge #6643
6643: Remove unused import r=lnicola a=lnicola

Not sure why CI didn't catch this...

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-11-26 17:28:43 +00:00
Laurențiu Nicola
a5477d7f29 Remove unused import 2020-11-26 19:25:59 +02:00