]> git.lizzy.rs Git - rust.git/log
rust.git
23 months 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

23 months 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

23 months 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

23 months 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

23 months 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

23 months 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

23 months 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.

23 months 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

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

23 months 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

23 months 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

23 months 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'

23 months 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>
23 months agoAdd doc comment to pass tidy check
Amos Wenger [Sat, 23 Jul 2022 22:48:20 +0000 (00:48 +0200)]
Add doc comment to pass tidy check

23 months agoAdd a proc-macro-srv-cli crate
Amos Wenger [Sat, 23 Jul 2022 20:47:34 +0000 (22:47 +0200)]
Add a proc-macro-srv-cli crate

23 months agoAuto merge of #12871 - fasterthanlime:sync-from-rust-2, r=Veykril
bors [Mon, 25 Jul 2022 12:58:58 +0000 (12:58 +0000)]
Auto merge of #12871 - fasterthanlime:sync-from-rust-2, r=Veykril

Sync from `rust-lang/rust`

This is the first subtree sync PR from `rust-lang/rust` to `rust-lang/rust-analyzer`, made by following the instructions at: https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html#performing-the-sync-from-rust-langrust-to-clippy

It includes all the commits that were made in:

  * https://github.com/rust-lang/rust/pull/99603

(And that were reviewed ahead of time by `@Veykril` + `@lnicola)`

23 months agorevert nightly rustfmt formatting that accidentally slipped in
Amos Wenger [Mon, 25 Jul 2022 12:18:28 +0000 (14:18 +0200)]
revert nightly rustfmt formatting that accidentally slipped in

cf. https://github.com/rust-lang/rust/pull/99603
cf. https://github.com/rust-lang/rust-analyzer/pull/12871#discussion_r928816339

23 months agoMerge remote-tracking branch 'origin/master' into sync-from-rust-2
Amos Wenger [Mon, 25 Jul 2022 12:07:07 +0000 (14:07 +0200)]
Merge remote-tracking branch 'origin/master' into sync-from-rust-2

23 months agoAuto merge of #12856 - Veykril:multi-proc-srv, r=Veykril
bors [Mon, 25 Jul 2022 10:41:05 +0000 (10:41 +0000)]
Auto merge of #12856 - Veykril:multi-proc-srv, r=Veykril

feat: Spawn a proc-macro-srv instance per workspace

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

The idea is to have each server be spawned with the appropriate toolchain, that way workspaces with differing toolchains shouldn't suffer from proc-macro abi mismatches.

23 months agoAuto merge of #12868 - lowr:follow-up-on-12832, r=lnicola
bors [Mon, 25 Jul 2022 10:15:08 +0000 (10:15 +0000)]
Auto merge of #12868 - lowr:follow-up-on-12832, r=lnicola

Replace `debug_assert!` with `stdx::always!`

Addresses https://github.com/rust-lang/rust-analyzer/pull/12832#issuecomment-1193713473

23 months agoReplace `debug_assert!` with `stdx::always!`
Ryo Yoshida [Mon, 25 Jul 2022 09:40:35 +0000 (18:40 +0900)]
Replace `debug_assert!` with `stdx::always!`

23 months agoMake macros test order-resistant
Amos Wenger [Sun, 24 Jul 2022 14:48:06 +0000 (16:48 +0200)]
Make macros test order-resistant

23 months agoAuto merge of #12861 - DorianListens:dscheidt/complete-field, r=DorianListens
bors [Sun, 24 Jul 2022 14:11:35 +0000 (14:11 +0000)]
Auto merge of #12861 - DorianListens:dscheidt/complete-field, r=DorianListens

fix: Autocomplete for struct fields includes receiver

fixes #12857

23 months agoSort when iterating through CrateGraph
Amos Wenger [Sun, 24 Jul 2022 14:11:05 +0000 (16:11 +0200)]
Sort when iterating through CrateGraph

23 months agofix: Autocomplete for struct fields includes receiver
Dorian Scheidt [Sun, 24 Jul 2022 05:29:07 +0000 (00:29 -0500)]
fix: Autocomplete for struct fields includes receiver

fixes #12857

23 months agoSort in DefMap::dump, since HashMap iteration order isn't defined
Amos Wenger [Sun, 24 Jul 2022 14:04:20 +0000 (16:04 +0200)]
Sort in DefMap::dump, since HashMap iteration order isn't defined

23 months agoAuto merge of #12863 - lowr:fix/missing-fields-on-destructuring-assignment, r=Veykril
bors [Sun, 24 Jul 2022 13:57:14 +0000 (13:57 +0000)]
Auto merge of #12863 - lowr:fix/missing-fields-on-destructuring-assignment, r=Veykril

Fix missing fields check on destructuring assignment

Fixes #12838

When checking if the record literal in question is an assignee expression or not, the new fn `is_assignee_record_literal` iterates over its ancestors until it is sure. This isn't super efficient, as we don't cache anything and does the iteration for every record literal during missing fields check. Alternatively, we may want to have a field like `assignee` on `hir_def::Expr::{RecordLit, Array, Tuple, Call}` to tell if it's an assignee expression, which would be O(1) when checking later but have some memory overhead for the field.

23 months agohir-def tests: sort results before comparing, since FxHashSet iteration order isn...
Amos Wenger [Sun, 24 Jul 2022 13:55:20 +0000 (15:55 +0200)]
hir-def tests: sort results before comparing, since FxHashSet iteration order isn't guaranteed

(And, in fact, it failed on i686)

23 months agofix: consider assignee expressions in record fields exhaustiveness check
Ryo Yoshida [Sun, 24 Jul 2022 13:34:53 +0000 (22:34 +0900)]
fix: consider assignee expressions in record fields exhaustiveness check

23 months agoAdd info whether it's assignee expr to relevant HIR `Expr` variants
Ryo Yoshida [Sun, 24 Jul 2022 13:32:49 +0000 (22:32 +0900)]
Add info whether it's assignee expr to relevant HIR `Expr` variants

23 months agoAuto merge of #12832 - lowr:fix/impl-default-members-no-codegen, r=Veykril
bors [Sun, 24 Jul 2022 12:46:08 +0000 (12:46 +0000)]
Auto merge of #12832 - lowr:fix/impl-default-members-no-codegen, r=Veykril

fix: don't replace default members' body

cc #12779, #12821
addresses https://github.com/rust-lang/rust-analyzer/pull/12821#issuecomment-1190157506

`gen_trait_fn_body()` only attempts to implement required trait member functions, so we shouldn't call it for `Implement default members` assist.

This patch also documents the precondition of `gen_trait_fn_body()` and inserts `debug_assert!`, but I'm not entirely sure if the assertions are appropriate.

23 months agoFix .gitattributes for test_data
Amos Wenger [Sun, 24 Jul 2022 12:05:35 +0000 (14:05 +0200)]
Fix .gitattributes for test_data

23 months agoSmall fixups
Joshua Nelson [Sat, 23 Jul 2022 20:37:46 +0000 (15:37 -0500)]
Small fixups

- use `path` instead of `paths`
- don't mark rust-analyzer as an optional tool
- print the cargo command that's run in the proc-macro-test build script

  this originally was part of a change to fix `test --stage 0 rust-analyzer`,
  but I'm going to leave that for a separate PR so it's easier to review.

23 months agoMove cfg attrs up to the mod definitions to disable sourcegen
Amos Wenger [Sat, 23 Jul 2022 15:23:13 +0000 (17:23 +0200)]
Move cfg attrs up to the mod definitions to disable sourcegen

23 months agoDisable all source-gen tests at compile time
Amos Wenger [Sat, 23 Jul 2022 00:06:11 +0000 (02:06 +0200)]
Disable all source-gen tests at compile time

23 months agoDon't run slow tests in Rust CI, only RA CI
Amos Wenger [Fri, 22 Jul 2022 16:16:46 +0000 (18:16 +0200)]
Don't run slow tests in Rust CI, only RA CI

23 months agoAdd `ellipsis` to HIR `RecordLit`
Ryo Yoshida [Fri, 22 Jul 2022 09:12:21 +0000 (18:12 +0900)]
Add `ellipsis` to HIR `RecordLit`

23 months agoAuto merge of #12859 - matklad:dont-color-the-whole-block-red-all-the-time-please...
bors [Sat, 23 Jul 2022 21:37:32 +0000 (21:37 +0000)]
Auto merge of #12859 - matklad:dont-color-the-whole-block-red-all-the-time-please, r=Veykril

feat: don't highlight the whole fn on return-type mismatch

23 months agointernal: extract common code for adjusting diagnostic range
Aleksey Kladov [Sat, 23 Jul 2022 21:16:36 +0000 (22:16 +0100)]
internal: extract common code for adjusting diagnostic range

23 months agofeat: don't highlight the whole fn on return-type mismatch
Aleksey Kladov [Sat, 23 Jul 2022 20:16:59 +0000 (21:16 +0100)]
feat: don't highlight the whole fn on return-type mismatch

23 months agoBetter error messages when the proc-macro-server fails to start
Lukas Wirth [Sat, 23 Jul 2022 18:24:01 +0000 (20:24 +0200)]
Better error messages when the proc-macro-server fails to start

23 months agoSpawn a proc-macro-srv instance per workspace
Lukas Wirth [Sat, 23 Jul 2022 18:10:10 +0000 (20:10 +0200)]
Spawn a proc-macro-srv instance per workspace

23 months agoAuto merge of #12851 - DorianListens:dscheidt/if-completion-match-guard, r=Veykril
bors [Sat, 23 Jul 2022 17:42:59 +0000 (17:42 +0000)]
Auto merge of #12851 - DorianListens:dscheidt/if-completion-match-guard, r=Veykril

fix: Don't add braces to 'if' completion in match guard position

fixes #12823

Is this what you were thinking of here, `@Veykril` ? I haven't done any work on completions before, so I could definitely be misunderstanding the issue.

23 months agofix: Don't add braces to 'if' completion in match guard position
Dorian Scheidt [Sat, 23 Jul 2022 00:06:14 +0000 (19:06 -0500)]
fix: Don't add braces to 'if' completion in match guard position

When the cursor is in a match arm, but before the fat arrow (=>) token, don't
add braces when autocompleting "if".

fixes #12823

23 months agoAuto merge of #12854 - RalfJung:generate_new, r=Veykril
bors [Sat, 23 Jul 2022 15:18:48 +0000 (15:18 +0000)]
Auto merge of #12854 - RalfJung:generate_new, r=Veykril

fix generate_new doc

Looks like this got copied from `generate_impl` without adjusting the description.

23 months agofix generate_new doc
Ralf Jung [Sat, 23 Jul 2022 15:09:01 +0000 (11:09 -0400)]
fix generate_new doc

23 months agoAuto merge of #12849 - Veykril:no-parse, r=Veykril
bors [Fri, 22 Jul 2022 23:00:35 +0000 (23:00 +0000)]
Auto merge of #12849 - Veykril:no-parse, r=Veykril

internal: Don't parse files unnecessarily in scope_for_offset

23 months agoAuto merge of #12850 - Veykril:display-fix, r=Veykril
bors [Fri, 22 Jul 2022 22:52:53 +0000 (22:52 +0000)]
Auto merge of #12850 - Veykril:display-fix, r=Veykril

fix: Fix error tooltip message for VSCode status bar item

23 months agofix: Fix error tooltip message for VSCode status bar item
Lukas Wirth [Fri, 22 Jul 2022 22:52:12 +0000 (00:52 +0200)]
fix: Fix error tooltip message for VSCode status bar item

23 months agointernal: Don't parse files unnecessarily in scope_for_offset
Lukas Wirth [Fri, 22 Jul 2022 22:50:59 +0000 (00:50 +0200)]
internal: Don't parse files unnecessarily in scope_for_offset

23 months agoAuto merge of #12847 - Veykril:vscode-downgrade, r=Veykril
bors [Fri, 22 Jul 2022 22:18:05 +0000 (22:18 +0000)]
Auto merge of #12847 - Veykril:vscode-downgrade, r=Veykril

fix: Fix restart server duplicating language clients

Reverts 03a62c180e6a7300d0d7b8c4d680b749c101bcbb
vscode-languageclient@8.0.0-next.15 and beyond changed the behaviour of language clients to be automatically started if a request comes in while they are not running. Currently when we restart the server via the restart command we recreate the language client, which causes VSCode to restart the stopped server, effectively duplicating our language clients...

Reverting the commit is simpler right now, the proper fix would be to only create a language client once and then use the `restart` functionality on it instead.

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

23 months agoRevert 03a62c180e6a7300d0d7b8c4d680b749c101bcbb
Lukas Wirth [Fri, 22 Jul 2022 22:14:34 +0000 (00:14 +0200)]
Revert 03a62c180e6a7300d0d7b8c4d680b749c101bcbb

23 months agoAuto merge of #12840 - Veykril:be-lazy, r=Veykril
bors [Fri, 22 Jul 2022 20:35:31 +0000 (20:35 +0000)]
Auto merge of #12840 - Veykril:be-lazy, r=Veykril

internal: Use ItemTree for variant, field and module attribute collection in attrs_query

Less parsing = very good, should speed up lang item collection as that basically probes attributes of all enum variants which currently triggers parsing

Not fond of how this is searching for the correct index, ideally we'd map between HIR and item tree Id here but I am not sure how, storing the item tree ids in the HIR version doesn't work due to the usage of `Trace`...

23 months agoUse ItemTree for modules in attrs_query
Lukas Wirth [Thu, 21 Jul 2022 14:05:52 +0000 (16:05 +0200)]
Use ItemTree for modules in attrs_query

23 months agoAuto merge of #12844 - Veykril:highlight-attr, r=Veykril
bors [Fri, 22 Jul 2022 15:31:32 +0000 (15:31 +0000)]
Auto merge of #12844 - Veykril:highlight-attr, r=Veykril

fix: Improve syntax highlighting in attributes

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

23 months agofix: Improve syntax highlighting in attributes
Lukas Wirth [Fri, 22 Jul 2022 15:29:03 +0000 (17:29 +0200)]
fix: Improve syntax highlighting in attributes

23 months agoAuto merge of #12835 - fasterthanlime:sysroot-abi, r=fasterthanlime
bors [Fri, 22 Jul 2022 12:28:27 +0000 (12:28 +0000)]
Auto merge of #12835 - fasterthanlime:sysroot-abi, r=fasterthanlime

Introduce proc-macro-srv/sysroot-abi

Still a WIP.

This change is tracked by:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

23 months agoAdd comment about replacing crossbeam with std scoped threads when they land
Amos Wenger [Fri, 22 Jul 2022 12:23:36 +0000 (14:23 +0200)]
Add comment about replacing crossbeam with std scoped threads when they land

23 months agoUse std::panic::resume_unwind
Amos Wenger [Thu, 21 Jul 2022 19:35:15 +0000 (21:35 +0200)]
Use std::panic::resume_unwind

23 months agoMove interner methods to Symbol, return SmolStr directly since it's ref-counted
Amos Wenger [Thu, 21 Jul 2022 19:32:46 +0000 (21:32 +0200)]
Move interner methods to Symbol, return SmolStr directly since it's ref-counted

23 months agoFix raw ident handling (a little)
Amos Wenger [Thu, 21 Jul 2022 17:13:44 +0000 (19:13 +0200)]
Fix raw ident handling (a little)

23 months agoAdd test for idents incl. raw idents
Amos Wenger [Thu, 21 Jul 2022 16:48:19 +0000 (18:48 +0200)]
Add test for idents incl. raw idents

23 months agoStringify literals create client-side properly
Amos Wenger [Thu, 21 Jul 2022 16:44:41 +0000 (18:44 +0200)]
Stringify literals create client-side properly

23 months agoAdd test for literals created client-side
Amos Wenger [Thu, 21 Jul 2022 16:29:28 +0000 (18:29 +0200)]
Add test for literals created client-side

23 months agoRun proc macro expansion in a separate thread (for the thread-local interner)
Amos Wenger [Thu, 21 Jul 2022 16:11:50 +0000 (18:11 +0200)]
Run proc macro expansion in a separate thread (for the thread-local interner)

23 months agoUse a thread-local for the symbol interner (1/2)
Amos Wenger [Thu, 21 Jul 2022 12:57:09 +0000 (14:57 +0200)]
Use a thread-local for the symbol interner (1/2)

23 months agoMove version string to RustcInfo, read '.rustc' section only once
Amos Wenger [Thu, 21 Jul 2022 11:57:36 +0000 (13:57 +0200)]
Move version string to RustcInfo, read '.rustc' section only once

23 months agoPass tidy checks
Amos Wenger [Thu, 21 Jul 2022 11:37:41 +0000 (13:37 +0200)]
Pass tidy checks

23 months agoAssert that sysroot ABI version matches exactly
Amos Wenger [Thu, 21 Jul 2022 11:13:24 +0000 (13:13 +0200)]
Assert that sysroot ABI version matches exactly

Otherwise, fall back to the multi ABI scheme, except in testing, where
it becomes a hard error.

This should make it possible to use a rustup-provided rust-analyzer with
proc macro dylibs compiled by older rustcs, and it'll also catch changes
to the format of `rustc --version` or the `.rustc` section that would
make them impossible to compare for equality.

23 months agoAuto merge of #12841 - Veykril:query-fix, r=Veykril
bors [Thu, 21 Jul 2022 08:23:19 +0000 (08:23 +0000)]
Auto merge of #12841 - Veykril:query-fix, r=Veykril

fix: Fix `trait_impls_in_deps_query` being called directly instead of as a query

Fixes the inlay hint performance regression introdcuced by https://github.com/rust-analyzer/rust-analyzer/issues/12549

23 months agofix: Fix `trait_impls_in_deps_query` being called directly instead of as a query
Lukas Wirth [Thu, 21 Jul 2022 08:17:57 +0000 (10:17 +0200)]
fix: Fix `trait_impls_in_deps_query` being called directly instead of as a query

23 months agoUse ItemTree for crate root attr_query collection
Lukas Wirth [Thu, 21 Jul 2022 07:23:30 +0000 (09:23 +0200)]
Use ItemTree for crate root attr_query collection

23 months agointernal: Use itemtree for variant and field attribute collection
Lukas Wirth [Thu, 21 Jul 2022 06:48:13 +0000 (08:48 +0200)]
internal: Use itemtree for variant and field attribute collection

23 months agoSimplify
Lukas Wirth [Thu, 21 Jul 2022 06:48:09 +0000 (08:48 +0200)]
Simplify

23 months agoAuto merge of #12827 - Veykril:be-lazy, r=Veykril
bors [Thu, 21 Jul 2022 00:11:18 +0000 (00:11 +0000)]
Auto merge of #12827 - Veykril:be-lazy, r=Veykril

internal: Construct fewer `AstIdMap`s in lowering

23 months agoSimplify
Lukas Wirth [Thu, 21 Jul 2022 00:06:26 +0000 (02:06 +0200)]
Simplify

23 months agoRemove AstIdMap from Expander as it is seldom needed
Lukas Wirth [Thu, 21 Jul 2022 00:00:58 +0000 (02:00 +0200)]
Remove AstIdMap from Expander as it is seldom needed

23 months agoimplement literal_from_str (poorly)
Amos Wenger [Wed, 20 Jul 2022 17:23:25 +0000 (19:23 +0200)]
implement literal_from_str (poorly)

23 months agoAdd literal/ident conversion, tests pass
Amos Wenger [Wed, 20 Jul 2022 17:13:06 +0000 (19:13 +0200)]
Add literal/ident conversion, tests pass

23 months agostub missing APIs
Amos Wenger [Wed, 20 Jul 2022 16:43:59 +0000 (18:43 +0200)]
stub missing APIs

23 months agoFix imports, delete removed interfaces
Amos Wenger [Wed, 20 Jul 2022 16:36:10 +0000 (18:36 +0200)]
Fix imports, delete removed interfaces

23 months agoMove token_stream to separate module
Amos Wenger [Wed, 20 Jul 2022 16:32:27 +0000 (18:32 +0200)]
Move token_stream to separate module

23 months agoAdd sysroot-abi feature, copy 1.64 ABI fo rnow
Amos Wenger [Wed, 20 Jul 2022 16:27:58 +0000 (18:27 +0200)]
Add sysroot-abi feature, copy 1.64 ABI fo rnow

23 months agoAuto merge of #12834 - fasterthanlime:proc-macro-test-toolchain, r=Veykril
bors [Wed, 20 Jul 2022 16:04:23 +0000 (16:04 +0000)]
Auto merge of #12834 - fasterthanlime:proc-macro-test-toolchain, r=Veykril

Add PROC_MACRO_TEST_TOOLCHAIN environment variable

This allows overriding the toolchain used to run `proc-macro-srv` tests.

---

Sample usage.

Testing the current ABI (variable unset/empty):

```shell
amos@tails ~/bearcove/rust-analyzer/crates/proc-macro-srv proc-macro-test-toolchain*
❯ PROC_MACRO_TEST_TOOLCHAIN="" cargo test --quiet

running 16 tests
................
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
```

Testing an older ABI:

```shell
amos@tails ~/bearcove/rust-analyzer/crates/proc-macro-srv proc-macro-test-toolchain*
❯ PROC_MACRO_TEST_TOOLCHAIN="1.58" cargo test --quiet

running 16 tests
................
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
```

Testing current nightly ABI:

```shell
❯ rustc +nightly --version
rustc 1.64.0-nightly (f8588549c 2022-07-18)

❯ PROC_MACRO_TEST_TOOLCHAIN="nightly" cargo test --quiet

running 16 tests
................
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
```

Testing future ABI (`rust-lang/rust` master):

```shell
amos@tails ~/bearcove/rust-analyzer/crates/proc-macro-srv proc-macro-test-toolchain
❯ PROC_MACRO_TEST_TOOLCHAIN="stage1" cargo test --quiet

running 16 tests
..........thread '<unnamed>' panicked at 'range end index 216221164920373249 out of range for slice of length 18', library/core/src/slice/index.rs:73:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
....F.
failures:

---- tests::test_fn_like_macro2 stdout ----
thread 'tests::test_fn_like_macro2' panicked at 'called `Result::unwrap()` on an `Err` value: "range end index 216221164920373249 out of range for slice of length 18"', crates/proc-macro-srv/src/tests/utils.rs:38:83
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    tests::test_fn_like_macro2

test result: FAILED. 15 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib
```

---

Tagging `@jonas-schievink:` this might be helpful when updating versioned ABIs later on.

23 months agoAdd PROC_MACRO_TEST_TOOLCHAIN environment variable
Amos Wenger [Wed, 20 Jul 2022 15:43:45 +0000 (17:43 +0200)]
Add PROC_MACRO_TEST_TOOLCHAIN environment variable

This allows overriding the toolchain used to run `proc-macro-srv` tests.

23 months agoAuto merge of #12833 - fasterthanlime:literal-tests, r=Veykril
bors [Wed, 20 Jul 2022 15:33:19 +0000 (15:33 +0000)]
Auto merge of #12833 - fasterthanlime:literal-tests, r=Veykril

Add proc-macro-srv integration test that clones literals

This exercises some of the upcoming proc_macro bridge changes. It should also pass for all supported ABIs, with the older-style bridge.

This changed is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

23 months agoAuto merge of #12831 - fasterthanlime:proc-macro-test-in-tmp-dir, r=fasterthanlime
bors [Wed, 20 Jul 2022 15:21:03 +0000 (15:21 +0000)]
Auto merge of #12831 - fasterthanlime:proc-macro-test-in-tmp-dir, r=fasterthanlime

Build proc-macro-test-impl out-of-tree

Building it in-place fails in rust CI because the source directory is read-only. This changes `proc-macro-test`'s build script to first
copy `imp` under `OUT_DIR` (which is read-write).

It also prints stdout/stderr for the nested cargo invocation, should it fail. (I've seen failures in rust CI that I couldn't explain, and
when they take 25 minutes to reproduce, you want to have that info)

This change is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

Maintainer impact: none.

23 months agoUpdate crates/proc-macro-test/build.rs
Amos Wenger [Wed, 20 Jul 2022 14:56:30 +0000 (16:56 +0200)]
Update crates/proc-macro-test/build.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
23 months agoUpdate crates/proc-macro-test/build.rs
Amos Wenger [Wed, 20 Jul 2022 14:56:25 +0000 (16:56 +0200)]
Update crates/proc-macro-test/build.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
23 months agoAdd proc-macro-srv integration test that clones literals
Amos Wenger [Wed, 20 Jul 2022 14:40:02 +0000 (16:40 +0200)]
Add proc-macro-srv integration test that clones literals

This exercises some of the upcoming proc_macro bridge changes. It
should also pass for all supported ABIs, with the older-style bridge.

23 months agoDon't copy the Cargo.lock
Amos Wenger [Wed, 20 Jul 2022 14:30:08 +0000 (16:30 +0200)]
Don't copy the Cargo.lock

23 months agoproc-macro-test build script: wipe before, be more verbose
Amos Wenger [Wed, 20 Jul 2022 14:22:48 +0000 (16:22 +0200)]
proc-macro-test build script: wipe before, be more verbose

23 months agoBuild proc-macro-test-impl out-of-tree
Amos Wenger [Wed, 20 Jul 2022 14:14:53 +0000 (16:14 +0200)]
Build proc-macro-test-impl out-of-tree

Building it in-place fails in rust CI because the source directory
is read-only. This changes `proc-macro-test`'s build script to first
copy `imp` under `OUT_DIR` (which is read-write).

It also prints stdout/stderr for the nested cargo invocation, should
it fail. (I've seen failures in rust CI that I couldn't explain, and
when they take 25 minutes to reproduce, you want to have that info)

23 months agoAuto merge of #12829 - fasterthanlime:in-rust-tree-feature, r=Veykril
bors [Wed, 20 Jul 2022 14:02:49 +0000 (14:02 +0000)]
Auto merge of #12829 - fasterthanlime:in-rust-tree-feature, r=Veykril

Remove `check_merge_commits` test

Due to the way "git subtree" works, the `check_merge_commits` test _will_ find merge commits and fail, so we simply skip it.

This changed is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

Maintainer impact: none

23 months agoRemove in-rust-tree feature
Amos Wenger [Wed, 20 Jul 2022 13:58:56 +0000 (15:58 +0200)]
Remove in-rust-tree feature

Since it's unused for now -it'll be re-introduced along with the
upcoming `proc-macro-srv/sysroot` feature.

23 months agoRemove check_merge_commits test altogether
Amos Wenger [Wed, 20 Jul 2022 13:57:13 +0000 (15:57 +0200)]
Remove check_merge_commits test altogether

Rationale: Merge commits will probably end up in
`rust-lang/rust-analyzer` when doing "rust=>ra" syncs anyway.

It could be changed to only check for merge commits in non-sync PRs,
but it's "probably not worth the hassle"

23 months agoAuto merge of #12828 - fasterthanlime:proc-macro-srv-naming, r=Veykril
bors [Wed, 20 Jul 2022 13:50:28 +0000 (13:50 +0000)]
Auto merge of #12828 - fasterthanlime:proc-macro-srv-naming, r=Veykril

Rename proc macro server from 'Rustc' to 'RustAnalyzer'

Related to:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

This is mostly a courtesy PR for the sake of rustc maintainers. When they looked at `proc-macro-srv`, they noticed the server was named `Rustc` — probably because of historical copy-paste. Only rustc's proc macro server should be named `Rustc`, ra's can be named `RustAnalyzer`.

Maintainer impact: There's no semantic changes in this PR, only naming. One test snapshot was updated since "proc macro server types" were used to test traits somewhere else and I renamed those too, why not.

23 months agoAllow merge commits when 'in-rust-tree' feature is enabled
Amos Wenger [Wed, 20 Jul 2022 13:49:40 +0000 (15:49 +0200)]
Allow merge commits when 'in-rust-tree' feature is enabled

This adds an `in-rust-tree` feature that will be enabled when
rust-analyzer is built from `rust-lang/rust`. Due to the way
"git subtree" works, that test _will_ find merge commits and
fail, so we simply skip it.

23 months agoRename proc macro server from 'Rustc' to 'RustAnalyzer'
Amos Wenger [Wed, 20 Jul 2022 13:40:23 +0000 (15:40 +0200)]
Rename proc macro server from 'Rustc' to 'RustAnalyzer'

23 months agofix: don't replace default members' body
Ryo Yoshida [Wed, 20 Jul 2022 13:30:16 +0000 (22:30 +0900)]
fix: don't replace default members' body