]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoFind IntoFuture::IntoFuture's poll method
Justin Ridgewell [Tue, 16 Aug 2022 21:53:10 +0000 (17:53 -0400)]
Find IntoFuture::IntoFuture's poll method

23 months agoSuggest `.await` when type impls IntoFuture
Justin Ridgewell [Tue, 9 Aug 2022 20:25:25 +0000 (16:25 -0400)]
Suggest `.await` when type impls IntoFuture

23 months agoImplement IntoFuture type inference
Justin Ridgewell [Tue, 9 Aug 2022 00:20:45 +0000 (20:20 -0400)]
Implement IntoFuture type inference

23 months agoAuto merge of #12947 - Veykril:switch-workspace, r=Veykril
bors [Fri, 5 Aug 2022 13:13:44 +0000 (13:13 +0000)]
Auto merge of #12947 - Veykril:switch-workspace, r=Veykril

Don't switch workspace on vfs file changes from libraries

When r-a starts up, it starts switching the workspace before all vfs
events have been processed which causes us to switch workspace multiple
times until all vfs changes have been processed. This scales with the
size of the project and its dependencies. If workspace files from
dependencies as well as the sysroot get loaded, we shouldn't switch
the workspace as those have no impact on the project workspace.

23 months agoAuto merge of #12949 - Veykril:token-pick, r=Veykril
bors [Fri, 5 Aug 2022 13:06:10 +0000 (13:06 +0000)]
Auto merge of #12949 - Veykril:token-pick, r=Veykril

fix: Fix incorrect token pick rankings

23 months agofix: Fix incorrect token pick rankings
Lukas Wirth [Fri, 5 Aug 2022 12:59:26 +0000 (14:59 +0200)]
fix: Fix incorrect token pick rankings

23 months agoAuto merge of #12948 - Veykril:classify-ops, r=Veykril
bors [Fri, 5 Aug 2022 12:55:36 +0000 (12:55 +0000)]
Auto merge of #12948 - Veykril:classify-ops, r=Veykril

feat: Handle operators like their trait functions in the IDE

Allows hover and goto implementation to work on `?`, indexing brackets, binary operators, prefix operators and `await`. Regarding `await`, hover will continue to show the keyword docs while goto implementation will bring the user to the `poll` function of the `Future` implementation.
![Code_CJmZ3FGFVn](https://user-images.githubusercontent.com/3757771/183076683-c9899bd6-60d3-461b-965f-0c0f9745e2e8.gif)

Fixes https://github.com/rust-lang/rust-analyzer/issues/12810

23 months agoSimplify
Lukas Wirth [Fri, 5 Aug 2022 12:54:14 +0000 (14:54 +0200)]
Simplify

23 months agoFix visibilities
Lukas Wirth [Fri, 5 Aug 2022 12:28:36 +0000 (14:28 +0200)]
Fix visibilities

23 months agofeat: Handle operators like their trait functions in the IDE
Lukas Wirth [Fri, 5 Aug 2022 12:16:36 +0000 (14:16 +0200)]
feat: Handle operators like their trait functions in the IDE

23 months agoDon't switch workspace on vfs file changes from libraries
Lukas Wirth [Fri, 5 Aug 2022 10:06:31 +0000 (12:06 +0200)]
Don't switch workspace on vfs file changes from libraries

When r-a starts up, it starts switching the workspace before all vfs
events have been processed which causes us to switch workspace multiple
times until all vfs changes have been processed. This scales with the
size of the project and its dependencies. If workspace files from
dependencies as well as the sysroot get loaded, we shouldn't switch
the workspace as those have no impact on the project workspace.

23 months agoAuto merge of #12946 - rust-lang:issue-template, r=lnicola
bors [Fri, 5 Aug 2022 07:09:34 +0000 (07:09 +0000)]
Auto merge of #12946 - rust-lang:issue-template, r=lnicola

Update bug_report.md

Closes https://github.com/rust-lang/rust-analyzer/issues/12944

23 months agoUpdate bug_report.md
Lukas Wirth [Fri, 5 Aug 2022 07:04:27 +0000 (09:04 +0200)]
Update bug_report.md

23 months agoUpdate bug_report.md
Lukas Wirth [Fri, 5 Aug 2022 06:42:13 +0000 (08:42 +0200)]
Update bug_report.md

23 months agoAuto merge of #12808 - Veykril:check-workspace, r=Veykril
bors [Thu, 4 Aug 2022 12:57:04 +0000 (12:57 +0000)]
Auto merge of #12808 - Veykril:check-workspace, r=Veykril

feat: Only flycheck workspace that belongs to saved file

Supercedes https://github.com/rust-lang/rust-analyzer/pull/11038

There is still the problem that all the diagnostics are cleared, only clearing diagnostics of the relevant workspace isn't easily doable though I think, will have to dig into that

23 months agoDon't flycheck while the workspace is being loaded
Lukas Wirth [Thu, 4 Aug 2022 12:01:33 +0000 (14:01 +0200)]
Don't flycheck while the workspace is being loaded

23 months agoAuto merge of #12939 - jean-santos:errors-ide-hover-wrong-place, r=Veykril
bors [Thu, 4 Aug 2022 12:42:51 +0000 (12:42 +0000)]
Auto merge of #12939 - jean-santos:errors-ide-hover-wrong-place, r=Veykril

Error Diagnostics appear in the wrong place

Fix #12436

23 months agotidy formatting
Jean santos [Thu, 4 Aug 2022 12:28:34 +0000 (09:28 -0300)]
tidy formatting

23 months agoTrigger flycheck on all transitive dependencies as well
Lukas Wirth [Thu, 4 Aug 2022 11:22:15 +0000 (13:22 +0200)]
Trigger flycheck on all transitive dependencies as well

23 months agoon hover fallback error, adds ast::type as possible node
Jean santos [Wed, 3 Aug 2022 20:37:11 +0000 (17:37 -0300)]
on hover fallback error, adds ast::type as possible node

23 months agoAuto merge of #12934 - Veykril:typing, r=Veykril
bors [Wed, 3 Aug 2022 16:23:49 +0000 (16:23 +0000)]
Auto merge of #12934 - Veykril:typing, r=Veykril

Add a setting to disable comment continuation in VSCode

Fixes https://github.com/rust-lang/rust-analyzer/issues/12928

23 months agoAdd a setting to disable comment continuation in VSCode
Lukas Wirth [Wed, 3 Aug 2022 16:22:45 +0000 (18:22 +0200)]
Add a setting to disable comment continuation in VSCode

23 months agoAuto merge of #12933 - Veykril:proc-ignored, r=Veykril
bors [Wed, 3 Aug 2022 16:11:08 +0000 (16:11 +0000)]
Auto merge of #12933 - Veykril:proc-ignored, r=Veykril

Use an empty expander for ignored non-attribute proc-macros

Identity is the wrong behaviour for anything that's not an attribute here

23 months agoUse an empty expander for ignored non-attribute proc-macros
Lukas Wirth [Wed, 3 Aug 2022 16:10:15 +0000 (18:10 +0200)]
Use an empty expander for ignored non-attribute proc-macros

23 months agoAuto merge of #12930 - lnicola:subtree-branch, r=lnicola
bors [Wed, 3 Aug 2022 06:49:13 +0000 (06:49 +0000)]
Auto merge of #12930 - lnicola:subtree-branch, r=lnicola

minor: Use the release branch in xtask promote

23 months agoUse the release branch in xtask promote
Laurențiu Nicola [Wed, 3 Aug 2022 06:48:44 +0000 (09:48 +0300)]
Use the release branch in xtask promote

23 months agoAuto merge of #12837 - DorianListens:dscheidt/generate-enum-data, r=Veykril
bors [Tue, 2 Aug 2022 19:50:01 +0000 (19:50 +0000)]
Auto merge of #12837 - DorianListens:dscheidt/generate-enum-data, r=Veykril

feat: support associated values in "Generate Enum Variant" assist

This change adds support for associated values to the "Generate Enum Variant" assist.

I've split the implementation out into 4 steps to make code review easier:
- Add "add_variant" support to the structural ast editing system in `edit_in_place`
- Migrate `generate_enum_variant` to use structural ast editing instead of string manipulation
- Support tuple fields
- Support record fields

Please let me know if I should leave the commits as-is, or squash before merging.

Fixes #12797

23 months agoSupport PathPat paths in generate_enum_variant
Dorian Scheidt [Tue, 2 Aug 2022 16:11:32 +0000 (12:11 -0400)]
Support PathPat paths in generate_enum_variant

23 months agoBe more strict about supported Paths in generate_enum_variant
Dorian Scheidt [Tue, 2 Aug 2022 15:54:00 +0000 (11:54 -0400)]
Be more strict about supported Paths in generate_enum_variant

PathType path parents don't support this assist

23 months agoSupport record fields in generate_enum_variant
Dorian Scheidt [Wed, 20 Jul 2022 18:02:21 +0000 (13:02 -0500)]
Support record fields in generate_enum_variant

23 months agoSupport tuple fields in generate_enum_variant
Dorian Scheidt [Wed, 20 Jul 2022 17:26:27 +0000 (12:26 -0500)]
Support tuple fields in generate_enum_variant

23 months agoconvert generate_enum_variant to use add_variant
Dorian Scheidt [Wed, 20 Jul 2022 17:11:00 +0000 (12:11 -0500)]
convert generate_enum_variant to use add_variant

23 months agoSupport adding variants via structural editing
Dorian Scheidt [Wed, 20 Jul 2022 17:03:18 +0000 (12:03 -0500)]
Support adding variants via structural editing

23 months agoAuto merge of #12880 - palango:while-fixup, r=Veykril
bors [Tue, 2 Aug 2022 14:08:56 +0000 (14:08 +0000)]
Auto merge of #12880 - palango:while-fixup, r=Veykril

Add syntax fixup for while loops

Part of https://github.com/rust-lang/rust-analyzer/issues/12777

This is a first iteration to gather some feedback. In particular I'm not sure if the curly braces should be added here, but I couldn't get the test to work without them. Any hints welcome!

23 months agoAuto merge of #12919 - jonas-schievink:speling, r=jonas-schievink
bors [Tue, 2 Aug 2022 13:10:12 +0000 (13:10 +0000)]
Auto merge of #12919 - jonas-schievink:speling, r=jonas-schievink

fix: Fix r-a spelling in some places

User-facing change: All commands are now rendered as "rust-analyzer: Command" rather than "Rust Analyzer: Command".

Alternative to https://github.com/rust-lang/rust-analyzer/pull/12910

Potentially controversial, since other extensions don't do this, so I won't self-approve.

23 months agoAuto merge of #12920 - jonas-schievink:arm-release, r=jonas-schievink
bors [Mon, 1 Aug 2022 14:17:53 +0000 (14:17 +0000)]
Auto merge of #12920 - jonas-schievink:arm-release, r=jonas-schievink

feat: Publish extension for 32-bit ARM systems

23 months agoDon't run on PRs
Jonas Schievink [Mon, 1 Aug 2022 14:16:22 +0000 (16:16 +0200)]
Don't run on PRs

23 months agoUpload arm-unknown-linux-gnueabihf build artifact
Laurențiu Nicola [Mon, 1 Aug 2022 13:54:54 +0000 (16:54 +0300)]
Upload arm-unknown-linux-gnueabihf build artifact

23 months agoFix linker env var name
Laurențiu Nicola [Mon, 1 Aug 2022 13:46:18 +0000 (16:46 +0300)]
Fix linker env var name

23 months agoFix target check
Jonas Schievink [Mon, 1 Aug 2022 13:22:02 +0000 (15:22 +0200)]
Fix target check

23 months agoSet linker
Jonas Schievink [Mon, 1 Aug 2022 13:09:45 +0000 (15:09 +0200)]
Set linker

23 months agoPublish extension for 32-bit ARM systems
Jonas Schievink [Mon, 1 Aug 2022 12:26:20 +0000 (14:26 +0200)]
Publish extension for 32-bit ARM systems

23 months agoFix r-a spelling in some places
Jonas Schievink [Mon, 1 Aug 2022 11:47:09 +0000 (13:47 +0200)]
Fix r-a spelling in some places

23 months agoAuto merge of #12918 - lowr:fix/doctest-names, r=Veykril
bors [Mon, 1 Aug 2022 10:12:59 +0000 (10:12 +0000)]
Auto merge of #12918 - lowr:fix/doctest-names, r=Veykril

fix: remove whitespaces from doctest names

When rustdoc runs doctests, it removes whitespaces from the tests' path ([code](https://github.com/rust-lang/rust/blob/25bb1c13bd472b75ceebee3b8dcf4dcbc431a8be/src/librustdoc/doctest.rs#L951)). See https://github.com/rust-lang/rust/pull/89422 for details.

Interestingly enough, "Run doctest" has been working without much problem even though rust-analyzer hasn't followed the change. This is because cargo passes the test name to rustdoc via `--test-args` option, and then rustdoc [splits it by whitespace](https://github.com/rust-lang/rust/blob/25bb1c13bd472b75ceebee3b8dcf4dcbc431a8be/src/librustdoc/config.rs#L513-L514); the last element of the split test name **always** matches the test name that rustdoc generates.

However, it may run other tests unexpectedly (to be precise, this has long since been a thing because of the split). Consider the following example:

```rust
struct A<T, U>(T, U);
struct B<T, U>(T, U);
/// ```
/// doctest here
/// ```
impl<T, U> A<T, U> {}
/// ```
/// doctest here
/// ```
impl<T, U> B<T, U> {}
```

When you "Run doctest" either of the two, rustdoc considers "U>" one of the test specs and both doctests are run. This patch fixes it by following rustdoc and removing the whitespace from the doctests' name.

23 months agofix: remove whitespaces from doctest names
Ryo Yoshida [Mon, 1 Aug 2022 07:48:33 +0000 (16:48 +0900)]
fix: remove whitespaces from doctest names

23 months agoAuto merge of #12915 - lnicola:promote-subtree, r=lnicola
bors [Sun, 31 Jul 2022 17:58:40 +0000 (17:58 +0000)]
Auto merge of #12915 - lnicola:promote-subtree, r=lnicola

internal: Update `xtask promote` and release instructions

Update `xtask` for the subtree workflow. This doesn't explain how to do a `rust -> RA`  sync, since that's definitely more involved, but will probably only happen rarely.

23 months agoAuto merge of #12916 - Veykril:nits, r=Veykril
bors [Sun, 31 Jul 2022 17:42:10 +0000 (17:42 +0000)]
Auto merge of #12916 - Veykril:nits, r=Veykril

minor: Properly cfg the `max` field of Limit

23 months agoGive variables more descriptive names
Lukas Wirth [Sun, 31 Jul 2022 17:27:34 +0000 (19:27 +0200)]
Give variables more descriptive names

23 months agoProperly cfg the `max` field of Limit
Lukas Wirth [Sun, 31 Jul 2022 17:27:20 +0000 (19:27 +0200)]
Properly cfg the `max` field of Limit

23 months agoUpdate xtask promote and release instructions
Laurențiu Nicola [Sun, 31 Jul 2022 17:26:35 +0000 (20:26 +0300)]
Update xtask promote and release instructions

23 months agoAuto merge of #12913 - Veykril:attr-merge, r=Veykril
bors [Sat, 30 Jul 2022 07:53:48 +0000 (07:53 +0000)]
Auto merge of #12913 - Veykril:attr-merge, r=Veykril

fix: Fix ast-id up when merging raw attributes

Fixes https://github.com/rust-lang/rust-analyzer/issues/12912

23 months agofix: Fix ast-id up when merging raw attributes
Lukas Wirth [Sat, 30 Jul 2022 07:43:30 +0000 (09:43 +0200)]
fix: Fix ast-id up when merging raw attributes

23 months agoAuto merge of #12906 - cynecx:fix-completions, r=Veykril
bors [Fri, 29 Jul 2022 15:41:36 +0000 (15:41 +0000)]
Auto merge of #12906 - cynecx:fix-completions, r=Veykril

fix: complete path of existing record expr

23 months agofix: complete path of existing record expr
cynecx [Fri, 29 Jul 2022 00:27:16 +0000 (02:27 +0200)]
fix: complete path of existing record expr

2 years agoAuto merge of #12904 - lnicola:completion-builtin-filter, r=lnicola
bors [Thu, 28 Jul 2022 18:52:00 +0000 (18:52 +0000)]
Auto merge of #12904 - lnicola:completion-builtin-filter, r=lnicola

internal: Be more explicit when filtering built-in completions

We return every built-in type here, but only have `u32` in the tests, so let's look for that one to make tests more reliable across platforms.

2 years agoBe more explicit when filtering built-in completions
Laurențiu Nicola [Thu, 28 Jul 2022 18:45:47 +0000 (21:45 +0300)]
Be more explicit when filtering built-in completions

2 years agoAuto merge of #12903 - lnicola:rainbows, r=Veykril
bors [Thu, 28 Jul 2022 18:08:09 +0000 (18:08 +0000)]
Auto merge of #12903 - lnicola:rainbows, r=Veykril

Only run rainbow highlighting test on 64-bit Unix

2 years agoOnly run rainbow highlighting test on 64-bit Unix
Laurențiu Nicola [Thu, 28 Jul 2022 18:02:36 +0000 (21:02 +0300)]
Only run rainbow highlighting test on 64-bit Unix

2 years agoAuto merge of #12902 - Veykril:item-scope, r=Veykril
bors [Thu, 28 Jul 2022 17:38:59 +0000 (17:38 +0000)]
Auto merge of #12902 - Veykril:item-scope, r=Veykril

fix: Order ItemScope::entries results

2 years agofix: Order ItemScope::entries results
Lukas Wirth [Thu, 28 Jul 2022 16:49:31 +0000 (18:49 +0200)]
fix: Order ItemScope::entries results

2 years agoAuto merge of #12901 - Veykril:completion-trait-expr, r=Veykril
bors [Thu, 28 Jul 2022 15:51:30 +0000 (15:51 +0000)]
Auto merge of #12901 - Veykril:completion-trait-expr, r=Veykril

fix: Don't complete marker traits in expression position

cc https://github.com/rust-lang/rust-analyzer/issues/12196

2 years agofix: Don't complete marker traits in expression position
Lukas Wirth [Thu, 28 Jul 2022 15:49:23 +0000 (17:49 +0200)]
fix: Don't complete marker traits in expression position

2 years agoAuto merge of #12900 - pksunkara:master, r=lnicola
bors [Thu, 28 Jul 2022 15:25:07 +0000 (15:25 +0000)]
Auto merge of #12900 - pksunkara:master, r=lnicola

publish: Use cargo ws rename to rename crates

Follow up for #12716

2 years agopublish: Use cargo ws rename to rename crates
Pavan Kumar Sunkara [Thu, 28 Jul 2022 15:21:14 +0000 (16:21 +0100)]
publish: Use cargo ws rename to rename crates

2 years agoAuto merge of #12899 - Veykril:compl-qualifier, r=Veykril
bors [Thu, 28 Jul 2022 15:11:24 +0000 (15:11 +0000)]
Auto merge of #12899 - Veykril:compl-qualifier, r=Veykril

fix: Do completions in path qualifier position

Fixes https://github.com/rust-lang/rust-analyzer/issues/12566

Not too happy with the duplication needed for this, but it is what it is. Completions in path qualifiers will have to be filtered properly still, but its better to show too many completions for this than too few for now.

2 years agofix: Do completions in path qualifier position
Lukas Wirth [Thu, 28 Jul 2022 15:09:31 +0000 (17:09 +0200)]
fix: Do completions in path qualifier position

2 years agoAuto merge of #12898 - Veykril:compl-pat-brace, r=Veykril
bors [Thu, 28 Jul 2022 13:48:12 +0000 (13:48 +0000)]
Auto merge of #12898 - Veykril:compl-pat-brace, r=Veykril

fix: Fix pattern completions adding unnecessary braces

Fixes https://github.com/rust-lang/rust-analyzer/issues/12852

2 years agofix: Fix pattern completions adding unnecessary braces
Lukas Wirth [Thu, 28 Jul 2022 13:47:46 +0000 (15:47 +0200)]
fix: Fix pattern completions adding unnecessary braces

2 years agoAuto merge of #12895 - Veykril:compl-anchor, r=Veykril
bors [Thu, 28 Jul 2022 08:06:58 +0000 (08:06 +0000)]
Auto merge of #12895 - Veykril:compl-anchor, r=Veykril

fix: Calculate completions after type anchors

Fixes https://github.com/rust-lang/rust-analyzer/issues/12892

2 years agofix: Calculate completions after type anchors
Lukas Wirth [Thu, 28 Jul 2022 08:05:21 +0000 (10:05 +0200)]
fix: Calculate completions after type anchors

2 years agoAuto merge of #12891 - brennanvincent:expander_stack, r=lnicola
bors [Wed, 27 Jul 2022 19:40:59 +0000 (19:40 +0000)]
Auto merge of #12891 - brennanvincent:expander_stack, r=lnicola

Use large stack on expander thread

I have verified that this fixes #12884 for me.

Hat tip to `@bjorn3` for identifying the cause of the issue.

2 years agoUse large stack on expander thread
Brennan Vincent [Wed, 27 Jul 2022 18:34:46 +0000 (14:34 -0400)]
Use large stack on expander thread

2 years agoAdd syntax fixup for `loop`
Paul Lange [Wed, 27 Jul 2022 16:18:51 +0000 (18:18 +0200)]
Add syntax fixup for `loop`

2 years agoAdd syntax fixup for while loops
Paul Lange [Tue, 26 Jul 2022 14:10:26 +0000 (16:10 +0200)]
Add syntax fixup for while loops

2 years agoAuto merge of #12890 - Veykril:syntax-blocks, r=Veykril
bors [Wed, 27 Jul 2022 15:30:03 +0000 (15:30 +0000)]
Auto merge of #12890 - Veykril:syntax-blocks, r=Veykril

internal: Assume condition/iterable is missing if there is only a BlockExpr

cc https://github.com/rust-lang/rust-analyzer/pull/12880#issuecomment-1195567103

It sounds good on paper, so let's try it

2 years agointernal: Assume condition/iterable is missing if there is only a BlockExpr
Lukas Wirth [Wed, 27 Jul 2022 15:14:50 +0000 (17:14 +0200)]
internal: Assume condition/iterable is missing if there is only a BlockExpr

2 years agoAuto merge of #12830 - hi-rustin:rustin-patch-issue-12717-fix, r=Veykril
bors [Wed, 27 Jul 2022 12:31:26 +0000 (12:31 +0000)]
Auto merge of #12830 - hi-rustin:rustin-patch-issue-12717-fix, r=Veykril

Find original ast node before compute ref match

ref https://github.com/rust-lang/rust-analyzer/issues/12717

2 years agoFind original ast node before compute ref match in fn render
hi-rustin [Wed, 27 Jul 2022 12:18:00 +0000 (20:18 +0800)]
Find original ast node before compute ref match in fn render

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAuto merge of #12887 - Veykril:compl-pref-fix, r=Veykril
bors [Wed, 27 Jul 2022 11:48:55 +0000 (11:48 +0000)]
Auto merge of #12887 - Veykril:compl-pref-fix, r=Veykril

fix: Honor ref expressions for compute_ref_match completions

Fixes https://github.com/rust-lang/rust-analyzer/issues/8357

2 years agofix: Honor ref expressions for compute_ref_match completions
Lukas Wirth [Wed, 27 Jul 2022 11:48:26 +0000 (13:48 +0200)]
fix: Honor ref expressions for compute_ref_match completions

2 years agoAuto merge of #12886 - Veykril:sema-cache, r=Veykril
bors [Wed, 27 Jul 2022 10:46:20 +0000 (10:46 +0000)]
Auto merge of #12886 - Veykril:sema-cache, r=Veykril

fix: Fix Semantics::original_ast_node not caching the resulting file

2 years agofix: Fix Semantics::original_ast_node not caching the resulting file
Lukas Wirth [Wed, 27 Jul 2022 10:45:29 +0000 (12:45 +0200)]
fix: Fix Semantics::original_ast_node not caching the resulting file

2 years agoAuto merge of #12877 - zachs18:inline-def-in-macro, r=zachs18
bors [Tue, 26 Jul 2022 16:14:51 +0000 (16:14 +0000)]
Auto merge of #12877 - zachs18:inline-def-in-macro, r=zachs18

fix: Insert spaces when inlining a function defined in a macro.

(partially) fixes #12860.

This PR (only) addresses the whitespace issue when inlining functions defined in macros.

Additionally, the indentation/spacing is not ideal, but works, e.g.
```rs
macro_rules! define_function {
    () => { fn test_function_macro() {
        if let Some(3) = 3i32.checked_add(0) {
            println!("3 + 0 == 3");
        }
    } };
}
define_function!();
fn main() {
    test_function_macro();
}
// previously became
// ...
fn main() {
    ifletSome(3)=3i32.checked_add(0){println!("3 + 0 == 3");};
}
// now becomes
// ...
fn main() {
    if let Some(3) = 3i32.checked_add(0){
        println!("3 + 0 == 3");

      };
}
```

The `self` -> `this` problem[^this] is (probably?) a separate problem that I am also looking into.

[^this]: As mentioned in [my comment on the above issue](https://github.com/rust-lang/rust-analyzer/issues/12860#issuecomment-1193231766), inlining a method defined in a macro does not properly replace `self` with the new local `this`.

2 years agoRemove FIXME comment for unreachable fallback.
Zachary S [Tue, 26 Jul 2022 15:59:19 +0000 (10:59 -0500)]
Remove FIXME comment for unreachable fallback.

2 years agoAuto merge of #12881 - Veykril:proc-srv, r=Veykril
bors [Tue, 26 Jul 2022 14:31:26 +0000 (14:31 +0000)]
Auto merge of #12881 - Veykril:proc-srv, r=Veykril

fix: Fix server panicking on project loading when proc-macros are disabled

Fixes https://github.com/rust-lang/rust-analyzer/issues/12879

2 years agofix: Fix server panicking on project loading when proc-macros are disabled
Lukas Wirth [Tue, 26 Jul 2022 14:30:45 +0000 (16:30 +0200)]
fix: Fix server panicking on project loading when proc-macros are disabled

2 years agoAuto merge of #12878 - fasterthanlime:standalone-pms-exe, r=lnicola
bors [Tue, 26 Jul 2022 10:33:43 +0000 (10:33 +0000)]
Auto merge of #12878 - fasterthanlime:standalone-pms-exe, r=lnicola

Find standalone proc-macro-srv on windows too

I forgot that executables end with `.exe` on Windows in:

  * https://github.com/rust-lang/rust-analyzer/pull/12858

2 years agoFind standalone proc-macro-srv on windows too
Amos Wenger [Tue, 26 Jul 2022 09:30:41 +0000 (11:30 +0200)]
Find standalone proc-macro-srv on windows too

2 years agoAuto merge of #12864 - Veykril:derive-helpers, r=Veykril
bors [Tue, 26 Jul 2022 07:34:11 +0000 (07:34 +0000)]
Auto merge of #12864 - Veykril:derive-helpers, r=Veykril

feat: Resolve derive helper attributes in IDE layer

![image](https://user-images.githubusercontent.com/3757771/180647125-98cae13b-a7b4-446b-8a64-fae014f982e2.png)

Also downmaps tokens inside deriver helpers to the derive expansion
![image](https://user-images.githubusercontent.com/3757771/180642110-699bdc73-e1f3-4692-94f2-21544f824ab9.png)

This does not handle the case where multiple derives make use of the same helper name though, unsure how to tackle that yet.

Partially addresses https://github.com/rust-lang/rust-analyzer/issues/10935

2 years agoAllow name querying for derive helpers
Lukas Wirth [Sun, 24 Jul 2022 12:32:39 +0000 (14:32 +0200)]
Allow name querying for derive helpers

2 years agoRecord derive helper attributes, resolve them in IDE layer
Lukas Wirth [Sun, 24 Jul 2022 12:05:37 +0000 (14:05 +0200)]
Record derive helper attributes, resolve them in IDE layer

2 years agofeat: Downmap tokens inside derive helpers
Lukas Wirth [Sun, 24 Jul 2022 10:04:15 +0000 (12:04 +0200)]
feat: Downmap tokens inside derive helpers

2 years agoAuto merge of #12858 - fasterthanlime:proc-macro-srv-bin, r=Veykril
bors [Tue, 26 Jul 2022 06:35:16 +0000 (06:35 +0000)]
Auto merge of #12858 - fasterthanlime:proc-macro-srv-bin, r=Veykril

Add `rust-analyzer-proc-macro-srv` binary, use it if found in sysroot

This adds a `bin` crate which simply runs `proc_macro_srv::cli::run()` (it does no CLI argument parsing, nothing).

The intent is to build that crate in Rust CI as part of the `dist::Rustc` component, then ship it in the sysroot: it would probably land in something like `~/.rustup/toolchains/nightly-2022-07-23-x86_64-unknown-linux-gnu/libexec/proc-macro-srv-cli`.

This makes https://github.com/rust-lang/rustup/pull/3022 less pressing. (Instead of teaching RA about rustup components, we simply teach it to look in the sysroot via `rustc --print sysroot`. If it can't find `proc-macro-srv-cli`, it falls back to its own `proc-macro` subcommand).

This is closely related to https://github.com/rust-lang/rust-analyzer/issues/12803 (but doesn't close it yet).

Things to address now:

  * [ ] What should the binary be named? What should the crate be named? We can pick different names with `[bin]` in the `Cargo.toml`

Things to address later:

  * Disable the "multi ABI compatibility scheme" when building that binary in Rust CI (that'll probably happen in `rust-lang/rust`)
  * Teaching RA to look in the sysroot

Things to address much, much later:

  * Is JSON a good fit here
  * Do we want to add versioning to future-proof it?
  * Other bikesheds

When built with `--features sysroot` on `nightly-2022-07-23-x86_64-unknown-linux-gnu`, the binary is 7.4MB. After stripping debuginfo, it's 2.6MB. When compressed to `.tar.xz`, it's 619KB.

In a Zulip discussion, `@jyn514` and `@Mark-Simulacrum` seemed to think that those sizes weren't a stopper for including the binary in the rustc component, even before we shrink it down further.

2 years agofix: Insert spaces when inlining a function defined in a macro.
Zachary S [Mon, 25 Jul 2022 20:43:25 +0000 (15:43 -0500)]
fix: Insert spaces when inlining a function defined in a macro.

2 years agoAllow specifying sysroot OR sysroot_src
Amos Wenger [Mon, 25 Jul 2022 15:52:38 +0000 (17:52 +0200)]
Allow specifying sysroot OR sysroot_src

2 years agoFix mix up in comments
Amos Wenger [Mon, 25 Jul 2022 14:59:10 +0000 (16:59 +0200)]
Fix mix up in comments

2 years agoGate and rename binary, use it if it's in the sysroot
Amos Wenger [Mon, 25 Jul 2022 14:22:39 +0000 (16:22 +0200)]
Gate and rename binary, use it if it's in the sysroot

2 years agoRemember the difference between 'sysroot root' and 'sysroot src root', start looking...
Amos Wenger [Mon, 25 Jul 2022 14:07:41 +0000 (16:07 +0200)]
Remember the difference between 'sysroot root' and 'sysroot src root', start looking in there for a rust-analyzer-proc-macro-srv binary

2 years agoName the binary 'proc-macro-srv'
Amos Wenger [Sun, 24 Jul 2022 12:53:20 +0000 (14:53 +0200)]
Name the binary 'proc-macro-srv'

2 years agoReturn result directly
Amos Wenger [Sun, 24 Jul 2022 12:50:30 +0000 (14:50 +0200)]
Return result directly

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>