Commit Graph

14388 Commits

Author SHA1 Message Date
Jeroen Vannevel
ee862cec10 simplified tail_expr 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4896ffb65c removing unwraps 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
50c913c733 don't remove the comment token if it's last 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4f3dd5bc08 very rough but comments get extracted 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
f662d8bf38 repro 2022-01-22 12:08:32 +00:00
Laurențiu Nicola
bdfdb525bb Bump chalk 2022-01-21 19:51:21 +02:00
Laurențiu Nicola
e3e6133ff4 Bump pulldown-cmark and pulldown-cmark-to-cmark 2022-01-21 19:49:57 +02:00
Laurențiu Nicola
09fb755432 Bump hashbrown 2022-01-21 19:44:03 +02:00
Laurențiu Nicola
485f318b70 Bump dashmap 2022-01-21 19:42:04 +02:00
Jonas Schievink
e5ed43b1dc Remove redundant Option from eager macro fns 2022-01-21 12:58:06 +01:00
Schuyler Cohen
11cb203daf Remove spurious format 2022-01-19 13:37:25 -06:00
Jonas Schievink
c714c139a4 Update tests
We're now omitting the libc crate's build script and const_fn test
2022-01-18 18:27:29 +01:00
Jonas Schievink
22ea5595a8 Don't load auxiliary crates outside the workspace 2022-01-18 18:17:43 +01:00
Wesley Norris
ba82cc7722 Add test for comments not directly next to items 2022-01-17 18:44:43 -05:00
Wesley Norris
7d10752299 Add a test for multi-single-line comments as well 2022-01-17 17:12:32 -05:00
Wesley Norris
1c866573cb fix: insert auto-imports after header comments
Fixes #8607.

This commit changes the auto-import functionality and causes it to add
imports after any leading comments, which are commonly license headers.
This does not affect comments on items as they're considered part of the
item itself and not separate.
2022-01-17 17:06:10 -05:00
Jonas Schievink
a3d06f824b status: output all crates a file belongs to 2022-01-17 18:10:01 +01:00
Jonas Schievink
8a7f0d920e Allow macros to expand to or-patterns 2022-01-17 16:52:53 +01:00
Laurențiu Nicola
c504518775 Temporarily disable format string completions 2022-01-17 09:30:35 +02:00
bors[bot]
e6e72809e3
Merge #11287
11287: fix: rust-analyzer spamming overly error message when workspace not being loaded r=lnicola a=Milo123459

Fixes #10120

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2022-01-16 15:13:52 +00:00
bors[bot]
7a52f83700
Merge #11294
11294: internal: Move format specifier lexing from syntax to ide_db r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-15 12:18:46 +00:00
Lukas Wirth
91279db2b4 Move format specifier lexing from syntax to ide_db 2022-01-15 13:14:59 +01:00
bors[bot]
4c34909308
Merge #11293
11293: feat: Add very simplistic ident completion for format_args! macro input r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-15 11:24:21 +00:00
Lukas Wirth
82fccb971e feat: Add very simplistic ident completion for format_args! macro input 2022-01-15 12:23:26 +01:00
bors[bot]
9ee5b89e52
Merge #11292
11292: internal: Decrease PartialOrd and PartialEq trait methods completion relevance r=Veykril a=Veykril


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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-15 10:17:01 +00:00
Lukas Wirth
2c36102722 internal: Decrease PartialOrd and PartialEq trait methods completion relevance 2022-01-15 11:05:13 +01:00
Jake Heinz
25f67b6939 make it a config 2022-01-15 02:47:47 +00:00
Milo
3de6b4839f format 2022-01-14 22:13:45 +00:00
Milo
e1fe930845 fix overly 2022-01-14 22:06:30 +00:00
bors[bot]
844c152fd1
Merge #11248
11248: Merge match assist: take arm types into consideration  r=Vannevelj a=Vannevelj

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

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-01-14 19:03:55 +00:00
Jeroen Vannevel
ffe4352d7c
styling fixes 2022-01-14 18:53:28 +00:00
Jonas Schievink
e52e1aaca1 Clean up assoc item collection a bit 2022-01-14 18:45:23 +01:00
Jonas Schievink
72fd08d8d2 Remove redundant recursion limit 2022-01-14 17:45:57 +01:00
bors[bot]
9ba6cfa9c7
Merge #11283
11283: fix: Adjust `.` typing auto indentation r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-14 11:16:18 +00:00
Lukas Wirth
ba3efafc0d fix: Adjust . typing auto indentation 2022-01-14 12:15:43 +01:00
Jake Heinz
bcc99091f3 hacky fix for cancelling 2022-01-14 10:30:51 +00:00
Jake Heinz
6c5504a617 one last bit of cleanup 2022-01-14 10:10:47 +00:00
bors[bot]
fc331fe831
Merge #11282
11282: fix: Properly cache files in Semantics when ascending macros r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-14 10:08:27 +00:00
Lukas Wirth
f1cb5ed9b0 fix: Properly cache files in Semantics when ascending macros 2022-01-14 11:07:53 +01:00
Jake Heinz
c3f30ae4f0 removed scoped threads, cleanup 2022-01-14 10:06:28 +00:00
Lukas Wirth
2f8dd64830 Replace HasSource usages with Semantics equivalent 2022-01-14 10:59:27 +01:00
Jake Heinz
f83c0166be cleanup + detect num cpus 2022-01-14 09:48:59 +00:00
Jake Heinz
0b0bfc6fdd cleanup 2022-01-14 09:36:03 +00:00
Jake Heinz
c8aa2f6a61 use index map 2022-01-14 09:35:41 +00:00
Jake Heinz
5f0c1aa2de make progress callback dyn 2022-01-14 09:33:40 +00:00
Jake Heinz
2b0d8a86a2 fix warnings 2022-01-14 09:25:45 +00:00
Jake Heinz
343b0ccfb9 simplify 2022-01-14 09:21:25 +00:00
Jake Heinz
3168148cc6 ide: parallel prime caches 2022-01-14 09:16:35 +00:00
Jeroen Vannevel
683de877ce
simple return 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
0700282b75
formatting 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
e5cdde95ab
removed toy 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
5e4370fe56
happy slice 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
8deadb18ae
refpat & slicepat 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
82d3238da8
ParenPat 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
c955ea11b4
support TuplePat 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
a347cb5f86
battle of the Some 2022-01-14 01:32:12 +00:00
Jeroen Vannevel
7daca6fe97
cleaning up Some 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
08300284e7
removed unwrap 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
7bc89f2542
formatting 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
bd77d8c3d1
removed prints 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
18fb5412b2
all tests work 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
aaec467cfd
merge_match_arms_nested_with_conflicting_identifier 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
169ec2fdc1
Added a few more test cases 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
b27b882e72
fixed test case 2022-01-14 01:32:11 +00:00
Jeroen Vannevel
2329b42407
test for different number of fields 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
5675e0cd40
test cases with more branches 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
130f11f270
simplified chain 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
5dfc8da77e
don't need the as_ref() 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
c52605024c
extracted function 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
d8a3e51a5f
added tests for multiple fields 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
9252c76255
using classify() 2022-01-14 01:32:10 +00:00
Jeroen Vannevel
6a1b4912bf
removed some unused stuff 2022-01-14 01:32:09 +00:00
Jeroen Vannevel
c9fc91822f
minicore 2022-01-14 01:32:09 +00:00
Jeroen Vannevel
215f896665
compiles, but doesn't work yet 2022-01-14 01:32:09 +00:00
bors[bot]
b4c31481a5
Merge #11276
11276: internal: Slightly cleanup HasFormatSpecifier::lex_format_specifier r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-13 19:18:47 +00:00
Laurențiu Nicola
0721a55a48 Remove duplicate test attribute 2022-01-13 21:08:04 +02:00
Laurențiu Nicola
84c59a1f9f Reformat code 2022-01-13 21:07:17 +02:00
Lukas Wirth
c3148cb396 Slightly cleanup HasFormatSpecifier::lex_format_specifier 2022-01-13 19:12:39 +01:00
Jonas Schievink
3fde9f820a Unexport MacroDefId from hir 2022-01-13 16:18:05 +01:00
Jonas Schievink
18e80e6892 Remove ModuleId from hir reexports 2022-01-12 20:21:13 +01:00
Jonas Schievink
09219e10f1 Mostly restore hir API boundary 2022-01-12 19:56:47 +01:00
bors[bot]
4fe10b7bfe
Merge #11265
11265: fix: Fix postfix completion panic r=lnicola a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-12 12:30:41 +00:00
Lukas Wirth
09ce5d81d0 fix: Fix postfix completion panic 2022-01-12 13:07:16 +01:00
bors[bot]
de50ef4bea
Merge #11263
11263: fix: Fix don't drop param completions when fully typing out a pattern r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-12 11:37:18 +00:00
Lukas Wirth
314b199e3c fix: Fix don't drop param completions when fully typing out a pattern 2022-01-12 12:36:46 +01:00
Lukas Wirth
51419c1931 Don't complete attributes with existing expressions 2022-01-11 19:03:21 +01:00
Jonas Schievink
7e8b96f07c Fix concatenation of super mod paths 2022-01-11 15:39:13 +01:00
Jonas Schievink
0706de94bb Report DefDiagnostics from inside item bodies 2022-01-11 14:34:25 +01:00
bors[bot]
5a711d4f3a
Merge #11210
11210: feat: Deprioritize ops methods in completion r=Veykril a=Veykril

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



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-11 09:39:12 +00:00
Lukas Wirth
4901ea3eef Lookup lang attribute on assoc item trait directly 2022-01-11 10:28:38 +01:00
Lukas Wirth
94b369faa3 Update tests 2022-01-11 09:26:53 +01:00
Lukas Wirth
ca0633c808 feat: Deprioritize ops methods in completion 2022-01-11 09:26:53 +01:00
bors[bot]
85bcca6b37
Merge #11252
11252: Fix documentation of snippet r=Veykril a=weirane

Closes #11234

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-11 08:11:55 +00:00
Wang Ruochen
01b3ce3006
Fix documentation of snippet 2022-01-10 21:29:41 -08:00
Jonas Schievink
601dc50b5a Print a single ellipsis for any number of omitted types 2022-01-10 16:55:53 +01:00
Jonas Schievink
3dd5e273b6 Shrink diagnostic spans for errors inside macros 2022-01-08 15:40:42 +01:00
Jonas Schievink
67f548d8e9 Allow doc comments on all Items 2022-01-08 15:27:48 +01:00
bors[bot]
ca8bd3ec42
Merge #11237
11237: fix: Fix outline modules spilling inner doc injections into their parent r=Veykril a=Veykril

Fixes another regression caused by https://github.com/rust-analyzer/rust-analyzer/pull/11225
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-08 13:55:18 +00:00
Lukas Wirth
b32f611b6e fix: Fix outline modules spilling inner doc injections into their parent 2022-01-08 14:54:31 +01:00
bors[bot]
01c3303270
Merge #11236
11236: internal: Remove `InFile` wrapping from `DynMap` keys r=Veykril a=Veykril

We already store a `DynMap` per `(Container, HirFileId)` pair, so the `InFile` keys are already guruanteed to always be of the same file id
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-08 11:17:56 +00:00
Lukas Wirth
47591f0fb2 Remove InFile wrapping from DynMap keys 2022-01-08 12:16:44 +01:00
Lukas Wirth
b6826e9246 Only add generics with the correct file id to DynMap 2022-01-08 11:34:58 +01:00
bors[bot]
926ba99f43
Merge #11235
11235: internal: Record attribute calls on assoc items in TraitData and ImplData r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-08 10:11:37 +00:00
Lukas Wirth
8d4f40e881 Do less allocs in trait_data and impl_data queries 2022-01-08 11:04:16 +01:00
Lukas Wirth
6746ba5839 Record attribute calls on assoc items in TraitData and ImplData 2022-01-08 10:45:12 +01:00
bors[bot]
c17db9fa53
Merge #11107
11107: Fix generic type substitution in impl trait with assoc type r=pnevyk a=pnevyk

Fixes #11045 

The path transform now detects if a type parameter that is being substituted has an associated type. In that case it is necessary (or safe in general case) to fully qualify the substitution with a trait which the associated type belongs to.

This PR also fixes the previous wrong behavior of the substitution that could create an invalid tree `PATH_TYPE -> PATH_TYPE -> ...`.

Co-authored-by: Petr Nevyhoštěný <petr.nevyhosteny@gmail.com>
2022-01-08 09:05:09 +00:00
Lukas Wirth
6cf0cadfaa Simplify 2022-01-07 21:52:37 +01:00
Lukas Wirth
0c9268c1ee Filter out macro calls by file id in when building DynMap 2022-01-07 21:31:08 +01:00
bors[bot]
41a0e95d61
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4 fix: Fix attribute stripping ignoring doc comments 2022-01-07 18:51:10 +01:00
Petr Nevyhoštěný
a710b87b1b Fix generic type substitution in impl trait with assoc const 2022-01-07 16:41:39 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
bors[bot]
efb9b89163
Merge #11220
11220: Turbo fish assist: don't include lifetime parameters r=Veykril a=Vannevelj

Fixes #11219

The issue talks about three different types of params: type, const & lifetime. I wasn't entirely sure which ones are intended to be included here so I've gone for the type & const params (i.e. exclude lifetime).

I've added a test case for both a lifetime param and a const param. I'm still making my way through the rust book (chapter 7, yay) so I'm not too sure yet what these are but my testing shows that this approach generates code that compiles.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-01-07 14:02:01 +00:00
Benjamin Coenen
8e0a05eb70 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 15:01:37 +01:00
Jeroen Vannevel
0a240e31c5
succinct code 2022-01-07 13:53:42 +00:00
bors[bot]
b70493d095
Merge #11225
11225: internal: Cleanup doc and attribute handling r=Veykril a=Veykril

(very vague PR title but as I tried to fix the mentioned issue I ran into more and more subtle things that were interwoven)
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11215

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 13:38:23 +00:00
Lukas Wirth
87735e5e9e Update item tree test output 2022-01-07 14:29:58 +01:00
bors[bot]
c09504bd58
Merge #11194
11194: fix(gen-doc-assist): remove lifetimes in description of `new` r=Veykril a=numero-744

From wrong behavior:

```rust
/// Creates a new [`MyGenericStruct<'a, T>`].
```

to correct behavior:

```rust
/// Creates a new [`MyGenericStruct<T>`].
```

But I feel like there is a better way to implement it. Do you know if there is an existing function that could do the work of `lifetimes_removed()` below?

Co-authored-by: Côme ALLART <come.allart@etu.emse.fr>
2022-01-07 13:24:58 +00:00
Lukas Wirth
ca4baa6e55 Use FileAstId<ast::Adt> in nameres where appropriate instead 2022-01-07 14:20:27 +01:00
Jeroen Vannevel
4bcdb05325
include tabstops 2022-01-07 13:17:21 +00:00
Lukas Wirth
08adce61a1 Better interface for doc comment and attribute processing 2022-01-07 14:14:33 +01:00
Benjamin Coenen
b60a29ca94 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 14:13:34 +01:00
Côme ALLART
1b5c60f549 refactor: apply suggestions
See PR #11194
2022-01-07 14:07:35 +01:00
Coenen Benjamin
0a4239a815
Update crates/rust-analyzer/src/config.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 14:07:02 +01:00
Jeroen Vannevel
778e71b15f
fmt 2022-01-07 12:40:41 +00:00
Jeroen Vannevel
76e0429048
concise filtering 2022-01-07 12:34:03 +00:00
Lukas Wirth
69dbfc7754 Generate AnyHasDocComments node 2022-01-07 12:38:18 +01:00
Jeroen Vannevel
734193bc23 support const params 2022-01-07 01:09:32 +00:00
Jeroen Vannevel
b6201051b2 Count the type parameters only 2022-01-07 01:02:16 +00:00
bors[bot]
2fb6f5e46a
Merge #11218
11218: fix: Correct has_ref detection, avoiding duplicate &mut insertion on parameter completion r=Veykril a=weirane

The original code fails to detect there's a ref in scenarios such as `&mut s` and `& s` because `WHITESPACE` and `IDENT` got reversed.

Closes #11199.

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-06 23:17:51 +00:00
Wang Ruochen
3a57f700d8
Correct has_ref detection 2022-01-06 11:46:28 -08:00
Benjamin Coenen
f4ce0d78bb add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-06 15:42:29 +01:00
Laurențiu Nicola
e14d9208f5 Move pretty-printing test out of assist 2022-01-06 16:38:25 +02:00
bors[bot]
5c47eb6bf8
Merge #11216
11216: internal: Support registered tools and attributes in ide layer r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-06 13:57:17 +00:00
Lukas Wirth
dc135cc076 internal: Support registered tools and attributes in ide layer 2022-01-06 14:56:50 +01:00
Lukas Wirth
dd20a6f701 feat: poke user when supplying faulty configurations 2022-01-06 14:24:19 +01:00
bors[bot]
8887d2016f
Merge #11193
11193: feat: Add config to replace specific proc-macros with dummy expanders r=Veykril a=Veykril

With this one can specify proc-macros from crates to expand into their input as a (temporary) workaround for the current completion problems with some of the bigger attribute proc-macros like `async_trait`.

This could've been done by just not expanding these macros, but that would require fiddling with nameres. I felt like this approach was simpler to pull off while also keeping the behaviour of the attributes/proc-macro in that they still expand instead of being dead syntax to us.

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

Usage(`async_trait` as example):
```jsonc
    "rust-analyzer.procMacro.dummies": {
        "async-trait": [ // crate name(as per its cargo.toml definition, not the dependency name)
            "async_trait" // exported proc-macro name
        ]
    },
```

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-06 12:53:49 +00:00
Lukas Wirth
f6eba28ef8 Adjust config name 2022-01-06 13:50:35 +01:00
Lukas Wirth
dd4b53402d Regenrate docs and package.json 2022-01-06 13:50:24 +01:00
Lukas Wirth
aecf26d09b feat: Add config to replace specific proc-macros with dummy expanders 2022-01-06 13:50:18 +01:00
Jonas Schievink
b1d6aea394 Fix parsing of #[derive] paths 2022-01-06 13:39:20 +01:00
Jonas Schievink
9dd42cd1e1 Useconst _ instead of mod __ 2022-01-06 12:55:33 +01:00
bors[bot]
7585127b92
Merge #11208
11208: feat: expand attribute macros on impl and trait items r=jonas-schievink a=jonas-schievink

fixes https://github.com/rust-analyzer/rust-analyzer/issues/11104

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-01-06 11:31:19 +00:00
Jonas Schievink
3ff68f25b8 Expand attribute macros on impl and trait items 2022-01-06 12:30:16 +01:00
Jonas Platte
c90c88b083
Always put a space after impl in macro pretty-printing
… regardless of whether the next symbol is punctuation or not.
2022-01-06 11:33:08 +01:00
Côme ALLART
c2d3f90886 fix: remove brackets if no generic types 2022-01-06 01:51:04 +01:00
bors[bot]
2e33bf23c9
Merge #11204
11204: fix: `replace_qualified_name_with_use` does not use full item path for replacements r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05 22:47:30 +00:00
Lukas Wirth
2d33cdf188 fix: replace_qualified_name_with_use does not use full item path for replacements 2022-01-05 23:46:58 +01:00
bors[bot]
ada51f2ac4
Merge #11195 #11202
11195: Correctly pass through reference modifiers when extracting a variable r=Veykril a=Vannevelj

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

This will parse the field expression and look at whether it is marked `&` or `&mut` and include a modifier if appropriate. The original issue only mentions `&mut params` but I've found that this issue also occurs for `&mut locals` as well as `&params` and `&locals` so I've also added tests for them.

I'd definitely be interested in hearing where I can make my code more idiomatic for Rust.

11202: fix: Fix `apply_demorgan` assist hanging for certain binary expressions r=Veykril a=Veykril

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

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05 21:30:50 +00:00
Lukas Wirth
b92ed115c1 fix: Fix apply_demorgan assist hanging for certain binary expressions 2022-01-05 22:30:19 +01:00
Jeroen Vannevel
035a373a6a
removed double matching 2022-01-05 21:16:24 +00:00
Jeroen Vannevel
771c87f890
no PathExpr arm 2022-01-05 21:12:09 +00:00
Jeroen Vannevel
8c0b848694
.clone() over .to_owned() 2022-01-05 21:10:03 +00:00
Jeroen Vannevel
2724b35490
less wordy ref_kind assignment 2022-01-05 21:08:46 +00:00
bors[bot]
735b542146
Merge #11201
11201: fix: Fix completions not considering ancestor items for attribute search r=Veykril a=Veykril

Turns out we never filled the `CompletionContext` with the attribute expansion of attributed impls and traits when typing in the assoc items, as we were only considering the assoc item to have an attribute to expand.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05 20:45:27 +00:00
Lukas Wirth
bd91327079 fix: Fix completions not considering ancestor items for attribute search 2022-01-05 21:44:56 +01:00
bors[bot]
149981fbfc
Merge #11200
11200: Always put a space after dyn in macro pretty-printing r=Veykril a=jplatte

Fixes #11100.

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-01-05 20:04:49 +00:00
Jonas Platte
b8f4667aa9
Always put a space after dyn in macro pretty-printing
… regardless of whether the next symbol is punctuation or not.
Fixes issue 11100.
2022-01-05 18:06:50 +01:00
Jonas Platte
f5b789b1dc
Add failing test case for issue 11100 2022-01-05 18:04:36 +01:00
Jonas Schievink
3eddda6f4c simplify 2022-01-05 17:26:34 +01:00
Aaron Hill
04cb85032f
Remove unused lifetime 2022-01-05 10:19:10 -05:00
Jeroen Vannevel
053ae2452c
removed trailing whitespace 2022-01-05 02:16:22 +00:00
Jeroen Vannevel
abab0154b6
comment 2022-01-05 01:48:57 +00:00
Jeroen Vannevel
fa0afb9576
additional test for a reference local (on top of mutable reference local) 2022-01-05 01:36:04 +00:00
Jeroen Vannevel
4c1a1b2570
failing test for a reference local 2022-01-05 01:27:15 +00:00
Jeroen Vannevel
cd5ad4e500
Don't include a ref if none was declared 2022-01-05 01:18:55 +00:00
Jeroen Vannevel
817f47828c
support ref params as well 2022-01-05 01:15:54 +00:00
Jeroen Vannevel
056e18fcbd
correctly handle mutable references 2022-01-05 01:03:27 +00:00
Côme ALLART
4a5341e044 fix(gen-doc-assist): remove lifetimes in description of new 2022-01-05 00:23:36 +01:00
bors[bot]
c5049bdcda
Merge #11190
11190: fix(completions): improve fn_param r=dbofmmbt a=dbofmmbt

- insert commas around when necessary
- only suggest `self` completions when param list is empty
- stop suggesting completions for identifiers which are already on the param list

Closes #11085 

Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2022-01-04 22:40:10 +00:00
Eduardo Canellas
a973e5a9db refactor: apply review suggestions 2022-01-04 19:30:57 -03:00
bors[bot]
ac3ea3e81c
Merge #11112
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi

cc #8655 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-04 21:51:37 +00:00
hkalbasi
75c2acae6e Evaluate constants in array repeat expression 2022-01-05 01:17:01 +03:30
Eduardo Canellas
30b7e92afa remove forgotten dbg macro 2022-01-04 15:37:10 -03:00
Eduardo Canellas
838944b387 improve logic for trailing comma addition 2022-01-04 15:30:30 -03:00
Eduardo Canellas
a9612666f8 fix(completions): improve fn_param
- insert commas around when necessary
- only suggest `self` completions when param list is empty
- stop suggesting completions for identifiers which are already on the param list
2022-01-04 15:03:46 -03:00
Lukas Wirth
c5a9985fc5 Remove lossy Definition::from_token/Definition::from_node methods 2022-01-04 18:29:53 +01:00
bors[bot]
68bc12c3b8
Merge #11157
11157: internal: Remove `SemanticScope::speculative_resolve_as_mac` r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-04 16:49:47 +00:00
Benjamin Coenen
336c899a07 add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
Laurențiu Nicola
c934a99fd3 Rename and use the 1.55 ABI for 1.54 2022-01-04 14:06:26 +02:00
bors[bot]
dbb1c1b4b1
Merge #11184
11184: Correctly pass through mutable parameter references when extracting a function r=Veykril a=Vannevelj

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

I have based this investigation based on my understanding of [the Borrowing chapter](https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html) but I wasn't able to debug the test runs or see it in action in an IDE. I'll try to figure out how to do that for future PRs but for now, the tests seem to confirm my understanding. I'll lay out my hypothesis below.

Here we define the parameters for the to-be-generated function: 

7409880a07/crates/ide_assists/src/handlers/extract_function.rs (L882)

Three values in particular are important here: `requires_mut`, `is_copy` and `move_local`. These will in turn be used here to determine the kind of parameter:

7409880a07/crates/ide_assists/src/handlers/extract_function.rs (L374-L381)

and then here to determine what transformation is needed for the calling argument:

7409880a07/crates/ide_assists/src/handlers/extract_function.rs (L383-L390)

which then gets transformed here:

7409880a07/crates/syntax/src/ast/make.rs (L381-L383)

What I believe is happening is that 
* `requires_mut` is `false` (it already is marked as mutable), 
* `is_copy` is `false` (`Foo` does not implement `Copy`), and 
* `move_local` is `false` (it has further usages)

According to the pattern matching in `fn kind()`, that would lead to `ParamKind::SharedRef` which in turn applies a transformation that prepends `&`.

However if I look at the chapter on borrowing then we only need to mark an argument as a reference if we actually own it. In this case the value is passed through as a reference parameter into the current function which means we never had ownership in the first place. By including the additional check for a reference parameter, `move_local` now becomes `true` and the resulting parameter is now `ParamKind::Value` which will avoid applying any transformations. This was further obscured by the fact that you need further usages of the variable or `move_local` would be considered `true` after all.

I didn't follow it in depth but it appears this idea applies for both the generated argument and the generated parameter.
There are existing tests that account for `&mut` values but they refer to local variables for which we do have ownership and as such they didn't expose this issue.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-01-04 10:19:37 +00:00
Jeroen Vannevel
ec61abbe93 reduced the tests to their bare essence 2022-01-04 10:11:04 +00:00
bors[bot]
22edf2e8a0
Merge #11186
11186: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-04 09:57:22 +00:00
Lukas Wirth
5fbdf20765 minor: Simplify 2022-01-04 10:56:28 +01:00
Jeroen Vannevel
5beddf93e7 additional test without further usages 2022-01-04 02:12:53 +00:00
Jeroen Vannevel
95cabfd722 Correctly pass through mutable references when extracting a function 2022-01-04 01:48:08 +00:00
bors[bot]
7409880a07
Merge #11061
11061: Support "move if to guard" for if else chains r=weirane a=weirane

The idea is to first parse the if else chain into a vector of `(Condition, BlockExpr)`s until we reach an iflet branch, an else branch, or the end (the tail). Then add the match arms with guard for the vector, and add the tail with no if guard.

Because the whole original match arm is replaced and the generated code doesn't have redundent commas, I removed redundent commas in some test cases.

Closes #11033.

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-03 17:59:00 +00:00
Wang Ruochen
95145d5ab6
Update generated tests 2022-01-03 09:48:50 -08:00
Wang Ruochen
a19a32488d
Don't add pattern if there is a catch all afterwards 2022-01-03 09:38:45 -08:00
bors[bot]
b14af5cc6f
Merge #11115
11115: internal: refactor: avoid separate traversal in replace filter map next with find map r=Veykril a=rainy-me

fix: #7428

Co-authored-by: rainy-me <github@yue.coffee>
2022-01-03 16:00:05 +00:00
Lukas Wirth
19f1ff5c70 give resolve_derive_ident a more robust api 2022-01-03 16:00:45 +01:00
David Hotham
b7cabf1e44
fix: don't panic on seeing an unexpected offset 2022-01-03 14:49:47 +00:00
bors[bot]
1ba9a924d7
Merge #11180
11180: minor: add missing test r=matklad a=matklad

This test kills the following mutant:

diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index 9d2b1da9a..055d9a733 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
`@@` -134,7 +134,7 `@@` impl<'a> TtIter<'a> {
         self.inner = self.inner.as_slice()[res.len()..].iter();
         let res = match res.len() {
             1 => Some(res[0].cloned()),
-            0 => None,
+            // 0 => None,
             _ => Some(tt::TokenTree::Subtree(tt::Subtree {
                 delimiter: None,
                 token_trees: res.into_iter().map(|it| it.cloned()).collect(),

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-03 14:22:37 +00:00
Aleksey Kladov
b688d84a4b minor: add missing test
This test kills the following mutant:

diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index 9d2b1da9a..055d9a733 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
@@ -134,7 +134,7 @@ impl<'a> TtIter<'a> {
         self.inner = self.inner.as_slice()[res.len()..].iter();
         let res = match res.len() {
             1 => Some(res[0].cloned()),
-            0 => None,
+            // 0 => None,
             _ => Some(tt::TokenTree::Subtree(tt::Subtree {
                 delimiter: None,
                 token_trees: res.into_iter().map(|it| it.cloned()).collect(),
2022-01-03 17:21:43 +03:00
bors[bot]
120d76e0a3
Merge #11179
11179: minor: simplify mbe matcher r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-03 13:28:56 +00:00
Aleksey Kladov
303814189a simplify 2022-01-03 16:27:16 +03:00
Aleksey Kladov
966983c707 simplify 2022-01-03 16:22:41 +03:00
Dániel Buga
2e472bb746 Fix replace_match_with_if_let removing blocks with modifiers
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2022-01-03 14:07:34 +01:00
bors[bot]
8e9ccbf97a
Merge #11177
11177: internal: dont descend into comments r=Veykril a=jhgg

fixes #11176

Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-01-03 02:03:03 +00:00
Jake Heinz
04decd5e6b internal: dont descend into comments 2022-01-03 01:53:58 +00:00