]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #7147
bors[bot] [Mon, 4 Jan 2021 20:36:13 +0000 (20:36 +0000)]
Merge #7147

7147: ssr: Allow replacing expressions with statements r=davidlattimore a=MarijnS95

Depends on #6587

Until that is merged, the diff is https://github.com/MarijnS95/rust-analyzer/compare/stmt..replace-expr-with-stmt

---

Now that statements can be matched and replaced (#6587) some usecases require expressions to be replaced with statements as well. This happens when something that can ambiguously be an expression or statement like `if` and loop blocks appear in the last position of a block, as trailing expression. In this case a replacement pattern of the form `if foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of statements but not if they (implicitly) end up in the trailing expression, where they are not wrapped by an EXPR_STMT (but the pattern and template are, as parsing only succeeds for the `stmt ==>> stmt` case).

Instead of adding two rules that match an expression - and emit duplicate matching errors - allow the template for expressions to be a statement if it fails to parse as an expression.

---

Another gross change that does not seem to break any tests currently, but perhaps a safeguard should be added to only allow this kind of replacement in blocks by "pushing" the replacement template to the statement list and clearing the trailing expression?

CC @davidlattimore

Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
3 years agoMerge #7159
bors[bot] [Mon, 4 Jan 2021 18:02:54 +0000 (18:02 +0000)]
Merge #7159

7159: Refactor mbe to reduce clone and copying r=edwin0cheng a=edwin0cheng

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoSimplify SubtreeTokenSource
Edwin Cheng [Mon, 4 Jan 2021 17:50:34 +0000 (01:50 +0800)]
Simplify SubtreeTokenSource

3 years agoRefactor TokenBuffer for reduc cloning
Edwin Cheng [Mon, 4 Jan 2021 16:22:42 +0000 (00:22 +0800)]
Refactor TokenBuffer for reduc cloning

3 years agoMerge #7157
bors[bot] [Mon, 4 Jan 2021 16:13:53 +0000 (16:13 +0000)]
Merge #7157

7157: Update crates r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUpdate crates
kjeremy [Mon, 4 Jan 2021 16:12:42 +0000 (11:12 -0500)]
Update crates

3 years agoReduce string copying
Edwin Cheng [Mon, 4 Jan 2021 16:11:56 +0000 (00:11 +0800)]
Reduce string copying

3 years agoMerge #7156
bors[bot] [Mon, 4 Jan 2021 15:41:56 +0000 (15:41 +0000)]
Merge #7156

7156: Rename extension config r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoRename extension config
Aleksey Kladov [Mon, 4 Jan 2021 15:39:15 +0000 (18:39 +0300)]
Rename extension config

3 years agoMerge #7154
bors[bot] [Mon, 4 Jan 2021 15:23:53 +0000 (15:23 +0000)]
Merge #7154

7154: Show goto type actions for Const and TypeParams r=matklad a=Veykril

Shows goto type actions for type parameters:
![Code_6hn3rowu9M](https://user-images.githubusercontent.com/3757771/103547890-42aaeb00-4ea5-11eb-8ac7-f166869af5f8.png)

Shows goto type actions for const parameters:
![Code_8UFCcbZL3z](https://user-images.githubusercontent.com/3757771/103547891-43438180-4ea5-11eb-91e8-50681e4d831e.png)

Also shows implementations for `Self`:
![Code_eQj1pWfser](https://user-images.githubusercontent.com/3757771/103547892-43438180-4ea5-11eb-9122-461f2e0fdd01.png)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7155
bors[bot] [Mon, 4 Jan 2021 15:04:23 +0000 (15:04 +0000)]
Merge #7155

7155: Fix x86_64-pc-windows-msvc artifact name r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFix x86_64-pc-windows-msvc artifact name
Laurențiu Nicola [Mon, 4 Jan 2021 15:02:17 +0000 (17:02 +0200)]
Fix x86_64-pc-windows-msvc artifact name

3 years agoMerge #7151
bors[bot] [Mon, 4 Jan 2021 14:57:18 +0000 (14:57 +0000)]
Merge #7151

7151: Allow download of aarch64-pc-windows-msvc binaries r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoShow GotoTypeAction for TypeParam
Lukas Wirth [Mon, 4 Jan 2021 14:44:19 +0000 (15:44 +0100)]
Show GotoTypeAction for TypeParam

3 years agoMerge #7153
bors[bot] [Mon, 4 Jan 2021 14:47:16 +0000 (14:47 +0000)]
Merge #7153

7153: rename exrtract_assignment -> pull r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoAllow download of aarch64-pc-windows-msvc binaries
Laurențiu Nicola [Mon, 4 Jan 2021 12:58:02 +0000 (14:58 +0200)]
Allow download of aarch64-pc-windows-msvc binaries

3 years agoShow GotoTypeAction for ConstParam
Lukas Wirth [Mon, 4 Jan 2021 14:19:09 +0000 (15:19 +0100)]
Show GotoTypeAction for ConstParam

3 years agoShow implementations when hovering over SelfType
Lukas Wirth [Mon, 4 Jan 2021 13:57:59 +0000 (14:57 +0100)]
Show implementations when hovering over SelfType

3 years agoMerge #7152
bors[bot] [Mon, 4 Jan 2021 13:44:21 +0000 (13:44 +0000)]
Merge #7152

7152: Implement hover for ConstParam r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agorename exrtract_assignment -> pull
Aleksey Kladov [Mon, 4 Jan 2021 13:38:34 +0000 (16:38 +0300)]
rename exrtract_assignment -> pull

Vertical code motions are conventionally called "pull up" / "push
down".

"extract" is used for introducing new names.

3 years agoFix HoverAction::Implementation typo
Lukas Wirth [Mon, 4 Jan 2021 13:24:37 +0000 (14:24 +0100)]
Fix HoverAction::Implementation typo

3 years agoImplement hover for ConstParam
Lukas Wirth [Mon, 4 Jan 2021 13:18:31 +0000 (14:18 +0100)]
Implement hover for ConstParam

3 years agoMerge #7149
bors[bot] [Mon, 4 Jan 2021 12:57:28 +0000 (12:57 +0000)]
Merge #7149

7149: Implement hovering for TypeParams r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7148
bors[bot] [Mon, 4 Jan 2021 11:29:06 +0000 (11:29 +0000)]
Merge #7148

7148: Build aarch64-pc-windows-msvc releases r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoImpl hovering for TypeParams
Lukas Wirth [Fri, 1 Jan 2021 23:05:51 +0000 (00:05 +0100)]
Impl hovering for TypeParams

3 years agoMerge #6587
bors[bot] [Mon, 4 Jan 2021 11:14:40 +0000 (11:14 +0000)]
Merge #6587

6587: SSR: Support statement matching and replacing r=davidlattimore a=MarijnS95

For #3186

Hi!

This is a smaller initial patchset that came up while working on support for statement lists (and my first time working on RA :grin:). It has me stuck on trailing semicolons for which I hope to receive some feedback. Matching (and replacing) `let` bindings with a trailing semicolon works fine, but trying to omit these (to make patterns more ergonomic) turns out more complex than expected.

The "optional trailing semicolon solution" implemented in this PR is ugly because `Matcher::attempt_match_token` should only consume a trailing `;` when parsing `let` bindings to prevent other code from breaking. That at the same time has a nasty side-effect of `;` ending up in the matched code: any replacements on that should include the trailing semicolon as well even if it was not in the pattern. A better example is in the tests:

https://github.com/rust-analyzer/rust-analyzer/blob/3ae1649c24a689473b874c331f5f176e5839978e/crates/ssr/src/tests.rs#L178-L184

The end result to achieve is (I guess) allowing replacement of let bindings without trailing semicolon like `let x = $a ==>> let x = 1` (but including them on both sides is still fine), and should make replacement in a macro call (where `foo!(let a = 2;)` for a `$x:stmt` is invalid syntax) possible as well. That should allow to enable/fix these tests:

https://github.com/rust-analyzer/rust-analyzer/blob/3ae1649c24a689473b874c331f5f176e5839978e/crates/ssr/src/tests.rs#L201-L214

A possible MVP of this PR might be to drop this optional `;' handling entirely and only allow an SSR pattern/template with semicolons on either side.

Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
3 years agoBuild aarch64-pc-windows-msvc releases
Laurențiu Nicola [Mon, 4 Jan 2021 10:04:58 +0000 (12:04 +0200)]
Build aarch64-pc-windows-msvc releases

3 years agossr: Allow replacing expressions with statements
Marijn Suijten [Sun, 3 Jan 2021 16:45:49 +0000 (17:45 +0100)]
ssr: Allow replacing expressions with statements

Now that statements can be matched and replaced (#6587) some usecases
require expressions to be replaced with statements as well. This happens
when something that can ambiguously be an expression or statement like
`if` and loop blocks appear in the last position of a block, as trailing
expression. In this case a replacement pattern of the form `if
foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of
statements but not if they (implicitly) end up in the trailing
expression, where they are not wrapped by an EXPR_STMT (but the pattern
and template are, as parsing only succeeds for the `stmt ==>> stmt`
case).

Instead of adding two rules that match an expression - and emit
duplicate matching errors - allow the template for expressions to be a
statement if it fails to parse as an expression.

3 years agoMerge #7113
bors[bot] [Sun, 3 Jan 2021 18:22:07 +0000 (18:22 +0000)]
Merge #7113

7113: Manual updates r=matklad a=tekul

Add some details on how to build the manual and some clarification on how to deal with "proc macro2 warnings.

For context, this arose from [this question](https://users.rust-lang.org/t/how-to-disable-rust-analyzer-proc-macro-warnings-in-neovim/53150) on users.rust-lang.org.

Co-authored-by: Luke Taylor <tekul.hs@gmail.com>
3 years agoMerge #7138
bors[bot] [Sun, 3 Jan 2021 18:14:12 +0000 (18:14 +0000)]
Merge #7138

7138: Support assignment to FieldExpr for extract_assignment assist r=matklad a=Jesse-Bakker

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoSupport assignment to FieldExpr for extract_assignment assist
Jesse Bakker [Sun, 3 Jan 2021 13:11:42 +0000 (14:11 +0100)]
Support assignment to FieldExpr for extract_assignment assist

3 years agoMerge #7139
bors[bot] [Sun, 3 Jan 2021 13:54:53 +0000 (13:54 +0000)]
Merge #7139

7139: Upgrade expect-test to 1.1 r=matklad a=Jesse-Bakker

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoUpgrade expect-test to 1.1
Jesse Bakker [Sun, 3 Jan 2021 13:43:29 +0000 (14:43 +0100)]
Upgrade expect-test to 1.1

3 years agossr: Add tests for raw LetStmt matching
Marijn Suijten [Tue, 17 Nov 2020 14:33:10 +0000 (15:33 +0100)]
ssr: Add tests for raw LetStmt matching

3 years agoparser,syntax: Add separate parser for stmt with optional semicolon
Marijn Suijten [Tue, 17 Nov 2020 19:02:46 +0000 (20:02 +0100)]
parser,syntax: Add separate parser for stmt with optional semicolon

Adjusting `grammar::fragments::stmt` to Optional or Yes will break
original functionality and tests.

3 years agoMerge #7137
bors[bot] [Sun, 3 Jan 2021 10:48:41 +0000 (10:48 +0000)]
Merge #7137

7137: Revert "Proper handling $crate and local_inner_macros" r=jonas-schievink a=jonas-schievink

Reverts rust-analyzer/rust-analyzer#7133

It caused a fairly significant performance regression.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRevert "Proper handling $crate and local_inner_macros"
Jonas Schievink [Sun, 3 Jan 2021 10:47:57 +0000 (11:47 +0100)]
Revert "Proper handling $crate and local_inner_macros"

3 years agosyntax,ssr: Implement statement parsing
Marijn Suijten [Tue, 17 Nov 2020 14:34:41 +0000 (15:34 +0100)]
syntax,ssr: Implement statement parsing

3 years agoMerge #7136
bors[bot] [Sun, 3 Jan 2021 09:58:32 +0000 (09:58 +0000)]
Merge #7136

7136: Fixed nested eager macro bug r=edwin0cheng a=edwin0cheng

fixes #7126

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFixed nested eager macro bug
Edwin Cheng [Sun, 3 Jan 2021 09:56:59 +0000 (17:56 +0800)]
Fixed nested eager macro bug

3 years agoMerge #7068
bors[bot] [Sun, 3 Jan 2021 09:03:15 +0000 (09:03 +0000)]
Merge #7068

7068: Add VSCode command to view the hir of a function body r=theotherphil a=theotherphil

Will fix https://github.com/rust-analyzer/rust-analyzer/issues/7061. Very rough initial version just to work out where I needed to wire everything up.

@matklad would you be happy merging a hir visualiser of some kind? If so, do you have any thoughts on what you'd like it show, and how?

I've spent very little time on this thus far, so I'm fine with throwing away the contents of this PR, but I want to avoid taking the time to make this more polished/interactive/useful only to discover that no-one else has any interest in this functionality.

![image](https://user-images.githubusercontent.com/1974256/103236081-bb58f700-493b-11eb-9d12-55ae1b870f8f.png)

Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
3 years agoMerge #7115
bors[bot] [Sun, 3 Jan 2021 08:56:17 +0000 (08:56 +0000)]
Merge #7115

7115: Migrate HasSource::source to return Option r=matklad a=nick96

I've made a start on fixing #6913 based on the provided work plan, migrating `HasSource::source` to return an `Option`. The simple cases are migrated but there are a few that I'm unsure exactly how they should be handled:

- Logging the processing of functions in `AnalysisStatsCmd::run`: In verbose mode it includes the path to the module containing the function and the syntax range. I've handled this with an if-let but would it be better to blow up here with `expect`? I'm not 100% on the code paths but if we're processing a function definition then the source should exist.

I've handled `source()` in all code paths as `None` being a valid return value but are there some cases where we should just blow up? Also, all I've done is bubble up the returned `None`s, there may be some places where we can recover and still provide something.

Co-authored-by: Nick Spain <nicholas.spain@stileeducation.com>
Co-authored-by: Nick Spain <nicholas.spain96@gmail.com>
3 years agoUse stdx::format_to instead of writeln
Phil Ellison [Sun, 3 Jan 2021 08:54:33 +0000 (08:54 +0000)]
Use stdx::format_to instead of writeln

3 years agoMerge #7128
bors[bot] [Sun, 3 Jan 2021 08:49:59 +0000 (08:49 +0000)]
Merge #7128

7128: Implement HasAttrs for GenericParam r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7135
bors[bot] [Sat, 2 Jan 2021 20:47:27 +0000 (20:47 +0000)]
Merge #7135

7135: Fix warnings on nightly r=lnicola a=cynecx

Co-authored-by: cynecx <me@cynecx.net>
3 years agoUse fully qualified `Itertools::intersperse` call to silence nightly warnings about...
cynecx [Sat, 2 Jan 2021 19:58:06 +0000 (20:58 +0100)]
Use fully qualified `Itertools::intersperse` call to silence nightly warnings about a potential name collision due to recent libstd api additions

3 years agoFix warnings on rust-nightly
cynecx [Sat, 2 Jan 2021 19:48:39 +0000 (20:48 +0100)]
Fix  warnings on rust-nightly

3 years agoMerge #7133
bors[bot] [Sat, 2 Jan 2021 17:42:45 +0000 (17:42 +0000)]
Merge #7133

7133: Proper handling $crate and local_inner_macros r=jonas-schievink a=edwin0cheng

This PR introduces `HygineFrames` to store the macro definition/call site hierarchy in hyginee and when resolving `local_inner_macros` and `$crate`, we use the token to look up the corresponding frame and return the correct value.

See also: https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies

fixe #6890 and  #6788

r? @jonas-schievink

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoMerge #7130
bors[bot] [Sat, 2 Jan 2021 16:23:06 +0000 (16:23 +0000)]
Merge #7130

7130: Add extract_assignment assist r=Jesse-Bakker a=Jesse-Bakker

Add extract-assignment assist (#7006).

Assist is for now only implemented on if/match-statements where the assigment is the last statement in every block,
as for other cases, one would have to check whether the assignment has effects on the rest of the block and
extract a temporary variable for it in the block.

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoAdd support for MatchExpr to extract_assigment assist
Jesse Bakker [Sat, 2 Jan 2021 14:33:23 +0000 (15:33 +0100)]
Add support for MatchExpr to extract_assigment assist

3 years agoAdd extract-assignment assist
Jesse Bakker [Sat, 2 Jan 2021 00:55:56 +0000 (01:55 +0100)]
Add extract-assignment assist

3 years agoUse arena instead of vec
Edwin Cheng [Sat, 2 Jan 2021 14:48:22 +0000 (22:48 +0800)]
Use arena instead of vec

3 years agoMerge #7134
bors[bot] [Sat, 2 Jan 2021 14:16:26 +0000 (14:16 +0000)]
Merge #7134

7134: Fix infer error of macro invocation in array expr r=edwin0cheng a=edwin0cheng

Fixed following infer error:

```rust
macro_rules! bar { () => {0u32} }
fn test() {
    let a = [bar!()];   // a : [unknown]
}
```

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix infer error of macro invocation in array expr
Edwin Cheng [Sat, 2 Jan 2021 14:06:59 +0000 (22:06 +0800)]
Fix infer error of macro invocation in array expr

3 years agoIntroduce HygieneFrames for proper token hyginee
Edwin Cheng [Sat, 2 Jan 2021 12:25:05 +0000 (20:25 +0800)]
Introduce HygieneFrames for proper token hyginee

3 years agoImplement HasAttrs for Type-, Const- and LifetimeParam
Lukas Wirth [Sat, 2 Jan 2021 11:11:46 +0000 (12:11 +0100)]
Implement HasAttrs for Type-, Const- and LifetimeParam

3 years agoFix ConstParam HasSource impl and implement TryToNav not Nav
Nick Spain [Sat, 2 Jan 2021 11:11:25 +0000 (22:11 +1100)]
Fix ConstParam HasSource impl and implement TryToNav not Nav

3 years agoRemove old_source now we've fully migrated
Nick Spain [Sat, 2 Jan 2021 05:25:36 +0000 (16:25 +1100)]
Remove old_source now we've fully migrated

Fixes #6913

3 years agoHandle case where detail doesn't exist without giving up on completion
Nick Spain [Fri, 1 Jan 2021 22:48:51 +0000 (09:48 +1100)]
Handle case where detail doesn't exist without giving up on completion

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoRemove source_old from adding const and function impls
Nick Spain [Fri, 1 Jan 2021 06:30:13 +0000 (17:30 +1100)]
Remove source_old from adding const and function impls

3 years agoMake the result of Const, FunctionRender and TypeAliasRender constructors optional
Nick Spain [Fri, 1 Jan 2021 06:26:39 +0000 (17:26 +1100)]
Make the result of Const, FunctionRender and TypeAliasRender constructors optional

They use source() which now returns an Option so they need to too.

3 years agoMove impls of ToNav that use source() to TryToNav
Nick Spain [Fri, 1 Jan 2021 06:13:15 +0000 (17:13 +1100)]
Move impls of ToNav that use source() to TryToNav

3 years agoHandle missing source in target_data_for_def
Nick Spain [Fri, 1 Jan 2021 05:52:59 +0000 (16:52 +1100)]
Handle missing source in target_data_for_def

3 years agoHandle missing source in filter_assoc_items
Nick Spain [Fri, 1 Jan 2021 05:49:44 +0000 (16:49 +1100)]
Handle missing source in filter_assoc_items

3 years agoGo back to use of source_old() in offset_target_and_file_id as it's not as simple...
Nick Spain [Fri, 1 Jan 2021 04:41:41 +0000 (15:41 +1100)]
Go back to use of source_old() in offset_target_and_file_id as it's not as simple as I thought

3 years agoFix type error with .and_then
Nick Spain [Fri, 1 Jan 2021 04:41:04 +0000 (15:41 +1100)]
Fix type error with .and_then

3 years agoHandle not finding range in Definition::search_scope
Nick Spain [Fri, 1 Jan 2021 04:33:06 +0000 (15:33 +1100)]
Handle not finding range in Definition::search_scope

The `LifetimeParam` and `Local` variants use `source()` to find their
range. Now that `source()` returns an `Option` we need to handle the
`None` case.

3 years agosource_old -> source for cases that can be handled by simple bubbling
Nick Spain [Fri, 1 Jan 2021 04:02:39 +0000 (15:02 +1100)]
source_old -> source for cases that can be handled by simple bubbling

3 years agoOnly log path and syntax range when processing function if source exists
Nick Spain [Fri, 1 Jan 2021 03:38:23 +0000 (14:38 +1100)]
Only log path and syntax range when processing function if source exists

3 years agoHasSource::source_old -> HasSource::source for places where proc-macros were special...
Nick Spain [Fri, 1 Jan 2021 03:14:09 +0000 (14:14 +1100)]
HasSource::source_old -> HasSource::source for places where proc-macros were special cased

In #6901 some special case handling for proc-macros was introduced to
prevent panicing as they have no AST. Now the new HasSource::source
method is used that returns an option.

Generally this was a pretty trivial change, the only thing of much
interest is that `hir::MacroDef` now implements `TryToNav` not `ToNav`
as this allows us to handle `HasSource::source` now returning an option.

3 years agoMark HasSource::source_old as deprecated but allow at all call sites
Nick Spain [Fri, 1 Jan 2021 02:50:50 +0000 (13:50 +1100)]
Mark HasSource::source_old as deprecated but allow at all call sites

3 years agoImplement new HasSource::source for all implementors of HasSource
Nick Spain [Fri, 1 Jan 2021 02:27:38 +0000 (13:27 +1100)]
Implement new HasSource::source for all implementors of HasSource

3 years agoHasSource::source -> HasSource::source_old
Nick Spain [Fri, 1 Jan 2021 02:05:28 +0000 (13:05 +1100)]
HasSource::source -> HasSource::source_old

To start migrating HasSource::source to return an Option.

3 years agoMerge #7132
bors[bot] [Sat, 2 Jan 2021 07:52:30 +0000 (07:52 +0000)]
Merge #7132

7132: Stop using beta toolchain in xtask dist r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoStop using beta toolchain in xtask dist
Laurențiu Nicola [Sat, 2 Jan 2021 07:51:41 +0000 (09:51 +0200)]
Stop using beta toolchain in xtask dist

3 years agoImpl HasAttrs for GenericParam
Lukas Wirth [Fri, 1 Jan 2021 23:42:07 +0000 (00:42 +0100)]
Impl HasAttrs for GenericParam

3 years agoMerge #7125
bors[bot] [Fri, 1 Jan 2021 19:50:02 +0000 (19:50 +0000)]
Merge #7125

7125: Don't emit arg count diagnostics for method calls with unknown receiver r=flodiebold a=flodiebold

Fixes #7098.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoDon't emit arg count diagnostics for method calls with unknown receiver
Florian Diebold [Fri, 1 Jan 2021 19:45:49 +0000 (20:45 +0100)]
Don't emit arg count diagnostics for method calls with unknown receiver

Fixes #7098.

3 years agoRemove some unnecessary code copied from the Syntax Tree command
Phil Ellison [Fri, 1 Jan 2021 19:35:10 +0000 (19:35 +0000)]
Remove some unnecessary code copied from the Syntax Tree command

3 years agoAddress review suggestion, fix tidy tests
Phil Ellison [Fri, 1 Jan 2021 19:25:18 +0000 (19:25 +0000)]
Address review suggestion, fix tidy tests

3 years agoExpand doc on dealing with "proc macro not expanded"
Luke Taylor [Thu, 31 Dec 2020 22:28:55 +0000 (22:28 +0000)]
Expand doc on dealing with "proc macro not expanded"

Added the error message to the doc for the UnresolvedProcMacro
diagnostic, explaining that either enabling the procMacro setting
or disabling this diagnostic should make the warnings go away.

3 years agoMerge #7123
bors[bot] [Fri, 1 Jan 2021 16:33:45 +0000 (16:33 +0000)]
Merge #7123

7123: Add support for Rust 2021. r=lnicola a=m-ou-se

This adds `2021` in all places where rust-analyzer already knew about `2015` and `2018`.

The only edition-specific behaviour I could find in the source code was gated on a direct comparison with `Edition2015`, so `Edition2021` should (correctly) behave the same as `Edition2018`:

https://github.com/rust-analyzer/rust-analyzer/blob/56a7bf7ede12f6bec194265ea4a95911c9e469bd/crates/hir_def/src/nameres/path_resolution.rs#L132

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
3 years agoFormatting.
Mara Bos [Fri, 1 Jan 2021 16:31:32 +0000 (17:31 +0100)]
Formatting.

3 years agoAdd support for Rust 2021.
Mara Bos [Fri, 1 Jan 2021 16:22:23 +0000 (17:22 +0100)]
Add support for Rust 2021.

3 years agoMerge #7121
bors[bot] [Fri, 1 Jan 2021 14:20:51 +0000 (14:20 +0000)]
Merge #7121

7121: Show lifetimes and labels on hover r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoShow lifetimes and labels on hover
Lukas Wirth [Fri, 1 Jan 2021 14:07:41 +0000 (15:07 +0100)]
Show lifetimes and labels on hover

3 years agoMerge #7080
bors[bot] [Fri, 1 Jan 2021 13:45:10 +0000 (13:45 +0000)]
Merge #7080

7080: Implement ConstParams for HIR r=Veykril a=Veykril

r? @flodiebold

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAdd ConstParams to the ide layer
Lukas Wirth [Fri, 1 Jan 2021 09:07:01 +0000 (10:07 +0100)]
Add ConstParams to the ide layer

3 years agoMerge #7116
bors[bot] [Fri, 1 Jan 2021 11:06:27 +0000 (11:06 +0000)]
Merge #7116

7116: Fix deep syntax tree bug generated by proc-macro r=jonas-schievink a=edwin0cheng

This PR fixed a bug from `semver-parser` and `pest_derive` crates which generate a very deep syntax tree such that serde reject to de-serialize. To fix this bug, we disabled recursion limit in `serde` (by calling [`Deserializer::disable_recursion_limit`](https://docs.rs/serde_json/1.0.61/serde_json/struct.Deserializer.html#method.disable_recursion_limit))

I have a feeling that we still need some way to protect against bad proc-macro generating huge syntax node, but I have no  idea right now.

r? @jonas-schievink

Fixes #7103

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoAdd ConstParams to the HIR
Lukas Wirth [Fri, 1 Jan 2021 09:06:42 +0000 (10:06 +0100)]
Add ConstParams to the HIR

3 years agoMerge #7117
bors[bot] [Fri, 1 Jan 2021 07:45:19 +0000 (07:45 +0000)]
Merge #7117

7117: Use stable instead of beta on macos-11 release runner r=lnicola a=lnicola

Because beta was promoted to stable yesterday.

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoUse stable instead of beta on macos-11 release runner
Laurențiu Nicola [Fri, 1 Jan 2021 07:44:01 +0000 (09:44 +0200)]
Use stable instead of beta on macos-11 release runner

3 years agoRemove serde_stacker which depends on cc
Edwin Cheng [Fri, 1 Jan 2021 07:26:55 +0000 (15:26 +0800)]
Remove serde_stacker which depends on cc

3 years agoFix deep syntax tree bug generated by proc-macro
Edwin Cheng [Fri, 1 Jan 2021 07:09:27 +0000 (15:09 +0800)]
Fix deep syntax tree bug generated by proc-macro

3 years agoMerge #7102
bors[bot] [Fri, 1 Jan 2021 00:32:59 +0000 (00:32 +0000)]
Merge #7102

7102: Fix completion of Default struct update syntax r=Veykril a=nick96

Previously the inserted text was always `..Default::default()` which ends up as `...Default::default()`
if `.` was typed. Now  checks if the current token is `.` and inserts `.Default::default()`
if it is, so `..Default::default()` is correctly completed.

I think there's probably a better way to implement this context aware completion because I've seen it in other parts of rust-analyzer as a user but I'm not sure how to do it.

Fixes #6969

Co-authored-by: Nick Spain <nicholas.spain@stileeducation.com>
3 years agoStrip completion prefix of what has already been typed
Nick Spain [Fri, 1 Jan 2021 00:17:15 +0000 (11:17 +1100)]
Strip completion prefix of what has already been typed

Per Veykril's suggestion, this removes the need to repeat the completion text twice. It also handles the completion
in a more general case.

3 years agoAdd a test for correct completion of ..Default::default()
Nick Spain [Fri, 1 Jan 2021 00:10:02 +0000 (11:10 +1100)]
Add a test for correct completion of ..Default::default()

3 years agoMerge #7112
bors[bot] [Thu, 31 Dec 2020 23:01:23 +0000 (23:01 +0000)]
Merge #7112

7112: deny_clippy test works with cfg_attr r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agodeny_clippy test works with cfg_attr
Aleksey Kladov [Thu, 31 Dec 2020 22:58:04 +0000 (01:58 +0300)]
deny_clippy test works with cfg_attr

3 years agoExpand contributing "tip" in manual.adoc
Luke Taylor [Thu, 31 Dec 2020 16:41:32 +0000 (16:41 +0000)]
Expand contributing "tip" in manual.adoc

- Add link to asciidoc website
- Explain how to create the generated adoc files from the source code
- How to run asciidoctor to generate the manual