]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoSupport `#[cfg]` on all associated items
Jonas Schievink [Thu, 18 Mar 2021 00:28:40 +0000 (01:28 +0100)]
Support `#[cfg]` on all associated items

3 years agoMerge #8076
bors[bot] [Wed, 17 Mar 2021 21:33:41 +0000 (21:33 +0000)]
Merge #8076

8076: Add test for self-calling inner function r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/4438 (and duplicates)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoAdd test for self-calling inner function
Jonas Schievink [Wed, 17 Mar 2021 21:30:09 +0000 (22:30 +0100)]
Add test for self-calling inner function

3 years agoMerge #8075
bors[bot] [Wed, 17 Mar 2021 21:25:25 +0000 (21:25 +0000)]
Merge #8075

8075: Fix `use crate as <name>;` imports r=jonas-schievink a=jonas-schievink

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

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFix `use crate as <name>;` imports
Jonas Schievink [Wed, 17 Mar 2021 21:24:51 +0000 (22:24 +0100)]
Fix `use crate as <name>;` imports

3 years agoMerge #8073
bors[bot] [Wed, 17 Mar 2021 20:56:37 +0000 (20:56 +0000)]
Merge #8073

8073: Improve diagnostic when including nonexistent file r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoImprove diagnostic when including nonexistent file
Jonas Schievink [Wed, 17 Mar 2021 20:56:09 +0000 (21:56 +0100)]
Improve diagnostic when including nonexistent file

3 years agoMerge #8072
bors[bot] [Wed, 17 Mar 2021 20:42:52 +0000 (20:42 +0000)]
Merge #8072

8072: Fix "unset `OUT_DIR`" diagnostic when using it in item position r=jonas-schievink a=jonas-schievink

"load out dirs from check" is enabled by default now, but better late than never I guess.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoUse first early expansion error during nameres
Jonas Schievink [Wed, 17 Mar 2021 20:40:36 +0000 (21:40 +0100)]
Use first early expansion error during nameres

3 years agoMerge #8071
bors[bot] [Wed, 17 Mar 2021 20:08:42 +0000 (20:08 +0000)]
Merge #8071

8071: Semantic highlight intradoclinks in documentation r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoSemantic highlight intradoclinks in documentation
Lukas Wirth [Wed, 17 Mar 2021 19:57:30 +0000 (20:57 +0100)]
Semantic highlight intradoclinks in documentation

3 years agoMerge #8069
bors[bot] [Wed, 17 Mar 2021 18:20:25 +0000 (18:20 +0000)]
Merge #8069

8069: Inject highlight into block doc comments r=Veykril a=Veykril

bors r+
Closes https://github.com/rust-analyzer/rust-analyzer/issues/6873

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoInject highlight into block doc comments
Lukas Wirth [Wed, 17 Mar 2021 17:59:54 +0000 (18:59 +0100)]
Inject highlight into block doc comments

3 years agoMerge #8068
bors[bot] [Wed, 17 Mar 2021 17:36:13 +0000 (17:36 +0000)]
Merge #8068

8068: Correctly handle `#[cfg]` on function parameters r=jonas-schievink a=jonas-schievink

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

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoImprove test
Jonas Schievink [Wed, 17 Mar 2021 17:35:17 +0000 (18:35 +0100)]
Improve test

3 years agoApply `#[cfg]`s when computing function signatures
Jonas Schievink [Wed, 17 Mar 2021 17:28:00 +0000 (18:28 +0100)]
Apply `#[cfg]`s when computing function signatures

3 years agoAdd test for `#[cfg]` on function params
Jonas Schievink [Wed, 17 Mar 2021 15:31:54 +0000 (16:31 +0100)]
Add test for `#[cfg]` on function params

3 years agoItemTree: lower attributes on fn parameters
Jonas Schievink [Wed, 17 Mar 2021 15:29:57 +0000 (16:29 +0100)]
ItemTree: lower attributes on fn parameters

3 years agoCorrectly parse attributes on fn parameters
Jonas Schievink [Wed, 17 Mar 2021 17:20:32 +0000 (18:20 +0100)]
Correctly parse attributes on fn parameters

3 years agoMerge #8067
bors[bot] [Wed, 17 Mar 2021 16:26:05 +0000 (16:26 +0000)]
Merge #8067

8067: Check whether cursor is on and not between intra doc links in goto_definition r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoCheck whether cursor is on and not between intra doc links in goto_definition
Lukas Wirth [Wed, 17 Mar 2021 16:24:16 +0000 (17:24 +0100)]
Check whether cursor is on and not between intra doc links in goto_definition

3 years agoMerge #8065
bors[bot] [Wed, 17 Mar 2021 16:00:43 +0000 (16:00 +0000)]
Merge #8065

8065: Better handling of block doc comments r=Veykril a=Veykril

Moves doc string processing to `Attrs::docs`, as we need the indent info from all comments before being able to know how much to strip

Closes #7774

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix incorrect newline emission in Attrs::docs
Lukas Wirth [Wed, 17 Mar 2021 15:10:58 +0000 (16:10 +0100)]
Fix incorrect newline emission in Attrs::docs

3 years agoMerge #8066
bors[bot] [Wed, 17 Mar 2021 14:12:39 +0000 (14:12 +0000)]
Merge #8066

8066: Handle `#[cfg]` on call arguments r=jonas-schievink a=jonas-schievink

This resolved the issue reported in this comment: https://github.com/rust-analyzer/rust-analyzer/issues/5649#issuecomment-789424608

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoHandle `#[cfg]` on call arguments
Jonas Schievink [Wed, 17 Mar 2021 14:08:46 +0000 (15:08 +0100)]
Handle `#[cfg]` on call arguments

3 years agoBetter handling of block doc comments
Lukas Wirth [Wed, 17 Mar 2021 13:38:11 +0000 (14:38 +0100)]
Better handling of block doc comments

3 years agoMerge #8059
bors[bot] [Wed, 17 Mar 2021 11:13:54 +0000 (11:13 +0000)]
Merge #8059

8059: Move doc-comment highlight injection from AST to HIR r=matklad,jonas-schievink a=Veykril

Fixes #5016

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoRemove quadratic attr source lookup
Lukas Wirth [Wed, 17 Mar 2021 10:22:40 +0000 (11:22 +0100)]
Remove quadratic attr source lookup

3 years agoMerge #8063
bors[bot] [Wed, 17 Mar 2021 08:12:34 +0000 (08:12 +0000)]
Merge #8063

8063: couple clippy::complexity fixes r=matklad a=matthiaskrgr

avoid redundant `.into()` calls to convert T into identical T (`let x: String = String::from("hello").into();`)
use `if let Some(x)` instead of `.is_some()` + `.unwrap()`
don't clone Copy types
remove redundant wrapped ?s:  `Some(Some(3)?)` can just be `Some(3)`
use `.map(|x| y)` instead of `and_then(|x| Some(y)` on `Option`s

Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
3 years agoMerge #8048
bors[bot] [Wed, 17 Mar 2021 07:20:28 +0000 (07:20 +0000)]
Merge #8048

8048: Fix missing unresolved macro diagnostic in function body r=edwin0cheng a=brandondong

This was an issue I found while working on https://github.com/rust-analyzer/rust-analyzer/pull/7970.

**Reproduction:**
1. Call a non-existent macro in a function body.
```
fn main() {
  foo!();
}
```
2. No diagnostics are raised. An unresolved-macro-call diagnostic is expected.
3. If the macro call is instead outside of the function body, this works as expected.

I believe this worked previously and regressed in https://github.com/rust-analyzer/rust-analyzer/pull/7805.

**Behavior prior to https://github.com/rust-analyzer/rust-analyzer/pull/7805:**
- The unresolved-macro-call diagnostic did not exist. Instead, a macro-error diagnostic would be raised with the text "could not resolve macro [path]".
- This was implemented by adding an error to the error sink (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8L657).
- The error was propagated through https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/crates/hir_def/src/body.rs#L123 eventually reaching https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/crates/hir_def/src/body/lower.rs#L569.

**Behavior after:**
- Instead of writing to the error sink, an UnresolvedMacro error is now returned (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R631).
- The parent caller throws away the error as its function signature is `Option<MacroCallId>` (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R604).
- We instead now reach the warn condition (https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/crates/hir_def/src/body.rs#L124) and no diagnostics are created in https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/crates/hir_def/src/body/lower.rs#L575.

**Fix:**
- Make sure to propagate the UnresolvedMacro error. Report the error using the new unresolved-macro-call diagnostic.

Co-authored-by: Brandon <brandondong604@hotmail.com>
3 years agoFollow established ErrorEmitted pattern
Brandon [Wed, 17 Mar 2021 06:31:14 +0000 (23:31 -0700)]
Follow established ErrorEmitted pattern

3 years agouse simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. (clippy::bind_...
Matthias Krüger [Wed, 17 Mar 2021 01:34:46 +0000 (02:34 +0100)]
use simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. (clippy::bind_instead_of_map)

3 years agoremove uselessly wrapped ?s. (clippy::meedless_question_mark
Matthias Krüger [Wed, 17 Mar 2021 01:19:40 +0000 (02:19 +0100)]
remove uselessly wrapped ?s. (clippy::meedless_question_mark

let x = Some(3);

let y = Some(x?);
can just be:
let y = x

3 years agodon't clone types that are copy (clippy::clone_on_copy)
Matthias Krüger [Wed, 17 Mar 2021 00:56:31 +0000 (01:56 +0100)]
don't clone types that are copy (clippy::clone_on_copy)

3 years agouse if let Some(x) instead of if x.is_some() and x.unwrap() (clippy::unnecessary...
Matthias Krüger [Wed, 17 Mar 2021 00:39:58 +0000 (01:39 +0100)]
use if let Some(x) instead of  if x.is_some() and x.unwrap() (clippy::unnecessary-unwrap)

3 years agoavoid converting types into themselves via .into() (clippy::useless-conversion)
Matthias Krüger [Wed, 17 Mar 2021 00:27:56 +0000 (01:27 +0100)]
avoid converting types into themselves via .into() (clippy::useless-conversion)

example: let x: String = String::from("hello world").into();

3 years agoProperly handle doc attributes in doc-comment highlight injection
Lukas Wirth [Tue, 16 Mar 2021 20:05:07 +0000 (21:05 +0100)]
Properly handle doc attributes in doc-comment highlight injection

3 years agoMerge #8062
bors[bot] [Tue, 16 Mar 2021 20:01:20 +0000 (20:01 +0000)]
Merge #8062

8062: pit-of-successify tree editor r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agopit-of-successify tree editor
Aleksey Kladov [Tue, 16 Mar 2021 19:59:57 +0000 (22:59 +0300)]
pit-of-successify tree editor

3 years agoMerge #8061
bors[bot] [Tue, 16 Mar 2021 19:53:01 +0000 (19:53 +0000)]
Merge #8061

8061: Auto-magical whitespace r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoAuto-magical whitespace
Aleksey Kladov [Tue, 16 Mar 2021 19:51:37 +0000 (22:51 +0300)]
Auto-magical whitespace

3 years agoMerge #8042
bors[bot] [Tue, 16 Mar 2021 19:36:55 +0000 (19:36 +0000)]
Merge #8042

8042: Add perf_revision to benchmark results r=lnicola a=d2weber

I gave it a try to add the hash as described in #8031
Feel free to tell me if there is something I could improve.

Co-authored-by: Douglas Weber <douglas.web@web.de>
3 years agoMerge #8060
bors[bot] [Tue, 16 Mar 2021 19:28:47 +0000 (19:28 +0000)]
Merge #8060

8060: Move more bounds r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMove more bounds
Aleksey Kladov [Tue, 16 Mar 2021 19:28:04 +0000 (22:28 +0300)]
Move more bounds

changelog: skip

3 years agoFix attribute index assignment in cfg_attr resolution
Lukas Wirth [Tue, 16 Mar 2021 18:55:40 +0000 (19:55 +0100)]
Fix attribute index assignment in cfg_attr resolution

3 years agoReplace trait object boxing with extra AttrsOwnerNode
Lukas Wirth [Tue, 16 Mar 2021 18:06:58 +0000 (19:06 +0100)]
Replace trait object boxing with extra AttrsOwnerNode

3 years agoMove doc-comment highlight injection from AST to HIR
Lukas Wirth [Tue, 16 Mar 2021 17:57:47 +0000 (18:57 +0100)]
Move doc-comment highlight injection from AST to HIR

3 years agoMerge #8041
bors[bot] [Tue, 16 Mar 2021 16:58:48 +0000 (16:58 +0000)]
Merge #8041

8041: Rename Substs -> Substitution r=flodiebold a=flodiebold

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoRename Substs -> Substitution
Florian Diebold [Mon, 15 Mar 2021 20:02:34 +0000 (21:02 +0100)]
Rename Substs -> Substitution

3 years agoMerge #8055
bors[bot] [Tue, 16 Mar 2021 15:48:35 +0000 (15:48 +0000)]
Merge #8055

8055: Implement HirDisplay for some more types r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #8053
bors[bot] [Tue, 16 Mar 2021 15:40:06 +0000 (15:40 +0000)]
Merge #8053

8053: Remove ShortLabel r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoImplement HirDisplay for some more types
Lukas Wirth [Tue, 16 Mar 2021 15:36:34 +0000 (16:36 +0100)]
Implement HirDisplay for some more types

3 years agoMerge #8034
bors[bot] [Tue, 16 Mar 2021 14:54:12 +0000 (14:54 +0000)]
Merge #8034

8034: Implement Crate::transitive_reverse_dependencies r=matklad a=Veykril

changelog internal Implement Crate::transitive_reverse_dependencies

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDon't repeat work in transitive_reverse_dependencies
Lukas Wirth [Tue, 16 Mar 2021 14:53:34 +0000 (15:53 +0100)]
Don't repeat work in transitive_reverse_dependencies

3 years agoRemove ShortLabel
Lukas Wirth [Tue, 16 Mar 2021 14:44:31 +0000 (15:44 +0100)]
Remove ShortLabel

3 years agoAdd new_source_root meta to test fixtures
Lukas Wirth [Tue, 16 Mar 2021 14:28:02 +0000 (15:28 +0100)]
Add new_source_root meta to test fixtures

3 years agoMerge #8052
bors[bot] [Tue, 16 Mar 2021 13:56:53 +0000 (13:56 +0000)]
Merge #8052

8052: minor style fixes per feedback on #8036 r=JoshMcguigan a=JoshMcguigan

cc @matklad  - this PR addresses your comments in #8036.

changelog fixup #8036

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agominor style fixes per feedback on #8036
Josh Mcguigan [Tue, 16 Mar 2021 13:54:17 +0000 (06:54 -0700)]
minor style fixes per feedback on #8036

3 years agoMerge #8051
bors[bot] [Tue, 16 Mar 2021 13:35:26 +0000 (13:35 +0000)]
Merge #8051

8051: Fix more unused wariable warnings r=lnicola a=lnicola

bors r+

changelog skip

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFix more unused wariable warnings
Laurențiu Nicola [Tue, 16 Mar 2021 13:34:19 +0000 (15:34 +0200)]
Fix more unused wariable warnings

3 years agoMerge #7498
bors[bot] [Tue, 16 Mar 2021 13:14:48 +0000 (13:14 +0000)]
Merge #7498

7498: Clone for update r=matklad a=matklad

rowan counterpart https://github.com/rust-analyzer/rowan/pull/93

#6857

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoUpgrade rowan
Aleksey Kladov [Sat, 30 Jan 2021 15:19:21 +0000 (18:19 +0300)]
Upgrade rowan

Notably, new rowan comes with support for mutable syntax trees.

3 years agoMerge #7900 #8000
bors[bot] [Tue, 16 Mar 2021 08:05:24 +0000 (08:05 +0000)]
Merge #7900 #8000

7900: show function params in completion detail r=matklad a=JoshMcguigan

This resolves #7842 by updating the detail for function completions from `-> T` to `fn(T, U) -> V`. I added an expicit unit test for this, `ide_completion::render::fn_detail_includes_args_and_return_type`, which passes.

Lots of other unit tests fail (~60 of them) due to this change, although I believe the failures are purely cosmetic (they were testing the exact format of this output). I'm happy to go update those tests, but before I do that I'd like to make sure this is in fact the format we want for the detail?

edit - I realized `UPDATE_EXPECT=1 cargo test` automatically updates `expect!` tests. Big :+1: to whoever worked on that! So I'll go ahead and update all these tests soon. But I still would like to confirm `fn(T, U) -> V` is the desired content in the `detail` field.

8000: Use hir formatter for hover text r=matklad a=oxalica

Fix #2765 , (should) fix #4665

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
3 years agoMerge #8036 #8046
bors[bot] [Tue, 16 Mar 2021 07:57:33 +0000 (07:57 +0000)]
Merge #8036 #8046

8036: completions: provide relevance bonus for enum types, and suggest ref matches for fn and enum r=matklad a=JoshMcguigan

This PR makes several improvements to completions and completion sorting:

1. Provide exact match type relevance score bonus for enum variants
2. Suggest `&Foo` (ref_match) for enums if that is an exact type match
3. Suggest `&foo()` (ref_match) if `foo` returns a type which would be an exact match either with the reference or due to a `Deref` impl

### Before

![pre-ref-relevance-centralized](https://user-images.githubusercontent.com/22216761/111189377-3f05a580-8573-11eb-89be-58a45cb7f829.png)

### After

![post-ref-relevance-centralized](https://user-images.githubusercontent.com/22216761/111189395-45941d00-8573-11eb-871b-09186b35cbb9.png)

### Caveats

I think generic types will require some kind of fancier logic when testing for `exact_type_match`, so for now `Option`/`Result`/etc unfortunately still don't have great completions.

### Implementation

I implemented this in a way that I think makes it most likely for each completion type to be handled consistently. Just replace `CompletionItem::new` with `CompletionItem::new_with_type_info` and `exact_type_match`/`exact_name_match`/`ref_match` are all handled for you, in a way which is sure to be consistent across completion types.

This approach does introduce some coupling/plumbing that didn't exist before. Notice for example `set_is_local` on the builder, because `set_relevance` was removed from the builder to enforce that the relevance was built "properly" with `CompletionItem::new_with_type_info`. But I think there are benefits to this approach, like `CompletionRelevance` should probably consider deprecation status, and we already tell the builder about that, so in the (likely near term) future we can just pass that information along to `CompletionRelevance` when the user calls `set_deprecated` rather than the user having to manually set it in two places. This basically just hides `CompletionRelevance` from the individual completions, so they only worry about the `CompletionItem` interface. At the moment this seems like a cleaner approach to me, but I'm open to feedback here.

edit - I've reimplemented this in a simpler way, per feedback below.

8046: Prefer match to if let else r=matklad a=matklad

bors r+
🤖

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoFix missing unresolved macro diagnostic in function body
Brandon [Tue, 16 Mar 2021 07:46:57 +0000 (00:46 -0700)]
Fix missing unresolved macro diagnostic in function body

3 years agoPrefer match to if let else
Aleksey Kladov [Tue, 16 Mar 2021 07:51:05 +0000 (10:51 +0300)]
Prefer match to if let else

3 years agoMerge #8045
bors[bot] [Tue, 16 Mar 2021 07:50:04 +0000 (07:50 +0000)]
Merge #8045

8045: Increase fetch-depth to make `git describe` work r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoIncrease fetch-depth to make `git describe` work
Laurențiu Nicola [Tue, 16 Mar 2021 07:48:50 +0000 (09:48 +0200)]
Increase fetch-depth to make `git describe` work

3 years agoMerge #8040
bors[bot] [Tue, 16 Mar 2021 07:41:58 +0000 (07:41 +0000)]
Merge #8040

8040: 7709: Added the check for return type of len function. r=Veykril a=chetankhilosiya

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years agoMerge #8044
bors[bot] [Tue, 16 Mar 2021 05:48:05 +0000 (05:48 +0000)]
Merge #8044

8044: Fix macro expansion for statements w/o semicolon r=edwin0cheng a=edwin0cheng

Fixes  #7845

And up `ungrammer` to  1.12.

cc @jonas-schievink

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix macro expansion for statements w/o semicolon
Edwin Cheng [Tue, 16 Mar 2021 05:44:50 +0000 (13:44 +0800)]
Fix  macro expansion for statements w/o semicolon

3 years agocompletions: centralize calculation of relevance and ref matches
Josh Mcguigan [Tue, 16 Mar 2021 02:26:59 +0000 (19:26 -0700)]
completions: centralize calculation of relevance and ref matches

3 years agoAdd perf_revision to benchmark results
Douglas Weber [Mon, 15 Mar 2021 21:21:02 +0000 (22:21 +0100)]
Add perf_revision to benchmark results

3 years ago7709: Import changes.
Chetan Khilosiya [Mon, 15 Mar 2021 20:28:21 +0000 (01:58 +0530)]
7709: Import changes.

3 years ago7709: Added the check for return type of len function.
Chetan Khilosiya [Mon, 15 Mar 2021 19:46:59 +0000 (01:16 +0530)]
7709: Added the check for return type of len function.

3 years agoMerge #8039
bors[bot] [Mon, 15 Mar 2021 18:49:07 +0000 (18:49 +0000)]
Merge #8039

8039: Use SmallVec for Substs r=flodiebold a=flodiebold

Doesn't help as much as I hoped, but it helps a bit and I also did some
refactorings that were necessary anyway.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoUse SmallVec for Substs
Florian Diebold [Mon, 15 Mar 2021 18:13:49 +0000 (19:13 +0100)]
Use SmallVec for Substs

Doesn't help as much as I hoped, but it helps a bit and I also did some
refactorings that were necessary anyway.

3 years agoMerge #7970
bors[bot] [Mon, 15 Mar 2021 18:24:22 +0000 (18:24 +0000)]
Merge #7970

7970: Fix incorrect diagnostics for failing built in macros r=jonas-schievink a=brandondong

**Reproduction:**
1. Use a built in macro in such a way that rust-analyzer fails to expand it. For example:

**lib.rs**
```
include!("<valid file but without a .rs extension so it is not indexed by rust-analyzer>");
```
2. rust-analyzer highlights the macro call and says the macro itself cannot be resolved even though include! is in the standard library (unresolved-macro-call diagnostic).
3. No macro-error diagnostic is raised.

**Root cause for incorrect unresolved-macro-call diagnostic:**
1. collector:collect_macro_call is able to resolve include! in legacy scope but the expansion fails. Therefore, it's pushed into unexpanded_macros to be retried with module scope.
2. include! fails at the resolution step in collector:resolve_macros now that it's using module scope. Therefore, it's retained in unexpanded_macros.
3. Finally, collector:finish tries resolving the remaining unexpanded macros but only with module scope. include! again fails at the resolution step so a diagnostic is created.

**Root cause for missing macro-error diagnostic:**
1. In collector:resolve_macros, directive.legacy is None since eager expansion failed in collector:collect_macro_call. The macro_call_as_call_id fails to resolve since we're retrying in module scope. Therefore, collect_macro_expansion is not called for the macro and no macro-error diagnostic is generated.

**Fix:**
- In collector:collect_macro_call, do not add failing built-in macros to the unexpanded_macros list and immediately raise the macro-error diagnostic. This is in contrast to lazy macros which are resolved in collector::resolve_macros and later expanded in collect_macro_expansion where a macro-error diagnostic may be raised.

Co-authored-by: Brandon <brandondong604@hotmail.com>
Co-authored-by: brandondong <brandondong604@hotmail.com>
3 years agoUpdate crates/hir_def/src/nameres/collector.rs
brandondong [Mon, 15 Mar 2021 18:16:58 +0000 (11:16 -0700)]
Update crates/hir_def/src/nameres/collector.rs

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMerge #8038
bors[bot] [Mon, 15 Mar 2021 18:14:49 +0000 (18:14 +0000)]
Merge #8038

8038: Fix unification logic r=flodiebold a=flodiebold

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoFix unification logic
Florian Diebold [Mon, 15 Mar 2021 17:22:25 +0000 (18:22 +0100)]
Fix unification logic

3 years agoMerge #8028
bors[bot] [Mon, 15 Mar 2021 17:50:20 +0000 (17:50 +0000)]
Merge #8028

8028: Return multiple modules in `parent_module` feature r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #8037
bors[bot] [Mon, 15 Mar 2021 17:40:14 +0000 (17:40 +0000)]
Merge #8037

8037: Assist is empty 7709 r=Veykril a=chetankhilosiya

Updated the implementation to get the function from implementation

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years agoImplement Crate::transitive_reverse_dependencies
Lukas Wirth [Mon, 15 Mar 2021 16:43:46 +0000 (17:43 +0100)]
Implement Crate::transitive_reverse_dependencies

3 years agoUpdate tests
oxalica [Mon, 15 Mar 2021 17:24:26 +0000 (01:24 +0800)]
Update tests

3 years agoPretty print root module of extern crates
oxalica [Mon, 15 Mar 2021 17:24:21 +0000 (01:24 +0800)]
Pretty print root module of extern crates

3 years ago7709: Updated the implementation.
Chetan Khilosiya [Mon, 15 Mar 2021 17:18:50 +0000 (22:48 +0530)]
7709: Updated the implementation.

The get function from impl method is updated.
and now same method used to get len and is_empty function.

3 years agoClean usage of ShortLabel
oxalica [Mon, 15 Mar 2021 16:58:42 +0000 (00:58 +0800)]
Clean usage of ShortLabel

3 years agoFix trait type parameter
oxalica [Mon, 15 Mar 2021 16:58:29 +0000 (00:58 +0800)]
Fix trait type parameter

3 years agoUse hir formatter more
oxalica [Mon, 15 Mar 2021 16:05:03 +0000 (00:05 +0800)]
Use hir formatter more

3 years agoImpl HirDisplay for function hover message
oxalica [Sun, 14 Mar 2021 12:03:39 +0000 (20:03 +0800)]
Impl HirDisplay for function hover message

3 years agoIntroduce FunctionQualifier for hir::FunctionData
oxalica [Sun, 14 Mar 2021 10:00:11 +0000 (18:00 +0800)]
Introduce FunctionQualifier for hir::FunctionData

3 years agoCollect HirDisplay impls to a single file
oxalica [Sun, 14 Mar 2021 09:36:04 +0000 (17:36 +0800)]
Collect HirDisplay impls to a single file

3 years agoAdd test for hover of macro expanded function
oxalica [Sat, 13 Mar 2021 17:07:05 +0000 (01:07 +0800)]
Add test for hover of macro expanded function

3 years agoMerge #8035
bors[bot] [Mon, 15 Mar 2021 16:51:53 +0000 (16:51 +0000)]
Merge #8035

8035: unqualfied_path completions aren't responsible for variant pattern completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agounqualfied_path completions aren't responsible for pattern completions
Lukas Wirth [Mon, 15 Mar 2021 16:23:08 +0000 (17:23 +0100)]
unqualfied_path completions aren't responsible for pattern completions

3 years ago7709: Added the assist to generate is_empty function
Chetan Khilosiya [Thu, 11 Mar 2021 18:55:22 +0000 (00:25 +0530)]
7709: Added the assist to generate is_empty function

the assist will be shown when the len function is implemented.
is_empty internally uses len function.

3 years agoMerge #7992
bors[bot] [Mon, 15 Mar 2021 15:53:15 +0000 (15:53 +0000)]
Merge #7992

7992: improved completion sorting for functions and methods r=JoshMcguigan a=JoshMcguigan

This PR improves completion sorting for functions and methods. Related to #7935.

### Before

The methods are being sorted by `coc` by closeness in file.

![pre-fn-relevance](https://user-images.githubusercontent.com/22216761/111018669-fe3d3f00-836e-11eb-9607-cc05af080a6a.png)

### After

Notice `bbb()` on top (type + name match), followed by `ddd()` (type match).

![image](https://user-images.githubusercontent.com/22216761/111018680-0e551e80-836f-11eb-94b1-c88336ecbc6e.png)

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agoMerge #8033
bors[bot] [Mon, 15 Mar 2021 15:39:34 +0000 (15:39 +0000)]
Merge #8033

8033: Add test for proc-macro meta info retrieval r=edwin0cheng a=edwin0cheng

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoAdd test for proc-macro meta info retrieval
Edwin Cheng [Mon, 15 Mar 2021 15:38:22 +0000 (23:38 +0800)]
Add test for proc-macro meta info retrieval