Commit Graph

18951 Commits

Author SHA1 Message Date
Oliver Cooper
0517247bbc Don't filter cargo tasks by scope
Fixes #9093
2021-08-31 20:35:22 +12:00
bors[bot]
20f3792d10
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>
2021-08-30 19:35:00 +00:00
bors[bot]
02a3d898e4
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>
2021-08-30 18:55:18 +00:00
nathan.whitaker
e1d86a42fe Add coverage mark for struct init shorthand test 2021-08-30 14:37:03 -04:00
Akshay
e304a623ad fix minor mispelling
find_map misspelt as wind_map
2021-08-30 22:51:14 +05:30
bors[bot]
5c704f11d2
Merge #10088
10088: feat: improve CPU usage r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 16:49:13 +00:00
Aleksey Kladov
53d2050085 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).
2021-08-30 19:48:16 +03:00
Aleksey Kladov
9e0203bd69 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.
2021-08-30 19:39:08 +03:00
Aleksey Kladov
a59f344c4f internal: improve consistency
Let's have only one place where we start delayed ops
2021-08-30 19:24:31 +03:00
Aleksey Kladov
6317292cd5 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!
2021-08-30 19:18:48 +03:00
bors[bot]
bb1987b45e
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>
2021-08-30 12:57:39 +00:00
Aleksey Kladov
4452f9ec48 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...
2021-08-30 15:55:40 +03:00
Aleksey Kladov
8dc3b46017 fix: avoid panic when parsing extern block
closes #10083
2021-08-30 15:40:47 +03:00
bors[bot]
cbae596941
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>
2021-08-30 09:50:16 +00:00
Mario Carneiro
b22eb02f8b
fail -> failed 2021-08-30 02:47:10 -07:00
Mario Carneiro
2d349aed2e
Update crates/hir_expand/src/db.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-08-30 02:43:13 -07:00
Mario Carneiro
6e8dedadcd
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.
2021-08-30 02:36:21 -07:00
bors[bot]
1636f61a15
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>
2021-08-30 08:42:13 +00:00
bors[bot]
d250aa77ec
Merge #10015
10015: internal: more declarative re-indentation API r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 08:34:49 +00:00
bors[bot]
ceecf853ee
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>
2021-08-30 07:58:59 +00:00
Aleksey Kladov
a833fba98a 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!
2021-08-30 10:58:39 +03:00
bors[bot]
b3452dd379
Merge #10079
10079: internal: make upstream bug less annoying r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 07:39:34 +00:00
Aleksey Kladov
3a055a6b1f internal: make upstream bug less annoying 2021-08-30 10:32:59 +03:00
bors[bot]
43ed5368d2
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>
2021-08-30 07:30:01 +00:00
Dezhi Wu
ba0947dded switch log crate to tracing 2021-08-30 15:11:42 +08:00
bors[bot]
c41870076b
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>
2021-08-30 06:54:36 +00:00
Laurențiu Nicola
878dd9d3ad Use Ubuntu 18.04 on CI 2021-08-30 09:50:41 +03:00
nathan.whitaker
e4757f9407 Update existing fill struct fields test 2021-08-29 13:14:15 -04:00
nathan.whitaker
251f9dfc8a Add tests for fill struct fields shorthand 2021-08-29 13:14:03 -04:00
nathan.whitaker
dcd4157420 Use struct init shorthand in fill struct fields assist 2021-08-29 13:12:59 -04:00
bors[bot]
d15f646ff1
Merge #10074
10074: internal: improve compile times a bit r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-29 15:56:06 +00:00
Aleksey Kladov
cfa3f679e9 internal: don't expose impl details out of hir 2021-08-29 18:55:25 +03:00
Aleksey Kladov
76b60efbfb 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
2021-08-29 18:49:16 +03:00
bors[bot]
35d98070d2
Merge #10071
10071: internal: slightly improve compile times r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-29 09:54:33 +00:00
Aleksey Kladov
78365c64c8 internal: slightly improve compile times
As per style guide, avoid monomorphisations
2021-08-29 12:53:56 +03:00
Aleksey Kladov
bef5e3096e minor: remove debug print 2021-08-29 12:33:07 +03:00
bors[bot]
7c7a41c5e9
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>
2021-08-28 23:38:34 +00:00
Lukas Wirth
6993a607cb Simplify 2021-08-29 01:38:10 +02:00
Lukas Wirth
99f1e66997 Only report unique text ranges in highlight_related 2021-08-29 01:11:29 +02:00
Lukas Wirth
72bfbb0691 Return all usages inside macros in usage searches 2021-08-29 00:49:57 +02:00
Lukas Wirth
512135920d Highlight all related tokens in macro inputs 2021-08-29 00:49:57 +02:00
Lukas Wirth
c5059e0623 Return all ranges corresponding to a token id in TokenMap 2021-08-29 00:49:57 +02:00
bors[bot]
7e31c5ec0d
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>
2021-08-28 21:13:18 +00:00
Jonas Schievink
002ef7d50a Use ManuallyDrop in RootDatabase 2021-08-28 23:05:40 +02:00
bors[bot]
10e9408d38
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>
2021-08-28 20:38:58 +00:00
Aleksey Kladov
0d5c671d76 minor: reformat 2021-08-28 23:38:39 +03:00
Aleksey Kladov
c639fe333f internal: improve compilation critical path a bit 2021-08-28 22:43:37 +03:00
Aleksey Kladov
0dabcf0044 remove unused serde feature from smol_str 2021-08-28 22:43:37 +03:00
Aleksey Kladov
55e9476e4b internal: more production-ready proc-macro RPC deserialization
* avoid arbitrary nested JSON tree (danger of stack overflow)
* use more compact representation.
2021-08-28 22:43:37 +03:00
bors[bot]
2e3322d3f5
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>
2021-08-28 14:48:46 +00:00