]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoSimplify `int_in_range`
Jonas Schievink [Tue, 31 Aug 2021 11:11:17 +0000 (13:11 +0200)]
Simplify `int_in_range`

2 years agoDepend on both crates individually
Jonas Schievink [Tue, 31 Aug 2021 11:10:16 +0000 (13:10 +0200)]
Depend on both crates individually

2 years agoFix DNF construction, add proptest
Jonas Schievink [Mon, 30 Aug 2021 20:26:35 +0000 (22:26 +0200)]
Fix DNF construction, add proptest

2 years agoMerge #10089
bors[bot] [Mon, 30 Aug 2021 19:35:00 +0000 (19:35 +0000)]
Merge #10089

10089: Fix minor mispelling r=bjorn3 a=NerdyPepper

`find_map` misspelt as `wind_map` in test identifier.

Co-authored-by: Akshay <nerdy@peppe.rs>
2 years agoMerge #10076
bors[bot] [Mon, 30 Aug 2021 18:55:18 +0000 (18:55 +0000)]
Merge #10076

10076: Use struct init shorthand when applicable in fill struct fields assist r=matklad a=nathanwhit

This PR tweaks the fill struct fields assist to use the struct init shorthand when a local variable with a matching name and type is in scope.

For example:
```rust
struct Foo {
    a: usize,
    b: i32,
    c: char,
}

fn main() {
    let a = 1;
    let b = 2;
    let c = 3;
    let foo = Foo { <|> };
}
```
Before we would insert
```rust
Foo {
    a: (),
    b: (),
    c: (),
}
```
now we would insert
```rust
Foo {
    a,
    b,
    c: ()
}
```

Co-authored-by: nathan.whitaker <nathan.whitaker01@gmail.com>
2 years agoAdd coverage mark for struct init shorthand test
nathan.whitaker [Mon, 30 Aug 2021 18:37:03 +0000 (14:37 -0400)]
Add coverage mark for struct init shorthand test

2 years agofix minor mispelling
Akshay [Mon, 30 Aug 2021 17:21:14 +0000 (22:51 +0530)]
fix minor mispelling

find_map misspelt as wind_map

2 years agoMerge #10088
bors[bot] [Mon, 30 Aug 2021 16:49:13 +0000 (16:49 +0000)]
Merge #10088

10088: feat: improve CPU usage r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agofeat: improve CPU usage
Aleksey Kladov [Mon, 30 Aug 2021 16:39:19 +0000 (19:39 +0300)]
feat: improve CPU usage

closes #9922

Turned out to be trivial after preliminary refactor.

The intended behavior is that we schedule cache priming once ws become
quiescent (that is, we fully load cargo project), and we continue to
rschedule it until it completes (priming might get cancelled by user
typing into a file).

2 years agointernal: make scheduling control flow more obvious
Aleksey Kladov [Mon, 30 Aug 2021 16:35:49 +0000 (19:35 +0300)]
internal: make scheduling control flow more obvious

There should be only one place where we need to check if we want to
start background activities.

2 years agointernal: improve consistency
Aleksey Kladov [Mon, 30 Aug 2021 16:24:31 +0000 (19:24 +0300)]
internal: improve consistency

Let's have only one place where we start delayed ops

2 years agointernal: more obviously correct code for cache priming progerss
Aleksey Kladov [Mon, 30 Aug 2021 16:18:48 +0000 (19:18 +0300)]
internal: more obviously correct code for cache priming progerss

It doesn't make sense for the prime_caches itself send begin/end events
-- the caller knows perfectly fine when they happen!

2 years agoMerge #10085
bors[bot] [Mon, 30 Aug 2021 12:57:39 +0000 (12:57 +0000)]
Merge #10085

10085: fix: avoid panic when parsing extern block r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: improve style
Aleksey Kladov [Mon, 30 Aug 2021 12:55:40 +0000 (15:55 +0300)]
internal: improve style

Group related stuff together, use only on path for parsing extern blocks
(they actually have modifiers).

Perhaps we should get rid of items_without_modifiers altogether? Better
to handle these kinds on diagnostics in validation layer...

2 years agofix: avoid panic when parsing extern block
Aleksey Kladov [Mon, 30 Aug 2021 12:40:47 +0000 (15:40 +0300)]
fix: avoid panic when parsing extern block

closes #10083

2 years agoMerge #10081
bors[bot] [Mon, 30 Aug 2021 09:50:16 +0000 (09:50 +0000)]
Merge #10081

10081: Fix error message r=lnicola a=digama0

I'm not entirely sure if the message is still correct, it seems to have survived a number of refactors, but it is mangled english anyway.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2 years agofail -> failed
Mario Carneiro [Mon, 30 Aug 2021 09:47:10 +0000 (02:47 -0700)]
fail -> failed

2 years agoUpdate crates/hir_expand/src/db.rs
Mario Carneiro [Mon, 30 Aug 2021 09:43:13 +0000 (02:43 -0700)]
Update crates/hir_expand/src/db.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2 years agoFix error message
Mario Carneiro [Mon, 30 Aug 2021 09:36:21 +0000 (02:36 -0700)]
Fix error message

I'm not entirely sure if the message is still correct, it seems to have survived a number of refactors, but it is mangled english anyway.

2 years agoMerge #10005
bors[bot] [Mon, 30 Aug 2021 08:42:13 +0000 (08:42 +0000)]
Merge #10005

10005: Extend `CargoConfig.unset_test_crates`  r=matklad a=regexident

This is to allow for efficiently disabling `#[cfg(test)]` on all crates (by passing `unset_test_crates: UnsetTestCrates::All`) without having to first load the crate graph, when using rust-analyzer as a library.

(FYI: The change doesn't seem to be covered by any existing tests.)

Co-authored-by: Vincent Esche <regexident@gmail.com>
2 years agoMerge #10015
bors[bot] [Mon, 30 Aug 2021 08:34:49 +0000 (08:34 +0000)]
Merge #10015

10015: internal: more declarative re-indentation API r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoMerge #10080
bors[bot] [Mon, 30 Aug 2021 07:58:59 +0000 (07:58 +0000)]
Merge #10080

10080: internal: don't shut up the compiler when it says the code's buggy r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: don't shut up the compiler when it says the code's buggy
Aleksey Kladov [Mon, 30 Aug 2021 07:53:59 +0000 (10:53 +0300)]
internal: don't shut up the compiler when it says the code's buggy

Wrapping state-modifying functions into a `catch_unwind` is wrong -- to
do retry after failure, you need to have transactional semantics!

2 years agoMerge #10079
bors[bot] [Mon, 30 Aug 2021 07:39:34 +0000 (07:39 +0000)]
Merge #10079

10079: internal: make upstream bug less annoying r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: make upstream bug less annoying
Aleksey Kladov [Mon, 30 Aug 2021 07:25:44 +0000 (10:25 +0300)]
internal: make upstream bug less annoying

2 years agoMerge #9906
bors[bot] [Mon, 30 Aug 2021 07:30:01 +0000 (07:30 +0000)]
Merge #9906

9906: switch `log` crate to `tracing` r=lnicola a=dzvon

Fixes #9274

1. Replace `log` crate with `tracing` of every crate that depend on `log`.
2. Change all `log` record macro with `tracing`.
3. Add `LoggerFormatter` make output format be the same as original.

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 years agoswitch `log` crate to `tracing`
Dezhi Wu [Sun, 15 Aug 2021 12:46:13 +0000 (20:46 +0800)]
switch `log` crate to `tracing`

2 years agoMerge #10078
bors[bot] [Mon, 30 Aug 2021 06:54:36 +0000 (06:54 +0000)]
Merge #10078

10078: internal: Use Ubuntu 18.04 on CI r=lnicola a=lnicola

Ubuntu 16.04 is EOL since April, let's upgrade to 18.04.

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoUse Ubuntu 18.04 on CI
Laurențiu Nicola [Mon, 30 Aug 2021 06:50:41 +0000 (09:50 +0300)]
Use Ubuntu 18.04 on CI

2 years agoUpdate existing fill struct fields test
nathan.whitaker [Sun, 29 Aug 2021 17:14:15 +0000 (13:14 -0400)]
Update existing fill struct fields test

2 years agoAdd tests for fill struct fields shorthand
nathan.whitaker [Sun, 29 Aug 2021 17:14:03 +0000 (13:14 -0400)]
Add tests for fill struct fields shorthand

2 years agoUse struct init shorthand in fill struct fields assist
nathan.whitaker [Sun, 29 Aug 2021 17:12:59 +0000 (13:12 -0400)]
Use struct init shorthand in fill struct fields assist

2 years agoMerge #10074
bors[bot] [Sun, 29 Aug 2021 15:56:06 +0000 (15:56 +0000)]
Merge #10074

10074: internal: improve compile times a bit r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: don't expose impl details out of hir
Aleksey Kladov [Sun, 29 Aug 2021 15:55:25 +0000 (18:55 +0300)]
internal: don't expose impl details out of hir

2 years agointernal: improve compile times a bit
Aleksey Kladov [Sun, 29 Aug 2021 15:49:16 +0000 (18:49 +0300)]
internal: improve compile times a bit

before after for cargo llvm-lines -q --lib --release -p ide_ssr | head -n 24

  Lines          Copies        Function name
  -----          ------        -------------
  297146 (100%)  12748 (100%)  (TOTAL)
    5970 (2.0%)     47 (0.4%)  core::iter::traits::iterator::Iterator::try_fold
    4750 (1.6%)     27 (0.2%)  hashbrown::raw::RawTable<T,A>::resize
    4080 (1.4%)     30 (0.2%)  alloc::raw_vec::RawVec<T,A>::grow_amortized
    3933 (1.3%)     69 (0.5%)  alloc::raw_vec::RawVec<T,A>::current_memory
    3668 (1.2%)     89 (0.7%)  <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
    3500 (1.2%)     50 (0.4%)  hashbrown::raw::RawTable<T,A>::drop_elements
    3436 (1.2%)     33 (0.3%)  hashbrown::raw::RawTable<T,A>::find
    3415 (1.1%)     17 (0.1%)  hashbrown::raw::RawTable<T,A>::rehash_in_place
    3400 (1.1%)     50 (0.4%)  <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
    2840 (1.0%)     20 (0.2%)  alloc::raw_vec::RawVec<T,A>::allocate_in
    2700 (0.9%)     30 (0.2%)  core::alloc::layout::Layout::array
    2666 (0.9%)     86 (0.7%)  core::ptr::metadata::from_raw_parts_mut
    2495 (0.8%)     50 (0.4%)  core::option::Option<T>::map
    2354 (0.8%)     38 (0.3%)  alloc::alloc::box_free
    2302 (0.8%)      7 (0.1%)  ide_ssr::parsing::RuleBuilder::try_add
    2146 (0.7%)     45 (0.4%)  core::mem::replace
    2070 (0.7%)     69 (0.5%)  <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
    1979 (0.7%)     16 (0.1%)  hashbrown::map::HashMap<K,V,S,A>::insert
    1926 (0.6%)     18 (0.1%)  <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
    1922 (0.6%)     62 (0.5%)  core::fmt::ArgumentV1::new
    1885 (0.6%)     13 (0.1%)  alloc::raw_vec::RawVec<T,A>::shrink

  Lines          Copies        Function name
  -----          ------        -------------
  261717 (100%)  11666 (100%)  (TOTAL)
    5239 (2.0%)     42 (0.4%)  core::iter::traits::iterator::Iterator::try_fold
    4750 (1.8%)     27 (0.2%)  hashbrown::raw::RawTable<T,A>::resize
    3933 (1.5%)     69 (0.6%)  alloc::raw_vec::RawVec<T,A>::current_memory
    3536 (1.4%)     26 (0.2%)  alloc::raw_vec::RawVec<T,A>::grow_amortized
    3500 (1.3%)     50 (0.4%)  hashbrown::raw::RawTable<T,A>::drop_elements
    3400 (1.3%)     50 (0.4%)  <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
    3124 (1.2%)     30 (0.3%)  hashbrown::raw::RawTable<T,A>::find
    2812 (1.1%)     14 (0.1%)  hashbrown::raw::RawTable<T,A>::rehash_in_place
    2604 (1.0%)     84 (0.7%)  core::ptr::metadata::from_raw_parts_mut
    2340 (0.9%)     26 (0.2%)  core::alloc::layout::Layout::array
    2302 (0.9%)      7 (0.1%)  ide_ssr::parsing::RuleBuilder::try_add
    2272 (0.9%)     16 (0.1%)  alloc::raw_vec::RawVec<T,A>::allocate_in
    2201 (0.8%)     35 (0.3%)  alloc::alloc::box_free
    2104 (0.8%)     44 (0.4%)  core::mem::replace
    2079 (0.8%)     42 (0.4%)  <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
    2070 (0.8%)     69 (0.6%)  <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
    1926 (0.7%)     18 (0.2%)  <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
    1885 (0.7%)     13 (0.1%)  alloc::raw_vec::RawVec<T,A>::shrink
    1833 (0.7%)     13 (0.1%)  hashbrown::raw::RawTable<T,A>::shrink_to
    1771 (0.7%)     91 (0.8%)  core::ptr::read
    1701 (0.6%)     35 (0.3%)  core::option::Option<T>::map

2 years agoMerge #10071
bors[bot] [Sun, 29 Aug 2021 09:54:33 +0000 (09:54 +0000)]
Merge #10071

10071: internal: slightly improve compile times r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: slightly improve compile times
Aleksey Kladov [Sun, 29 Aug 2021 09:31:42 +0000 (12:31 +0300)]
internal: slightly improve compile times

As per style guide, avoid monomorphisations

2 years agominor: remove debug print
Aleksey Kladov [Sun, 29 Aug 2021 09:32:35 +0000 (12:32 +0300)]
minor: remove debug print

2 years agoMerge #10067
bors[bot] [Sat, 28 Aug 2021 23:38:34 +0000 (23:38 +0000)]
Merge #10067

10067: Downmap tokens to all token descendants instead of just the first r=Veykril a=Veykril

With this we can now resolve usages of identifiers inside (proc-)macros even if they are used for different purposes multiple times inside the expansion.
Example here being with the cursor being on the `no_send_sync_value` function causing us to still highlight the identifier in the attribute invocation correctly as we now resolve its usages in there. Prior we only saw the first usage of the identifier which is for a definition only, as such we bailed and didn't highlight it.
![image](https://user-images.githubusercontent.com/3757771/131233056-7e645b1d-b82f-468c-bf19-d3335a2cf7c2.png)

Note that this has to be explicitly switched over for most IDE features now as pretty much everything expects a single node/token as a result from descending.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Sat, 28 Aug 2021 23:38:10 +0000 (01:38 +0200)]
Simplify

2 years agoOnly report unique text ranges in highlight_related
Lukas Wirth [Sat, 28 Aug 2021 22:45:55 +0000 (00:45 +0200)]
Only report unique text ranges in highlight_related

2 years agoReturn all usages inside macros in usage searches
Lukas Wirth [Sat, 28 Aug 2021 22:36:26 +0000 (00:36 +0200)]
Return all usages inside macros in usage searches

2 years agoHighlight all related tokens in macro inputs
Lukas Wirth [Sat, 28 Aug 2021 19:37:27 +0000 (21:37 +0200)]
Highlight all related tokens in macro inputs

2 years agoReturn all ranges corresponding to a token id in TokenMap
Lukas Wirth [Sat, 28 Aug 2021 19:18:56 +0000 (21:18 +0200)]
Return all ranges corresponding to a token id in TokenMap

2 years agoMerge #10069
bors[bot] [Sat, 28 Aug 2021 21:13:18 +0000 (21:13 +0000)]
Merge #10069

10069: internal: Use `ManuallyDrop` in `RootDatabase` to improve build times r=matklad a=jonas-schievink

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoUse `ManuallyDrop` in `RootDatabase`
Jonas Schievink [Sat, 28 Aug 2021 21:05:40 +0000 (23:05 +0200)]
Use `ManuallyDrop` in `RootDatabase`

2 years agoMerge #10066
bors[bot] [Sat, 28 Aug 2021 20:38:58 +0000 (20:38 +0000)]
Merge #10066

10066: internal: improve compile times a bit r=matklad a=matklad

I wanted to *quickly* remove `smol_str = {features = "serde"}`, and figured out that the simplest way to do that is to replace our straightforward proc macro serialization with something significantly more obscure.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: reformat
Aleksey Kladov [Sat, 28 Aug 2021 20:38:39 +0000 (23:38 +0300)]
minor: reformat

2 years agointernal: improve compilation critical path a bit
Aleksey Kladov [Sat, 28 Aug 2021 19:03:06 +0000 (22:03 +0300)]
internal: improve compilation critical path a bit

2 years agoremove unused serde feature from smol_str
Aleksey Kladov [Sat, 28 Aug 2021 17:41:22 +0000 (20:41 +0300)]
remove unused serde feature from smol_str

2 years agointernal: more production-ready proc-macro RPC deserialization
Aleksey Kladov [Sat, 28 Aug 2021 17:36:41 +0000 (20:36 +0300)]
internal: more production-ready proc-macro RPC deserialization

* avoid arbitrary nested JSON tree (danger of stack overflow)
* use more compact representation.

2 years agoMerge #10062
bors[bot] [Sat, 28 Aug 2021 14:48:46 +0000 (14:48 +0000)]
Merge #10062

10062: Set esbuild target as node14 r=matklad a=mtsmfm

ref: https://github.com/rust-analyzer/rust-analyzer/pull/10061

Currently, target version is not specified so it's esnext.

https://esbuild.github.io/api/#target

VSCode uses node 14 since version 1.56.

https://github.com/rust-analyzer/rust-analyzer/issues/3167#issuecomment-907058367

Co-authored-by: Fumiaki MATSUSHIMA <mtsmfm@gmail.com>
2 years agoSet esbuild target as node14
Fumiaki MATSUSHIMA [Sat, 28 Aug 2021 14:10:35 +0000 (14:10 +0000)]
Set esbuild target as node14

2 years agoMerge #10025
bors[bot] [Sat, 28 Aug 2021 14:14:54 +0000 (14:14 +0000)]
Merge #10025

10025: Don't mutate syntax trees when preparing proc-macro input r=Veykril a=Veykril

Fixes #10013

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #10059
bors[bot] [Fri, 27 Aug 2021 21:22:35 +0000 (21:22 +0000)]
Merge #10059

10059: feat: Enable diagnostics in `const` and `static` items r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoEnable diagnostics in `const` and `static` items
Jonas Schievink [Fri, 27 Aug 2021 21:21:21 +0000 (23:21 +0200)]
Enable diagnostics in `const` and `static` items

2 years agoMerge #10044
bors[bot] [Fri, 27 Aug 2021 20:19:56 +0000 (20:19 +0000)]
Merge #10044

10044: minor: Ignore text and bench attributes again r=Veykril a=Veykril

Reverts part of #9943

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoIgnore text and bench attributes again
Lukas Wirth [Thu, 26 Aug 2021 13:11:55 +0000 (15:11 +0200)]
Ignore text and bench attributes again

2 years agoMerge #9970
bors[bot] [Fri, 27 Aug 2021 19:30:36 +0000 (19:30 +0000)]
Merge #9970

9970: feat: Implement attribute input token mapping, fix attribute item token mapping r=Veykril a=Veykril

![image](https://user-images.githubusercontent.com/3757771/130328577-4c1ad72c-51b1-47c3-8d3d-3242ec44a355.png)

The token mapping for items with attributes got overwritten partially by the attributes non-item input, since attributes have two different inputs, the item and the direct input both.
This PR gives attributes a second TokenMap for its direct input. We now shift all normal input IDs by the item input maximum(we maybe wanna swap this see below) similar to what we do for macro-rules/def. For mapping down we then have to figure out whether we are inside the direct attribute input or its item input to pick the appropriate mapping which can be done with some token range comparisons.

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #10057
bors[bot] [Fri, 27 Aug 2021 18:00:37 +0000 (18:00 +0000)]
Merge #10057

10057: fix: Remove incorrect assertion in extract_function r=Veykril a=Veykril

This assertion is actually just wrong
Fixes #10056
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRemove incorrect assertion in extract_function
Lukas Wirth [Fri, 27 Aug 2021 17:58:50 +0000 (19:58 +0200)]
Remove incorrect assertion in extract_function

2 years agoMerge #10055
bors[bot] [Fri, 27 Aug 2021 13:11:34 +0000 (13:11 +0000)]
Merge #10055

10055: fix: Don't use fake text range in original node search as is in completions r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10042
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoDon't use fake text range in original node search as is in completions
Lukas Wirth [Fri, 27 Aug 2021 13:10:42 +0000 (15:10 +0200)]
Don't use fake text range in original node search as is in completions

2 years agoMerge #10054
bors[bot] [Fri, 27 Aug 2021 12:21:46 +0000 (12:21 +0000)]
Merge #10054

10054: minor: Ignore text and bench attributes again r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/8518#issuecomment-907039593
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoAdd completion tests for cursor after items
Lukas Wirth [Fri, 27 Aug 2021 12:20:32 +0000 (14:20 +0200)]
Add completion tests for cursor after items

2 years agoMerge #10053
bors[bot] [Fri, 27 Aug 2021 09:46:25 +0000 (09:46 +0000)]
Merge #10053

10053: Remove old workaround in vscode extension r=lnicola a=Azorlogh

See #3167.

Co-authored-by: = <bott.alix@gmail.com>
2 years agoremove workaround from old node versions
= [Fri, 27 Aug 2021 09:31:25 +0000 (11:31 +0200)]
remove workaround from old node versions

2 years agoMerge #10049
bors[bot] [Thu, 26 Aug 2021 19:14:09 +0000 (19:14 +0000)]
Merge #10049

10049: minor: nicer way to defeat disjoint closure captures r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: nicer way to defeat disjoint closure captures
Aleksey Kladov [Thu, 26 Aug 2021 19:11:54 +0000 (22:11 +0300)]
minor: nicer way to defeat disjoint closure captures

Thanks https://internals.rust-lang.org/t/feature-idea-edition-dependent-names-replacing-standard-library-items/15198/27?u=matklad!

2 years agoExtend `CargoConfig.unset_test_crates` to allow for efficiently disabling `#[cfg...
Vincent Esche [Mon, 23 Aug 2021 17:18:11 +0000 (19:18 +0200)]
Extend `CargoConfig.unset_test_crates` to allow for efficiently disabling `#[cfg(test)]` on all crates without having to first load the crate graph

2 years agoMerge #10032
bors[bot] [Thu, 26 Aug 2021 09:33:12 +0000 (09:33 +0000)]
Merge #10032

10032: Fix missing unsafe block for the nightly change r=lnicola a=oxalica

Fix #10022

Tested via vscode extension.

Co-authored-by: oxalica <oxalicc@pm.me>
2 years agoFix missing unsafe block for the nightly change
oxalica [Thu, 26 Aug 2021 08:42:45 +0000 (16:42 +0800)]
Fix missing unsafe block for the nightly change

Fix #10022

2 years agoMerge #10030
bors[bot] [Thu, 26 Aug 2021 01:34:30 +0000 (01:34 +0000)]
Merge #10030

10030: fix: Fix multiple derives in one attribute not expanding all in expand_macro r=Veykril a=Veykril

It's probably better to only expand the exact derive the cursor is on(if possible) instead of all derives in the attribute the cursor is one.
follow up to #10029
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix multiple derives in one attribute not expanding all in expand_macro
Lukas Wirth [Thu, 26 Aug 2021 01:32:34 +0000 (03:32 +0200)]
fix: Fix multiple derives in one attribute not expanding all in expand_macro

2 years agoMerge #10029
bors[bot] [Thu, 26 Aug 2021 00:39:00 +0000 (00:39 +0000)]
Merge #10029

10029: internal: Improve expand_macro r=Veykril a=Veykril

- Adds a few more newlines to the output making it more readable
- Fixes a bug with multiple derives not being expandable

There seems to be an issue with multiple derives in one attribute only showing the expansion of the last derive which I'll have to investigate.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoImprove expand_macro
Lukas Wirth [Thu, 26 Aug 2021 00:36:33 +0000 (02:36 +0200)]
Improve expand_macro

2 years agoAdd simple test for syntax_node_to_token_tree_censored
Lukas Wirth [Wed, 25 Aug 2021 17:22:22 +0000 (19:22 +0200)]
Add simple test for syntax_node_to_token_tree_censored

2 years agoMerge #10024
bors[bot] [Wed, 25 Aug 2021 17:40:57 +0000 (17:40 +0000)]
Merge #10024

10024: fix: Fix reporting of build script errors r=matklad a=jonas-schievink

r? `@matklad` (mostly to double-check that the redundant code I removed was, in fact, redundant)

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9864
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10023

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoDon't mutate syntax trees when preparing proc-macro input
Lukas Wirth [Wed, 25 Aug 2021 16:57:24 +0000 (18:57 +0200)]
Don't mutate syntax trees when preparing proc-macro input

2 years agoReduce visibility of `WorkspaceBuildScripts::run`
Jonas Schievink [Wed, 25 Aug 2021 16:02:27 +0000 (18:02 +0200)]
Reduce visibility of `WorkspaceBuildScripts::run`

2 years agoFix reporting of build script errors
Jonas Schievink [Wed, 25 Aug 2021 15:56:39 +0000 (17:56 +0200)]
Fix reporting of build script errors

2 years agoDon't fetch build script output twice
Jonas Schievink [Wed, 25 Aug 2021 15:56:24 +0000 (17:56 +0200)]
Don't fetch build script output twice

2 years agointernal: more declarative re-indentation API
Aleksey Kladov [Tue, 24 Aug 2021 15:18:43 +0000 (18:18 +0300)]
internal: more declarative re-indentation API

2 years agoMerge #10014
bors[bot] [Tue, 24 Aug 2021 14:58:02 +0000 (14:58 +0000)]
Merge #10014

10014: feat: Expand derive macros under cursor in `Expand Macro Recursively` r=Veykril a=Veykril

Expands the derive macros under the cursor if it is one a derive attribute, with this the feature should be basically feature complete I believe(except for the whitespace problem ofc)?

Actually this might interact a bit funky with items that have attributes ***and*** derives since we don't descend the cursor token into macro invocations first, for obvious reasons. So I expected trying to expand a derive in that case will either just expand the attributes on the item or fail in general.

Closes https://github.com/rust-analyzer/rust-analyzer/issues/4005

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoExpand derive macros under cursor in `Expand Macro Recursively`
Lukas Wirth [Tue, 24 Aug 2021 14:33:52 +0000 (16:33 +0200)]
Expand derive macros under cursor in `Expand Macro Recursively`

2 years agoMerge #9944
bors[bot] [Tue, 24 Aug 2021 13:11:50 +0000 (13:11 +0000)]
Merge #9944

9944: internal: introduce in-place indenting API r=matklad a=iDawer

Introduce `edit_in_place::Indent` that uses mutable tree API and intended to replace `edit::AstNodeEdit`.

Closes #9903

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2 years agoMerge #9993
bors[bot] [Tue, 24 Aug 2021 12:14:25 +0000 (12:14 +0000)]
Merge #9993

9993: feat: join lines merges assignments r=matklad a=unexge

Closes https://github.com/rust-analyzer/rust-analyzer/issues/9967.
![Peek 2021-08-22 21-46](https://user-images.githubusercontent.com/16212576/130366571-3ebb1753-f8d5-4884-be8f-222cda71a2a7.gif)

Co-authored-by: unexge <unexge@gmail.com>
2 years agoMerge #10011
bors[bot] [Tue, 24 Aug 2021 11:39:49 +0000 (11:39 +0000)]
Merge #10011

10011: minor: remove dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: remove dead code
Aleksey Kladov [Tue, 24 Aug 2021 11:39:31 +0000 (14:39 +0300)]
minor: remove dead code

2 years agoMerge #10010
bors[bot] [Tue, 24 Aug 2021 11:10:09 +0000 (11:10 +0000)]
Merge #10010

10010: internal: use idiomatic form of assertions r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: use idiomatic form of assertions
Aleksey Kladov [Tue, 24 Aug 2021 10:13:38 +0000 (13:13 +0300)]
internal: use idiomatic form of assertions

Ideally, we should just return an InvalidParameter dialog here, but that
shows error message to the end user, and we generally avoid that

2 years agoMerge #9994
bors[bot] [Tue, 24 Aug 2021 09:26:52 +0000 (09:26 +0000)]
Merge #9994

9994: add static method generation assist r=matklad a=mahdi-frms

Adds feature: #9948

Will soon send a GIF for the changelog.

Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2 years agoMerge #10008
bors[bot] [Tue, 24 Aug 2021 01:16:44 +0000 (01:16 +0000)]
Merge #10008

10008: feat: Highlight declarations and references for both defs in field shorthands r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoHighlight declarations and references for both defs in field shorthands
Lukas Wirth [Tue, 24 Aug 2021 01:14:03 +0000 (03:14 +0200)]
Highlight declarations and references for both defs in field shorthands

2 years agoMerge #10001
bors[bot] [Mon, 23 Aug 2021 22:19:50 +0000 (22:19 +0000)]
Merge #10001

10001: Sort enum variant r=Veykril a=vsrs

A small fix to the problem noted by `@lnicola` :

> ![sort-fields](https://user-images.githubusercontent.com/308347/129513196-4ffc7937-be58-44d4-9ec7-ba8745dcb460.gif)
>
> (note the slight inconsistency here: to sort the variants of `Animal` I have to select the enum name, but to sort the fields of `Cat` I have to select the fields themselves)

Co-authored-by: vsrs <vit@conrlab.com>
2 years agoMerge #10004
bors[bot] [Mon, 23 Aug 2021 21:23:17 +0000 (21:23 +0000)]
Merge #10004

10004: ⬆️ rowan r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years ago⬆️ rowan
Lukas Wirth [Mon, 23 Aug 2021 21:22:31 +0000 (23:22 +0200)]
⬆️ rowan

2 years agoMerge #10003
bors[bot] [Mon, 23 Aug 2021 18:19:42 +0000 (18:19 +0000)]
Merge #10003

10003: :arrow_up: rowan r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years ago:arrow_up: rowan
Aleksey Kladov [Mon, 23 Aug 2021 18:07:23 +0000 (21:07 +0300)]
:arrow_up: rowan

This pulls in https://github.com/rust-analyzer/rowan/pull/111, which
fixes a bug in green node hash, making it more efficient.

On analysis stats, total memory goes from 1271mb to 1244mb, instructions
from 358ginstr to 353ginstr (not 100% clear on this one -- for some
reasons instruction counts are not stable for me anymore).

The counts are (before, than after):

rowan::green::node::GreenNode       11_490_596    2_357_063    2_233_347
rowan::green::token::GreenToken      5_010_401      994_281      991_920

rowan::green::node::GreenNode        9_738_085    1_988_164    1_890_549
rowan::green::token::GreenToken      3_353_409      687_333      685_831
                                         total     max_live         live

2 years agoSort enum variant
vsrs [Mon, 23 Aug 2021 17:31:54 +0000 (20:31 +0300)]
Sort enum variant