Commit graph

11029 commits

Author SHA1 Message Date
Jonas Schievink
f04f38d3d7 nameres: collect unnamed consts 2021-04-07 03:12:40 +02:00
memoryruins
e1e6e3b925 Fix typo 2021-04-06 19:38:59 -04:00
memoryruins
c201cce527 Do not import on the fly during fields of record literal syntax 2021-04-06 18:40:06 -04:00
bors[bot]
a35f7cb635
Merge #8382
8382: Make Fixture docs more accessible and fix small doc issues r=SomeoneToIgnore a=SomeoneToIgnore

Follow up of https://github.com/rust-analyzer/rust-analyzer/pull/8302#discussion_r607054896

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-04-06 22:23:41 +00:00
Florian Diebold
b03969cda9 Remove SolutionVariables, add ConstrainedSubst analogous to Chalk
... just missing the constraints.
2021-04-06 23:46:32 +02:00
bors[bot]
31d2b3b9cb
Merge #8386
8386: Avoid O(n²) when constructing AttrSourceMap r=jonas-schievink a=jonas-schievink

Brings https://github.com/rust-analyzer/rust-analyzer/issues/8377 down to 2.52s on my machine. Not quite back to where it was before, so I'll leave that issue open for now.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-06 20:26:52 +00:00
Jonas Schievink
035d84558c Avoid O(n²) when constructing AttrSourceMap 2021-04-06 22:25:44 +02:00
Florian Diebold
768ee3e47a Align InferenceVar to Chalk 2021-04-06 21:10:22 +02:00
Florian Diebold
d280538174 Clean up Chalk mapping a bit 2021-04-06 21:10:22 +02:00
Kirill Bulatov
e785672f15 Adjust fixture docs a bit 2021-04-06 21:42:27 +03:00
Jonas Schievink
0d4c931416 Lower attributes on tuple fields 2021-04-06 20:19:53 +02:00
Jonas Schievink
230c763648 infer: remove record_pat_field_resolutions field
Same as https://github.com/rust-analyzer/rust-analyzer/pull/8376, this
can be computed from other data
2021-04-06 19:44:28 +02:00
bors[bot]
e6a1c9ca60
Merge #8371
8371: Don't use HirDisplayWrapper when displaying SourceCode r=matklad a=Veykril

The issue was basically that when displaying for `DisplayTarget::SourceCode` some `hir_fmt` functions would create `HirDisplayWrapper`s which would then `fmt` these triggering the Display panic since `fmt::Display` can't fail the same way as `HirDisplay`. Simple fix is to just use `hir_fmt` directly. Should probably write that down somewhere in source, looking for a good spot to put that right now.

Fixes #8077, Fixes #8370


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-06 16:12:30 +00:00
Jonas Schievink
e9752308bb infer: remove record_field_resolutions field
It stores no useful data, since we can derive all fields from
`variant_resolutions`
2021-04-06 17:59:18 +02:00
bors[bot]
74711deb72
Merge #8375
8375: feat: show errors from `cargo metadata` and initial `cargo check` in the status bar r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-06 15:09:38 +00:00
Aleksey Kladov
de33702784 feat: show errors from cargo metadata and initial cargo check in the status bar
closes #3155
2021-04-06 18:08:05 +03:00
Jonas Schievink
a25fbdb30a Intern TypeRefs stored in Body
Minor improvement to memory usage (1 MB or so)
2021-04-06 16:07:45 +02:00
bors[bot]
7d39b13996
Merge #8364
8364: Memory usage improvements r=jonas-schievink a=alexmaco

These are mostly focused on splitting up enum variants with large size differences between variants by `Box`-ing things up.

In my testing this reduces the memory usage somewhere in the low percentages, even though the measurements are quite noisy.

Co-authored-by: Alexandru Macovei <alexnmaco@gmail.com>
2021-04-06 13:43:37 +00:00
bors[bot]
12e86433ab
Merge #8368
8368: Move Ty accessors to TyExt r=flodiebold a=Veykril

CC #8313

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-06 13:32:15 +00:00
Aleksey Kladov
9ec5e6e4fd Clearer naming 2021-04-06 16:22:26 +03:00
Alexandru Macovei
4e2a6ac7ea Avoid duplicating VfsPath in vfs::path_interner::PathInterner by using an IndexSet 2021-04-06 16:03:57 +03:00
Alexandru Macovei
32304d14a1 Use Box'es to reduce the size of hir_def::expr::Pat from 112 to 64 bytes on 64bit 2021-04-06 16:01:31 +03:00
Alexandru Macovei
fb1f544e24 Use Box'es to reduce size of hir_def::expr::Expr from 128 to 72 bytes (on 64bit systems)
Rationale: only a minority of variants used almost half the size.
By keeping large members (especially in Option) behind a box
the memory cost is only payed when the large variants are needed.

This reduces the size Vec<Expr> needs to allocate.
2021-04-06 16:01:31 +03:00
bors[bot]
4414071074
Merge #8355
8355: internal: do not drop errors from cargo metadata/check r=matklad a=matklad

Work towards #3155

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-06 12:50:25 +00:00
Aleksey Kladov
8fe20b19d4 More robust status notifications 2021-04-06 15:45:31 +03:00
Lukas Wirth
a43409fa43 Panic when creating a HirDisplayWrapper with DisplayTarget::SourceCode 2021-04-06 14:42:34 +02:00
Lukas Wirth
ffdb2da49d Don't use HirDisplayWrapper when displaying SourceCode 2021-04-06 14:21:35 +02:00
Lukas Wirth
bc993bbe85 Remove TyExt::dyn_trait_ref 2021-04-06 13:58:51 +02:00
Lukas Wirth
9b4699a9be Move Ty accessors to TyExt 2021-04-06 13:58:48 +02:00
Aleksey Kladov
9143e3925c Prepare for more stateless status reporting 2021-04-06 13:23:09 +03:00
Aleksey Kladov
e3c47ccefc Use autoreload config to gate execution rather that staleness 2021-04-06 13:10:50 +03:00
Lukas Wirth
9fbba7bc45 Add chalk_ir::Const to TyKind::Array 2021-04-06 11:45:41 +02:00
Aleksey Kladov
3698b3eab8 Avoid duplicate cargo checks 2021-04-06 12:40:31 +03:00
Aleksey Kladov
9ca59733e3 Improve readability
It's better to order functions in the order they are called, if there's
ordering between them.
2021-04-06 12:35:40 +03:00
Aleksey Kladov
aaa8c208b1 internal: do not drop errors from cargo metadata/check
Work towards #3155
2021-04-06 12:33:19 +03:00
Lukas Wirth
08dc69599e Use a constructor function for Static lifetimes 2021-04-06 10:50:55 +02:00
Lukas Wirth
b98c681cb7 Always use Static lifetimes in chalk mapping 2021-04-06 10:45:34 +02:00
Lukas Wirth
9da191c7e0 Add Lifetime to DynTy 2021-04-06 10:45:34 +02:00
Lukas Wirth
96756f1b1d Add Lifetime to TyKind::Ref 2021-04-06 10:45:30 +02:00
Florian Diebold
1ae967bf8e Fix shifting of binders in FnPointer
- don't shift in/out for Chalk mapping (we want to have the same
   binders now)
 - do shift in when creating the signature for a closure (though it
   shouldn't matter much)
 - do shift in when lowering a `fn()` type
 - correctly deal with the implied binder in TypeWalk
2021-04-05 23:00:50 +02:00
Florian Diebold
edc59d897d Align FnPointer with Chalk 2021-04-05 22:23:30 +02:00
Florian Diebold
b67148daea Substitution::prefix -> subst_prefix
I probably want to get rid of this function completely later.
2021-04-05 21:58:53 +02:00
Florian Diebold
2a83645e1b Get rid of Substitution::suffix 2021-04-05 21:58:03 +02:00
Florian Diebold
b443e5304e Remove some unused methods, move some to types.rs 2021-04-05 21:58:03 +02:00
Florian Diebold
738174671a Binders::wrap_empty -> wrap_empty_binders 2021-04-05 21:58:03 +02:00
Florian Diebold
2f5a77658b Substitution::single -> from1 2021-04-05 21:58:03 +02:00
Florian Diebold
788533d380 Move ProjectionTy methods to extension trait 2021-04-05 21:58:01 +02:00
bors[bot]
8c96a7d81e
Merge #8353
8353: Replace hir_ty::Lifetime with chalk equivalent r=flodiebold a=Veykril

Our `Lifetime` isn't really used yet so this is a rather simple change

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-05 19:34:50 +00:00
bors[bot]
72781085bb
Merge #8352
8352: Remove dead legacy macro expansion code r=lnicola a=brandondong

I was investigating some unrelated macro issue when I noticed this dead code. This legacy macro expansion logic was changed in https://github.com/rust-analyzer/rust-analyzer/pull/8128.

Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-04-05 19:00:27 +00:00
Brandon
4dbec2d545 Remove dead legacy macro expansion code 2021-04-05 11:47:06 -07:00
Lukas Wirth
d587ca2991 Replace unused hir_ty::Lifetime with chalk equivalents 2021-04-05 20:46:15 +02:00
bors[bot]
453f2360d3
Merge #8351
8351: Use more assoc. type aliases in the chalk interner r=flodiebold a=jonas-schievink

Makes it sligthly easier to swap out these types

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-05 18:38:32 +00:00
Jonas Schievink
f48dd154a5 Use more assoc. type aliases in the chalk interner
Makes it sligthly easier to swap out these types
2021-04-05 20:15:07 +02:00
bors[bot]
87e56eb94c
Merge #8350
8350: internal: prepare to store OpQueue results in the queue itself r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-05 17:49:48 +00:00
Aleksey Kladov
7099438e0c internal: prepare to store OpQueue results in the queue itself 2021-04-05 20:49:00 +03:00
bors[bot]
c91b537683
Merge #8348
8348: Make `Binders` more like Chalk r=flodiebold a=flodiebold

Working towards #8313.
 - hide `value`
 - use `VariableKinds`
 - adjust `subst` to be like Chalk's `substitute`
 - also clean up some other `TypeWalk` stuff to prepare for it being replaced by Chalk's `Fold`

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-05 17:25:19 +00:00
Florian Diebold
a316d58360 Rename shift_bound_vars{_out} to align with Chalk 2021-04-05 19:21:03 +02:00
Florian Diebold
fbab69cbff Get rid of subst_bound_vars uses 2021-04-05 19:21:03 +02:00
Florian Diebold
e28f0c98ba Get rid of some walk_mut uses 2021-04-05 19:21:03 +02:00
Florian Diebold
30a339e038 Add Interner parameter to Binders::substitute 2021-04-05 19:21:01 +02:00
Florian Diebold
05eba0db3d Binders::subst -> substitute 2021-04-05 19:20:28 +02:00
Florian Diebold
ad20f00844 Use VariableKinds in Binders 2021-04-05 19:19:18 +02:00
Florian Diebold
69714d36e6 Hide Binders internals more 2021-04-05 19:19:18 +02:00
bors[bot]
467a5c6cd1
Merge #8347
8347: Minor interning improvements r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-05 17:17:07 +00:00
kjeremy
b246f57fad Use arrayvec 0.7 to avoid perf regression in 0.6.1
See: https://github.com/bluss/arrayvec/issues/182
2021-04-05 12:58:35 -04:00
Jonas Schievink
b57462d60d Interned<T>: Only hash the pointer 2021-04-05 17:07:53 +02:00
Jonas Schievink
a0b50bcf1e Make impl_internable! macro public 2021-04-05 16:59:13 +02:00
Laurențiu Nicola
d7546d8c23 Pass interner to TraitRef::self_type_parameter 2021-04-05 17:38:37 +03:00
Laurențiu Nicola
aefcbf2758 Pass interner to ProjectionTy::self_type_parameter 2021-04-05 17:37:24 +03:00
bors[bot]
fab1c06646
Merge #8343
8343: internal: document hypothetical completion problem r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-05 13:28:32 +00:00
Aleksey Kladov
1f00191de2 internal: document hypothetical completion problem 2021-04-05 16:27:45 +03:00
bors[bot]
8a18f23df0
Merge #8342
8342: Rename `TyKind::Unknown` and `TyKind::ForeignType` (Chalk move) r=flodiebold a=lnicola

CC #8313

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-04-05 13:05:35 +00:00
Laurențiu Nicola
72c54c53cd Rename TyKind::ForeignType to Foreign 2021-04-05 15:39:06 +03:00
Laurențiu Nicola
65c2e51940 Rename TyKind::Unknown to Error 2021-04-05 15:39:06 +03:00
bors[bot]
c2be91dcd8
Merge #8245
8245: Properly resolve intra doc links in hover and goto_definition r=matklad a=Veykril

Unfortunately involves a bit of weird workarounds due to pulldown_cmark's incorrect lifetimes on `BrokenLinkCallback`... I should probably open an issue there asking for the fixes to be pushed to a release since they already exist in the repo for quite some time it seems.

Fixes #8258, Fixes #8238

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-05 12:30:20 +00:00
bors[bot]
d8ee25bb97
Merge #8339
8339: fix: extract variable works in guards r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-05 12:19:25 +00:00
Aleksey Kladov
30d6419bc9 fix: extract variable works in guards
closes #8336
2021-04-05 14:40:56 +03:00
bors[bot]
4a589b1c3a
Merge #8326
8326: Rewrite reorder fields assist to use mutable syntax trees r=matklad a=Veykril

This also instead uses `Either` to use the typed `RecordPat` and `RecordExpr` nodes, this unfortunately gives a bit of code duplication

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-05 11:23:12 +00:00
Aleksey Kladov
a01fd1af19 internal: explain "extract if condition" refactoring 2021-04-05 13:02:47 +03:00
Jonas Schievink
6f1ee9a7f4 simplify visibility.rs 2021-04-05 04:27:57 +02:00
Jonas Schievink
7c0c713a10 Intern GenericParams
Also share the same instance between `ItemTree` and `generic_params`
query.
2021-04-05 03:50:10 +02:00
Jonas Schievink
adcf18e27d Add GenericParams::shrink_to_fit
Reduces memory usage by over 10 MB
2021-04-05 03:32:43 +02:00
Jonas Schievink
24e876b52e Intern more TypeRefs in generics
Saves ~3 MB
2021-04-05 02:03:37 +02:00
Jonas Schievink
ab49f762a9 analysis-stats: allow skipping type inference
This removes "noise" from memory profiles since it avoids lowering
function bodies and types
2021-04-05 01:42:19 +02:00
Jonas Schievink
d3b804d11d Error when rustfmt component is unavailable 2021-04-05 00:33:11 +02:00
bors[bot]
35614c7623
Merge #8328
8328: Move things in hir_ty into submodules r=flodiebold a=flodiebold

 - all the types that will be replaced by Chalk go to `types`
 - `TypeWalk` impls go to `walk`
 - also fix signature of `Substitution::interned`

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-04 18:29:53 +00:00
Florian Diebold
645a9c3a27 Move things from traits module to types as well 2021-04-04 20:27:40 +02:00
Florian Diebold
508a1ecad3 Move things in hir_ty into submodules
- all the types that will be replaced by Chalk go to `types`
 - `TypeWalk` impls go to `walk`
2021-04-04 20:22:00 +02:00
bors[bot]
0924888cce
Merge #8325
8325: Check if bitflags deps pulls its weight r=jonas-schievink a=matklad

Bitflags is generally a good dependency -- it's lightweight, well
maintained and embraced by the ecosystem.

I wonder, however, do we really need it? Doesn't feel like it adds much
to be honest.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-04 15:42:19 +00:00
bors[bot]
bc8b278841
Merge #8295
8295: Add `convert_into_to_from` assist r=Veykril a=obmarg

This adds a "Convert Into to From" assist, useful since clippy has
recently started adding lints on every `Into`.

It covers converting the signature, and converting any `self`/`Self`
references within the body.

It does assume that every instance of `Into` can be converted to a
`From`, which I _think_ is the case now.  Let me know if there's
something I'm not thinking of and I can try and make it smarter.

Closes #8196 

![CleanShot 2021-04-02 at 13 39 54](https://user-images.githubusercontent.com/556490/113420108-9ce21c00-93c0-11eb-8c49-80b5fb189284.gif)

I'm extremely new to this codebase so please let me know if anything needs
changed.

Co-authored-by: Graeme Coupar <grambo@grambo.me.uk>
2021-04-04 11:38:20 +00:00
Florian Diebold
cde3857897 Add comment 2021-04-04 13:23:22 +02:00
Florian Diebold
ebdfc932e7 Replace Substitution::type_params 2021-04-04 13:16:39 +02:00
Florian Diebold
a4d7bdf1c8 Replace Substitution::bound_vars and ::type_params_for_generics 2021-04-04 13:16:39 +02:00
Florian Diebold
715c178f0b Move TyBuilder to its own module 2021-04-04 13:16:39 +02:00
Florian Diebold
584d1c9e5b Replace last uses of SubstsBuilder by TyBuilder 2021-04-04 13:16:39 +02:00
Florian Diebold
505ca65216 Remove CallableSig::from_substs 2021-04-04 13:16:39 +02:00
Florian Diebold
ac8fee006a Use TyBuilder in another place 2021-04-04 13:16:38 +02:00
Florian Diebold
eaa03ef446 Some more TyBuilder use 2021-04-04 13:16:38 +02:00
Florian Diebold
5d2b488aeb Replace remaining uses of Substitution::build_for_def 2021-04-04 13:16:38 +02:00
Florian Diebold
77333a571f More TyBuilder use 2021-04-04 13:16:38 +02:00
Florian Diebold
66fec39aa0 More TyBuilder use 2021-04-04 13:16:38 +02:00
Florian Diebold
cd227f581e Add and start using TraitRef and ProjectionTy builders 2021-04-04 13:16:38 +02:00
Florian Diebold
2ead65190e Move Ty::builtin to TyBuilder 2021-04-04 13:16:38 +02:00
Florian Diebold
620769f322 Add TyBuilder::adt 2021-04-04 13:16:38 +02:00
Florian Diebold
e6f007d9a8 Move Ty::fn_ptr to TyBuilder 2021-04-04 13:16:38 +02:00
Florian Diebold
b0fe3d929f Add TyBuilder::unit() and TyExt::is_unit() 2021-04-04 13:16:38 +02:00
Florian Diebold
b15152c430 Add TyBuilder 2021-04-04 13:16:38 +02:00
Aleksey Kladov
d1474ae518 Check if bitflags deps pulls its weight
Bitflags is generally a good dependency -- it's lightweight, well
maintained and embraced by the ecosystem.

I wonder, however, do we really need it? Doesn't feel like it adds much
to be honest.
2021-04-04 12:06:01 +03:00
bors[bot]
c9bcbf9a43
Merge #8324
8324: Add `Body::shrink_to_fit` r=jonas-schievink a=jonas-schievink

Saves ~15 MB

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-04 01:27:14 +00:00
Jonas Schievink
1da6d0bed9 Add Body::shrink_to_fit 2021-04-04 03:26:16 +02:00
Jonas Schievink
9b13e1bb91 Only remember blocks that have a DefMap 2021-04-04 03:16:26 +02:00
bors[bot]
4c8ee9a531
Merge #8322
8322: Access a body's block def maps via a method r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-04 01:04:44 +00:00
Jonas Schievink
d8bf9bef80 Access a body's block def maps via a method 2021-04-04 03:03:18 +02:00
Jonas Schievink
f774a56af2 Use exhaustive matches in shrink_to_fit impls 2021-04-04 02:56:11 +02:00
Jonas Schievink
3abcdc03ba Make ast_to_token_tree infallible
It could never return `None`, so reflect that in the return type
2021-04-04 01:46:45 +02:00
Jonas Schievink
613f9ea41e Glob-reexport hir_def database types 2021-04-04 01:29:59 +02:00
Jonas Schievink
d1bce6070d Use shrink_to_fit to reduce DefMap sizes 2021-04-03 23:45:27 +02:00
Jonas Schievink
ee4b5a34d8 Use bitflags to compress function properties
Very minor savings, only 1 MB or so
2021-04-03 20:58:42 +02:00
Jonas Schievink
f7e6b186e1 Intern ModPath in Import
Minor savings only
2021-04-03 20:57:25 +02:00
Lukas Wirth
df1320d8c4 Rewrite reorder fields assist to use mutable syntax trees 2021-04-03 17:22:16 +02:00
Graeme Coupar
ee03849017 Convert Into to From assist
This adds a "Convert Into to From" assist, useful since clippy has
recently started adding lints on every `Into`.

It covers converting the signature, and converting any `self`/`Self`
references within the body to the correct types.

It does assume that every instance of `Into` can be converted to a
`From`, which I _think_ is the case now.  Let me know if there's
something I'm not thinking of and I can try and make it smarter.
2021-04-03 15:48:35 +01:00
Florian Diebold
c551604b5a Rename Ty::interned to Ty::kind
... since that's the actual method on Chalk side that matches the signature.
2021-04-03 13:08:29 +02:00
Florian Diebold
e480d81988 Introduce GenericArg like in Chalk
Plus some more adaptations to Substitution.

Lots of `assert_ty_ref` that we should revisit when introducing
lifetime/const parameters.
2021-04-03 11:17:13 +02:00
Edwin Cheng
20d55ce44d Allow include! an empty content file 2021-04-03 12:50:55 +08:00
Edwin Cheng
b636080f67 Fix joinLines panic if run on the empty last line 2021-04-03 11:20:16 +08:00
Jonas Schievink
5742cdf3f1 Support #[rustc_builtin_macro = "builtin_name"] 2021-04-03 03:13:04 +02:00
Jonas Schievink
6198eb74b2 Implement edition-dependent builtin panic! macro 2021-04-03 03:12:55 +02:00
Jonas Schievink
eaffdae300 Allow , to delimit macro 2.0 rules 2021-04-03 03:08:31 +02:00
Jonas Schievink
85757be59a Allow interning strings 2021-04-03 01:00:45 +02:00
Jonas Schievink
e73d26fa62 Stop using an upgradeable read lock in interning
Only one upgradeable read lock can be handed out at the same time, and
we never acquire a non-upgradeable read lock, so this has no benefit
over just using a write lock in the first place.
2021-04-02 20:46:37 +02:00
Jonas Schievink
7ceaba21df Only populate prelude for crate-level DefMaps 2021-04-02 19:00:26 +02:00
bors[bot]
f4d56989b6
Merge #8284
8284: Reduce memory usage by using global `Arc`-based interning r=jonas-schievink a=jonas-schievink

This saves around 50 mb when running `analysis-stats` on r-a itself. Not a lot, but this infra can be easily reused to intern more stuff.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-02 16:43:16 +00:00
bors[bot]
9bcdbefc7b
Merge #8291
8291: Put the revision in the startup message r=jonas-schievink a=lf-



Co-authored-by: Jade <software@lfcode.ca>
2021-04-02 16:35:22 +00:00
Jonas Schievink
6e227b80a7 Remove ?Sized on PartialEq/Eq impls 2021-04-02 18:26:34 +02:00
Jonas Schievink
76452956e4 Split Intern::drop into hot and cold path 2021-04-02 18:11:08 +02:00
bors[bot]
d619070b83
Merge #8287
8287: Don't allocate in `associated_type_shorthand_candidates` r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-02 14:41:24 +00:00
Lukas Wirth
c24753ae5d Don't allocate in associated_type_shorthand_candidates 2021-04-02 16:40:31 +02:00
Aleksey Kladov
387d7c7d96 minor: add profile call for resolve_obligations 2021-04-02 15:28:51 +03:00
bors[bot]
00ce7ae524
Merge #8285
8285: Don't recheck obligations if we have learned nothing new r=matklad a=flodiebold

This is just the most trivial check: If no inference variables have been updated, and there are no new obligations, we can just skip trying to solve them again. We could be smarter about it, but this already helps quite a bit, and I don't want to touch this too much before we replace the inference table by Chalk's.

Fixes #8263 (well, improves it quite a bit).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-02 11:25:40 +00:00
Jade
feae14be11 Put the revision in the logged startup message 2021-04-02 02:53:56 -07:00
bors[bot]
ea8feca31a
Merge #8265
8265: Improve rustc diagnostic mapping r=jonas-schievink a=jonas-schievink

Try to mirror rustc diagnostics more closely by:

* Emitting hint-level diagnostics at *all* macro invocation sites that caused the diagnostic
  * Previously we emitted a copy of the diagnostic (not at hint level) at the last macro invocation site only
* Emitting the original diagnostic inside the macro, if it was caused by a macro
* Always including related information pointing to the invocation site or the macro, respectively (the old code contained a bug that would sometimes omit it)

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


![screenshot-2021-03-30-19:34:56](https://user-images.githubusercontent.com/1786438/113031484-1266a600-918f-11eb-9164-fed01c8ba37e.png)
![screenshot-2021-03-30-19:35:10](https://user-images.githubusercontent.com/1786438/113031486-12ff3c80-918f-11eb-8f15-9d7f23b69653.png)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2021-04-01 21:22:11 +00:00
bors[bot]
5ef0c7a213
Merge #8283
8283: Resolve associated types r=flodiebold a=Veykril

Prior we were only resolving paths until the first type was found, then discarding the result if the path wasn't fully consumed. That of course causes associated types to not resolve. Fixes #5003

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-01 21:11:06 +00:00
Jonas Schievink
0a8274dd46 Include remaining memory in memory usage stats 2021-04-01 23:01:07 +02:00
Jonas Schievink
afd83e0686 Remove unnecessary region, relax Sized bounds 2021-04-01 22:24:40 +02:00
Lukas Wirth
9fe10a9606 Resolve associated types with type anchors 2021-04-01 21:52:07 +02:00
Florian Diebold
0e8c4503bf Don't recheck obligations if we have learned nothing new
This is just the most trivial check: If no inference variables have been
updated, and there are no new obligations, we can just skip trying to
solve them again. We could be smarter about it, but this already helps
quite a bit, and I don't want to touch this too much before we replace
the inference table by Chalk's.

Fixes #8263 (well, improves it quite a bit).
2021-04-01 21:45:44 +02:00
Lukas Wirth
444f6caaba Resolve associated types 2021-04-01 21:31:25 +02:00
Jonas Schievink
39d992ef55 Intern Attr, MacroCall and Path components 2021-04-01 20:35:21 +02:00
Jonas Schievink
b00266b79f Global TypeRef/TraitRef interning 2021-04-01 19:46:43 +02:00
Jonas Schievink
608a4653a3 Check for and skip dummy macro files 2021-04-01 15:51:34 +02:00
Jonas Schievink
066330e953 Adjust message when pointing at location in macro 2021-04-01 14:44:20 +02:00
bors[bot]
25201b2dad
Merge #8274
8274: Adding a few more gifs and screenshots for features in manual r=Veykril a=MozarellaMan

Related  #8267,#6539. Gifs are [here](https://github.com/rust-analyzer/rust-analyzer/issues/6539#issuecomment-809574840)

Finishing up the last PR,  for the last two features that didn't have a visual example. 

For syntax highlighting, I wasn't able to find a theme that displayed the difference between an enum and struct, but I only tried a few apart from the default so there could be one out there! 

e.g., with the default light theme, `Ord` and `Ordering` in `use std::cmp::{Ord, Ordering}` had the same highlight colour. So I just went with displaying `mut` items being underlined.


Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
2021-04-01 00:01:40 +00:00
Edwin Cheng
6a3f2ce76c Fix block inner item defined in macro 2021-04-01 03:45:21 +08:00
Ayomide Bamidele
7bea1d8bfe Additional syntax highlighting screenshot in manual 2021-03-31 18:45:15 +01:00
Jonas Schievink
7c87e49638 Search for a suitable primary location 2021-03-31 17:50:19 +02:00
Ayomide Bamidele
4296cc3318 Gif of "let = " typing assist 2021-03-31 16:39:04 +01:00
Ayomide Bamidele
d82176c146 Gifs and screenshots for features in manual (syntax highlighting and typing) 2021-03-31 16:20:54 +01:00
Jonas Schievink
7723dd0909 Rename convert_location -> location 2021-03-31 17:18:21 +02:00
bors[bot]
75011bbccb
Merge #8210
8210: Implement "Extract type alias" assist r=jonas-schievink a=jonas-schievink



Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-31 12:26:57 +00:00
bors[bot]
aca9004c7e
Merge #8271
8271: Fix fail to parse u128  in proc-macro r=edwin0cheng a=edwin0cheng

fixes #8270

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-31 12:08:12 +00:00
Edwin Cheng
55a3364e35 Fix parse u128 bug in proc-macro 2021-03-31 19:50:36 +08:00
bors[bot]
b6e21a4ca4
Merge #8269
8269: internal: document semantics for missing names r=flodiebold a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-31 10:30:45 +00:00
Aleksey Kladov
5c0c09c9c3 internal: document semantics for missing names 2021-03-31 13:24:08 +03:00
bors[bot]
55d7d71590
Merge #8267
8267: Adding gifs and screenshots for features in manual r=matklad a=MozarellaMan

For #6539

This includes most of gif or screenshot examples of most items in the "Features" header. With the exceptions of:

- **On Typing Assists** - couldn't get it to work for a demo, I'm probably missing something?
- **Structural search and replace** - looked to be already a visual example of the feature
- **Workspace symbol** - wasn't sure how best to show this, all of the examples maybe? Also wasn't sure of the best code example to show it off
- **Semantic Syntax Highlighting** - seemed obvious enough to not need a screenshot, but I could easily add this

All the gifs/pngs are hosted in this [comment](https://github.com/rust-analyzer/rust-analyzer/issues/6539#issuecomment-809574840). Please let me know if any of them aren't suitable (and why) and I'll improve it! Or if you don't like the theme/font

Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
2021-03-31 10:01:56 +00:00
bors[bot]
c69f6f31d1
Merge #8266
8266: Fix generic arguments being incorrectly offset in qualified trait casts r=flodiebold a=Veykril

We reverse the segments and generic args of the lowered path after building it, this wasn't accounted for when inserting the self parameter in `Type as Trait` segments.

Fixes #5886

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-31 09:52:47 +00:00
Ayomide Bamidele
276022682b Gifs and screenshots for features in manual 2021-03-31 00:08:10 +01:00
Lukas Wirth
6f0575f08a Fix generic arguments being incorrectly offset in qualified trait casts 2021-03-30 23:23:00 +02:00
Lukas Wirth
8d786dc4c3 Replace Range<usize> usage with TextRange 2021-03-30 22:42:21 +02:00
Chetan Khilosiya
518c9c7548 Revert "8024: Added test case for highlighting trait items."
This reverts commit d7dcd41801.
2021-03-31 01:46:01 +05:30
Chetan Khilosiya
d0fcd5c5e0 8024: Fix for function name change. 2021-03-31 00:47:37 +05:30
Chetan Khilosiya
d7dcd41801 8024: Added test case for highlighting trait items. 2021-03-31 00:31:15 +05:30
Chetan Khilosiya
56f624532a 8024: Updated the implementation for trait modifier.
Fixed the test cases.
2021-03-31 00:31:15 +05:30
Chetan Khilosiya
f269fe7156 8024: Added the trait modifier for methods
method in impls and method calls will have trait modifier.
2021-03-31 00:31:15 +05:30
Jonas Schievink
9b41effd07 Improve rustc diagnostic mapping 2021-03-30 19:29:26 +02:00
bors[bot]
fd7c454d51
Merge #8186
8186: Lower traits to `TraitRef` instead of `TypeRef` r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-30 16:45:05 +00:00
bors[bot]
277db63a08
Merge #8261
8261: Fix expansion of OR-patterns in match check r=Veykril a=Jesse-Bakker

Fixes #8249


Co-authored-by: Jesse Bakker <github@jessebakker.com>
2021-03-30 16:34:53 +00:00
Lukas Wirth
c43359b64e Remove unused Definition::docs 2021-03-30 18:30:42 +02:00
Lukas Wirth
bb56b7a75c Use new new docs string source mapping in goto_def and hover 2021-03-30 18:27:16 +02:00
Lukas Wirth
9a327311e4 Implement basic Documentation source to syntax range mapping 2021-03-30 17:20:43 +02:00
bors[bot]
ab4fae45ac
Merge #8262
8262: internal: revive google_cpu_profile infra r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-30 14:32:04 +00:00
Aleksey Kladov
fb00b92dde internal: revive google_cpu_profile infra 2021-03-30 17:29:43 +03:00
Jesse Bakker
80fe03877d Fix expansion of OR-patterns in match check 2021-03-30 15:01:47 +02:00
Lukas Wirth
9df78ec4a4 Properly resolve intra doc links in hover and goto_definition 2021-03-30 14:03:32 +02:00
bors[bot]
0b68e03bf5
Merge #8256
8256: Item movers improvements r=ivan770 a=ivan770

Closes #8236

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2021-03-30 11:10:20 +00:00
ivan770
4fcba8b1bf
Fix code style 2021-03-30 12:58:41 +02:00
ivan770
6ef6e4dee1
Improved node lookup algorithm, added more movable nodes 2021-03-30 12:44:09 +02:00
Aleksey Kladov
797185e1b6 internal: switch from CLI to internal benchmarking
We have a CLI for benchmarking, but no one actually uses it it seems.
Let's try switching to "internal" benchmarks, implemented as rust tests.
They should be easier to "script" to automate tracking of perf
regressions.
2021-03-30 12:47:23 +03:00
Jonas Schievink
41c7448e12 Accurately classify assoc. types in paths 2021-03-30 02:09:17 +02:00
bors[bot]
b3ca06e4fd
Merge #8247
8247: internal: ensure that runaway type-inference doesn't block the main loop r=flodiebold a=matklad

We have a bug where type-checking `per_query_memory_usage` takes a
couple of seconds. It also reveals another bug: our type inference is
not cancellable.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-29 20:39:36 +00:00
Aleksey Kladov
b35312d4af internal: ensure that runaway type-inference doesn't block the main loop
We have a bug where type-checking `per_query_memory_usage` takes a
couple of seconds. It also reveals another bug: our type inference is
not cancellable.
2021-03-29 23:15:12 +03:00
bors[bot]
35efbf5661
Merge #8244
8244: internal: track missing `.check_cancelled` r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-29 19:22:11 +00:00
Aleksey Kladov
483a5bc9c8 internal: track missing .check_cancelled 2021-03-29 21:38:23 +03:00
bors[bot]
7b9e2a2641
Merge #8243
8243: Remove code duplication in highlight injection r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-29 18:18:40 +00:00
Lukas Wirth
6b8358d4d9 Remove code duplication in highlight injection 2021-03-29 20:11:28 +02:00
Aleksey Kladov
2381a54c2f internal: cleanup hprof 2021-03-29 20:54:15 +03:00
Lukas Wirth
b4bb774381 Remove TraitRef::Error 2021-03-29 18:41:21 +02:00
Lukas Wirth
c2a63b97a8 Rename target_ty to self_ty 2021-03-29 17:47:47 +02:00
Lukas Wirth
bb6e1bf811 Lower traits to TraitRef instead of TypeRef 2021-03-29 17:11:28 +02:00
ivan770
f9d17c6d7c
Apply test style fixes to all empty remove_dbg tests 2021-03-29 16:00:09 +02:00
ivan770
8e5611442e
Update crates/ide_assists/src/handlers/remove_dbg.rs
Apply standard test style fixes

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-29 16:52:30 +03:00
Ayomide Bamidele
8e11796dc5 formatting fix 2021-03-29 12:56:02 +01:00
Jonas Schievink
3c6c1c99b4 Don't use snippets 2021-03-29 13:23:07 +02:00
Ayomide Bamidele
a813062ed2 Folding range for statics 2021-03-29 12:20:26 +01:00
Jonas Schievink
8c1092455e Use find_node_at_range 2021-03-29 13:17:49 +02:00
Ayomide Bamidele
391be07298 Folding range for consts 2021-03-29 12:17:19 +01:00
Ayomide Bamidele
23601454fe New FoldKinds - Consts, Statics 2021-03-29 11:49:14 +01:00
Ayomide Bamidele
f6702dda9a Test cases for folding consts and statics 2021-03-29 11:43:03 +01:00
bors[bot]
ae7de296ae
Merge #8222
8222: Don't mark unlinked file diagnostic as unused r=lnicola a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8215, at least on VS Code

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-03-29 07:30:28 +00:00
bors[bot]
bb1d925dab
Merge #8212
8212: Basic support macro 2.0 r=jonas-schievink a=edwin0cheng

Turn out it is quite straight forward :)

r @jonas-schievink 

![m2](https://user-images.githubusercontent.com/11014119/112712565-6eb99380-8f0b-11eb-88de-5d7f974dfe6d.png)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-28 15:43:11 +00:00
Edwin Cheng
7729879118 Remove unused test fixtures 2021-03-28 10:41:18 +08:00
Jonas Schievink
bd18e5fa87 Don't mark unlinked file diagnostic as unused 2021-03-28 03:56:03 +02:00
bors[bot]
ce6bb5ccca
Merge #8221
8221: Prefer adding `mod` declaration to lib.rs over file.rs in UnlinkedFile fix r=Veykril a=Veykril

When there is a `lib.rs` and `main.rs` in one crate, one usually wants the `lib.rs` file to declare the modules.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-27 22:43:34 +00:00
Lukas Wirth
c9e479870b Prefer add mod declaration to lib.rs over file.rs in UnlinkedFile fix 2021-03-27 23:43:07 +01:00
bors[bot]
84f1660a37
Merge #8220
8220: Reorder some ide_db imports r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-27 21:13:08 +00:00
Lukas Wirth
1ef55002c2 Cleanup ide_db imports 2021-03-27 21:51:00 +01:00
Jonas Schievink
b494e47920 Snippet support in extract_type_alias 2021-03-27 18:53:13 +01:00
ivan770
665266bf66
Replace empty dbg with unit in letexprs, better removal in blocks 2021-03-27 17:34:35 +02:00
bors[bot]
ae92014319
Merge #8213
8213: Added support for const generics in impl generation r=Veykril a=ivan770

Closes #8211

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2021-03-27 10:00:37 +00:00
ivan770
5a2ef8d0ca
Added support for const generics in impl generation 2021-03-27 11:37:39 +02:00
ivan770
0a5badbcba
Replace match on option with if 2021-03-27 11:17:17 +02:00
ivan770
c7cd0aff4a
Remove dbg expression and newline as whole 2021-03-27 11:10:20 +02:00
Edwin Cheng
eedadd7024 Add support for doc on hover for macro 2.0 2021-03-27 14:57:11 +08:00
Edwin Cheng
4520002b63 Unleash macro 2.0 in hightlight and more 2021-03-27 14:42:49 +08:00
Edwin Cheng
a193666361 Basic Support Macro 2.0 2021-03-27 13:44:54 +08:00
bors[bot]
c8066ebd17
Merge #8201
8201: Fix recursive macro statements expansion r=edwin0cheng a=edwin0cheng

This PR attempts to properly handle macro statement expansion by implementing the following:

1.  Merge macro expanded statements to parent scope statements.
2.  Add a new hir `Expr::MacroStmts` for handle tail expression infer.

PS : The scope of macro expanded statements are so strange that it took more time than I thought to understand and implement it :(

Fixes  #8171



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-27 02:57:02 +00:00
Jonas Schievink
e39979aa91 Implement "Extract type alias" assist 2021-03-26 19:39:20 +01:00
Aleksey Kladov
1bbac9053d Add TokenText 2021-03-26 21:33:45 +03:00
cynecx
5ff3299dd6 syntax: return owned string instead of leaking string 2021-03-26 18:30:59 +01:00
Josh Mcguigan
0e31ae2cef completion relevance distinguish between exact type match and could unify 2021-03-26 09:18:18 -07:00
Josh Mcguigan
957939292e completion relevance consider if types can be unified 2021-03-26 09:11:50 -07:00
ivan770
2292ff64f1
Show dbg remove assist on empty contents 2021-03-26 16:15:26 +02:00
ivan770
50e28aec25
Ignore main functions not in root module 2021-03-26 16:04:53 +02:00
Edwin Cheng
8ce15b02de Fix recursive macro statement expansion 2021-03-26 04:21:15 +08:00
Laurențiu Nicola
bc5c86543b Use more std::array::IntoIter 2021-03-25 21:06:48 +02:00
Laurențiu Nicola
9787bddac5 Use arrayvec 0.6 2021-03-25 21:03:20 +02:00
bors[bot]
d7db38fff9
Merge #7907
7907: Autoderef with visibility r=cynecx a=cynecx

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

I am not sure about the general approach here. Right now this simply tries to check whether the autoderef candidate is reachable from the current module. ~~However this doesn't exactly work with traits (see the `tests::macros::infer_derive_clone_in_core` test, which fails right now).~~ see comment below

Refs:

- `rustc_typeck` checking fields: 66ec64ccf3/compiler/rustc_typeck/src/check/expr.rs (L1610) 


r? @flodiebold

Co-authored-by: cynecx <me@cynecx.net>
2021-03-24 22:37:48 +00:00
bors[bot]
9d81618f11
Merge #8190
8190: Fix chalk_ir assertion r=flodiebold a=flodiebold

Fixes #8150.

I implemented a validator that catches this in the tests, but it'd need to get merged in Chalk first.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-03-24 22:13:56 +00:00
Florian Diebold
b4c20e3589 Fix chalk_ir assertion
Fixes #8150.
2021-03-24 23:10:13 +01:00
cynecx
d1156bb52e hir: don't use the self module as visible_from in iterate_method_candidates 2021-03-24 23:09:22 +01:00
cynecx
7155f815b9 hir_ty: don't call write_field_resolution when field candidate isn't visible 2021-03-24 23:03:38 +01:00
cynecx
96c88680b2 hir_def: move visibility queries from hir_ty to hir_def 2021-03-24 23:00:03 +01:00
Jonas Schievink
37c6ce34a9 Document unlinked-file diagnostic 2021-03-24 22:18:17 +01:00
Jonas Schievink
4781479ab2 Sweep the new TraitEnvironmentQuery 2021-03-24 18:59:35 +01:00
hi-rustin
eef9bdb441 refine comment style of tests 2021-03-24 19:28:50 +08:00
bors[bot]
776b1ebcb4
Merge #8168
8168: correct `convert to guard return` let_stmt r=Veykril a=hi-rustin

close https://github.com/rust-analyzer/rust-analyzer/issues/8074

Co-authored-by: hi-rustin <rustin.liu@gmail.com>
2021-03-24 10:55:25 +00:00
bors[bot]
2aa64831e5
Merge #8183
8183: Fix missing command error with macros r=Veykril a=brandondong

**Reproduction:**
1. Define a struct through a macro (can be via `macro_rules`, proc macro, or `include!()`).
2. !!MISSING: command!! annotation appears. Clicking on it results in an error message. No matter where the macro is called/defined, the annotation is always at the start of the file.
![image](https://user-images.githubusercontent.com/13722457/112268785-bce14500-8c34-11eb-9a23-bafd63ffd6ef.png)

**Cause:**
- For struct `A`, a `HasImpls` annotation is added just like for struct `B`. Unlike `B`, the file id for `A` is not the file we are adding annotations to but a macro file.
- The resolving step of the code lens does not succeed.

**Fix:**
- Check that the files match before computing offsets and adding `HasImpls`/`HasReferences` annotations.

Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-03-24 10:17:12 +00:00
bors[bot]
5f9ba2d589
Merge #8177
8177: Limit the hints size by default r=Veykril a=SomeoneToIgnore

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8175
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/3138

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-03-24 08:53:48 +00:00
Brandon
903a2e98f9 Clean up implementation 2021-03-24 00:47:55 -07:00
Edwin Cheng
a2950fcb05 Trim down IPC json size 2021-03-24 15:01:37 +08:00
Brandon
0d063b8d21 Fix MISSING: command error with macros 2021-03-24 00:00:38 -07:00