Commit graph

14027 commits

Author SHA1 Message Date
bors[bot]
917d56273d
Merge #6840
6840: Add a language configuration file for VS Code r=matklad a=dustypomerleau

There has been recent discussion in #6451 and #6682 about the need to include angle brackets in auto-close and auto-surround functionality. This PR will accomplish that, but only for users of VS Code, as it uses the VS Code-specific `language-configuration.json` to get the job done. Since there are a large number of VS Code users in the Rust Analyzer cohort, it may be reasonable to fix the issue for them, while waiting on a more comprehensive solution in the language server. In addition to the usual brackets, I've added auto-closing of block comments. I avoided autoclosing single quotes, given that lifetimes are more common than chars.

Co-authored-by: Dusty Pomerleau <dustypomerleau@users.noreply.github.com>
2020-12-13 14:20:11 +00:00
bors[bot]
fbad1b8a24
Merge #6856
6856: Add test for #6852 r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-12-13 13:54:39 +00:00
Florian Diebold
4788aaa5f0 Add test for #6852 2020-12-13 14:53:04 +01:00
bors[bot]
48802e54d1
Merge #6855
6855: Change recommendation when source can't be loaded from sysroot r=matklad a=flodiebold

Since we just tried running `rustup component add`, it doesn't make sense to me to recommend trying that again. If we're reaching this case, it's probably more likely that rustc was installed via package manager, in which case the source should be installed the same way (e.g. if you install the rust-src package on Ubuntu it will install a symlink in the right place to make our sysroot
detection work, and IMO we should get other distributors to do the same if they aren't already).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-12-13 13:18:41 +00:00
Laurențiu Nicola
dc519b88af Replace goblin crate with object 2020-12-13 14:08:59 +02:00
Florian Diebold
7d7949b315 Change recommendation when source can't be loaded from sysroot
Since we just tried running `rustup component add`, it doesn't make sense to me
to recommend trying that again. If we're reaching this case, it's probably more
likely that rustc was installed via package manager, in which case the source
should be installed the same way (e.g. if you install the rust-src package on
Ubuntu it will install a symlink in the right place to make our sysroot
detection work).
2020-12-13 13:04:50 +01:00
bors[bot]
ca3a54f0a4
Merge #6852
6852: Ignore lifetime params in substitutions r=matklad a=Veykril

[`hir_ty::utils::Generics`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/utils.rs#L153) currently only assumes type parameters but not lifetime parameters and therefor creates incorrect index and length calculations, this PR just makes the use sites ignore LifetimeGenerics for now.

This fixes the panic at least locally for me for `analysis-stats`. Funnily enough this panic prevented me from using reference search for the `args` field to fix this problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-13 11:34:43 +00:00
Lukas Wirth
ae8a802085 Ignore lifetime params in substitutions 2020-12-13 11:34:44 +01:00
Dusty Pomerleau
612be09282 add a language configuration for VS Code 2020-12-13 19:31:11 +11:00
bors[bot]
a15d19619e
Merge #6845
6845: Don't HirDisplay unknown types when displaying for source r=Veykril a=Veykril

Was wondering why the add missing impl assist didn't do anything here:
![Code_JCA1Qo0V9P](https://user-images.githubusercontent.com/3757771/101990300-7af44a80-3ca6-11eb-8431-e5eb4de4e78c.png)
Turns out me forgetting to set the Index::Idx type in the trait causes RA to panic due to it trying to to create an unparsable type in the `make` module.
Now we get this instead which imo is definitely better to have.
![Code_MUFPJUCULY](https://user-images.githubusercontent.com/3757771/101990347-c9094e00-3ca6-11eb-9c6a-146bddf64b7c.png)



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 18:06:36 +00:00
Lukas Wirth
69b78edb5e Don't HirDisplay unknown types when displaying for source 2020-12-12 19:05:00 +01:00
bors[bot]
10f6332831
Merge #6846
6846: Remove some redundant allocations r=kjeremy a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-12-12 17:29:20 +00:00
Jeremy Kolb
26a1675764 Remove some redundant allocations 2020-12-12 12:27:09 -05:00
bors[bot]
479d1f7eec
Merge #6818
6818: Add Lifetimes to the HIR r=matklad a=Veykril

This doesn't handle resolve yet as I don't know yet how that will be used. I'll get to that once I start moving the lifetime reference PR to the hir.

This also adds a new `hir` name type for lifetimes and labels, `hir::LifetimeName`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 14:35:38 +00:00
bors[bot]
64a1c9810d
Merge #6841
6841: Added "Remove this semicolon" test r=matklad a=ivan770

Closes https://github.com/rust-analyzer/rust-analyzer/pull/6769#discussion_r540150066

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2020-12-12 14:29:12 +00:00
ivan770
f7f4f366ac
Added remove this semicolon test 2020-12-12 13:50:11 +02:00
bors[bot]
70db57cc59
Merge #6839
6839: Infer labeled blocks r=flodiebold a=Veykril

The test should cover all the interesting cases I believe(main part of it is copied from the loop label break test above it).

The test is indented to stay consistent with the rest of the tests in the file, I can dedent all the tests in the file in a follow up PR if desired.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 10:18:16 +00:00
Lukas Wirth
11f8664182 Add Lifetimes to the HIR 2020-12-12 00:56:52 +01:00
Lukas Wirth
378ec2841b Infer labeled blocks 2020-12-12 00:06:48 +01:00
bors[bot]
4998807039
Merge #6813
6813: negative sign matching in mbe matching for literal r=edwin0cheng a=edwin0cheng

Fix #6292

r @jonas-schievink 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-11 22:17:40 +00:00
Edwin Cheng
ae29fb0211 Add missing arg for eat_char 2020-12-12 06:14:11 +08:00
bors[bot]
c1ef623338
Merge #6838
6838: cargo update r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-12-11 22:07:11 +00:00
kjeremy
8079f5b147 cargo update 2020-12-11 17:00:25 -05:00
bors[bot]
4227246948
Merge #6836
6836: Use Attrs::docs in NavigationTarget instead of DocCommentsOwner r=kjeremy a=Veykril

That should be the last place where the AST comment machinery is referred to.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-11 20:32:11 +00:00
Lukas Wirth
8ed8e4f25a Use Attrs::docs in NavigationTarget instead of DocCommentsOwner 2020-12-11 21:19:58 +01:00
bors[bot]
91bf15a2f5
Merge #6834
6834: Use Attrs::docs in runnables instead of DocCommentsOwner r=kjeremy a=Veykril

I figured that we should probably move as much of the doc usage to the HIR as possible hence this PR. If we should keep this AST-based feel free to close.

This change does have the nice(but not really useful as I doubt anyones gonna write doc tests like these) side effect that these two doc string snippets allow being run now.
![image](https://user-images.githubusercontent.com/3757771/101945607-bf241400-3bee-11eb-96ce-ccae80028b1f.png)
![image](https://user-images.githubusercontent.com/3757771/101946375-2e9a0380-3bef-11eb-9950-e35168fdd048.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-11 19:57:08 +00:00
Lukas Wirth
ac19a71459 Use Attrs::docs in runnables instead of DocCommentsOwner 2020-12-11 20:11:03 +01:00
bors[bot]
1e4378b540
Merge #6832
6832: Add upstream commit to builtin_attr.rs r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 18:12:42 +00:00
Jonas Schievink
00c34b048e Add upstream commit to builtin_attr.rs 2020-12-11 19:12:06 +01:00
bors[bot]
3674e494ca
Merge #6819
6819: Add builtin attributes for use in nameres r=jonas-schievink a=jonas-schievink

These are not yet used, but have to go through nameres later in order to support procedural macro attributes

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 18:03:09 +00:00
bors[bot]
3df4b8c1fa
Merge #6830
6830: Avoid panic when collecting memory metrics r=jonas-schievink a=jonas-schievink

This is getting hit during metrics collection.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 17:25:16 +00:00
Jonas Schievink
cb35d3a05a metrics: go back to cmd! 2020-12-11 18:24:42 +01:00
Jonas Schievink
2fdde98b5c Move print_memory_usage to cli.rs 2020-12-11 18:24:27 +01:00
Jonas Schievink
c007ac3830 Avoid panic when collecting memory metrics 2020-12-11 18:18:27 +01:00
bors[bot]
24731e107f
Merge #6829
6829: Fix typo leading to metrics loss r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 16:56:30 +00:00
Jonas Schievink
64752ef5e9 Fix typo leading to metrics loss 2020-12-11 17:55:52 +01:00
bors[bot]
d3700b80b1
Merge #6828
6828: Metrics debugging r=jonas-schievink a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 16:31:13 +00:00
Jonas Schievink
7fc4ba000e Capture memory usage metrics 2020-12-11 17:30:32 +01:00
bors[bot]
e68110c082
Merge #6827
6827: Revert "Fix memory usage metrics" r=jonas-schievink a=jonas-schievink

Reverts rust-analyzer/rust-analyzer#6825

It broke metrics entirely. Will debug this later, unless someone else gets to it first.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 15:51:13 +00:00
Jonas Schievink
75543d8ca1
Revert "Fix memory usage metrics" 2020-12-11 16:50:17 +01:00
bors[bot]
df1f3907af
Merge #6824
6824: Don't highlight parent nodes of comments on hover r=kjeremy a=Veykril

Fixes #6815

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-11 15:02:57 +00:00
Lukas Wirth
37c5b82938 Don't highlight parent nodes of comments on hover 2020-12-11 16:00:52 +01:00
bors[bot]
57ea320ffc
Merge #6825
6825: Fix memory usage metrics r=jonas-schievink a=jonas-schievink

Let's see if this fixes https://github.com/rust-analyzer/rust-analyzer/issues/6808

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 14:48:27 +00:00
Jonas Schievink
777d8dca26 Fix memory usage metrics 2020-12-11 15:47:40 +01:00
bors[bot]
f304ce329f
Merge #6821
6821: Improve code structure r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-11 14:08:22 +00:00
Aleksey Kladov
4015ff0e0b Improve code structure
Make sure that there's only one entry point, analyze, remove awkard
analyzer2 name
2020-12-11 17:06:21 +03:00
Jonas Schievink
253678ead2 Add builtin attributes for use in nameres 2020-12-11 14:04:33 +01:00
bors[bot]
15a644d606
Merge #6816
6816: Use natural trait ordering in derive completion r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-11 12:46:47 +00:00
Aleksey Kladov
e179ed6f53 Use natural trait ordering in derive completion
derive(Clone, Copy) reads better than derive(Copy, Clone).

However, we preserve the reverse ordering in the lookup text for
sorting purposes. That way, it's convenient to type just `Ord` to
derive everything.
2020-12-11 15:45:53 +03:00
Edwin Cheng
175229ab3d negative sign matching in mbe matching for literal 2020-12-11 17:59:04 +08:00