Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync rust-analyzer, add rust-analyzer-proc-macro-srv binary to Rustc component #99756

Merged
merged 40 commits into from
Jul 28, 2022

Conversation

fasterthanlime
Copy link
Contributor

As discussed earlier with @jyn514 and @pietroalbini, I'm also going to use this PR to have dist::Rustc build the rust-analyzer-proc-macro-srv binary introduced in:

lowr and others added 30 commits July 20, 2022 22:30
- 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.
…gen, r=Veykril

fix: don't replace default members' body

cc rust-lang#12779, rust-lang#12821
addresses rust-lang/rust-analyzer#12821 (comment)

`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.
…on order isn't guaranteed

(And, in fact, it failed on i686)
…ing-assignment, r=Veykril

Fix missing fields check on destructuring assignment

Fixes rust-lang#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.
…, r=DorianListens

fix: Autocomplete for struct fields includes receiver

fixes rust-lang#12857
feat: Spawn a proc-macro-srv instance per workspace

cc rust-lang/rust-analyzer#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.
…ykril

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:

  * rust-lang#99603

(And that were reviewed ahead of time by `@Veykril` + `@lnicola)`
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
…, start looking in there for a rust-analyzer-proc-macro-srv binary
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jul 26, 2022
@fasterthanlime
Copy link
Contributor Author

Ok, so! I added tool::RustAnalyzerProcMacroSrv, and I ensure'd it from dist::Rustc, and I checked that it works by doing:

$ ./x.py dist rustc
(cut)
$ tar wtf build/dist/rustc-1.64.0-dev-x86_64-unknown-linux-gnu.tar.gz | sed -n 's/rustc-[^/]*\/rustc//p' | grep proc-macro-srv
/libexec/rust-analyzer-proc-macro-srv

Things that bother me are:

  • This isn't covered by x.py check right now
  • I'm not 100% confident about any of the bootstrap code I added - I don't get code intelligence in there via rust-analyzer, so it's mostly grepping and guessing

@fasterthanlime
Copy link
Contributor Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 26, 2022
@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Jul 26, 2022

I don't get code intelligence in there via rust-analyzer, so it's mostly grepping and guessing

Try setting rust-analyzer.linkedProjects to ["./Cargo.toml", "src/bootstrap/Cargo.toml"].

@jyn514
Copy link
Member

jyn514 commented Jul 26, 2022

No need for a separate check, it's covered by check::RustAnalyzer which checks the whole workspace

Does that mean we don't need a separate tool step either? since it's built as part of tool::RustAnalyzer?

@fasterthanlime
Copy link
Contributor Author

since it's built as part of tool::RustAnalyzer?

Nope, that one builds src/tools/rust-analyzer/crates/rust-analyzer, not src/tools/rust-analyzer.

@fasterthanlime
Copy link
Contributor Author

I made the two bootstrap tests pass in e075003 but I'm not sure if:

  • it's normal that the test "fixtures" needed to be updated since we're now building More Stuff
  • that means I did something wrong (picked the wrong target or something)

These lines I don't feel super confident about:

https://github.com/rust-lang/rust/blob/e0750037f305452ea80066ae371341f29608d3c0/src/bootstrap/dist.rs#L365-L368

@fasterthanlime fasterthanlime marked this pull request as ready for review July 26, 2022 20:40
@fasterthanlime fasterthanlime changed the title Sync rust-analyzer Sync rust-analyzer, add rust-analyzer-proc-macro-srv binary to Rustc component Jul 27, 2022
@Mark-Simulacrum
Copy link
Member

If possible, please squash the bootstrap-related commits into just one, and then I'm happy to r+

Thanks!

This builds `src/tools/rust-analyzer/crates/proc-macro-srv-cli` and
ships it as part of Rustc's dist component. This allows rust-analyzer's
proc macro support to work on all rustc versions (stable, beta and
nightly) starting now.
@fasterthanlime fasterthanlime force-pushed the ra-sync-and-pms-component branch from 87ae3c0 to 6ea7d82 Compare July 27, 2022 13:54
@fasterthanlime
Copy link
Contributor Author

If possible, please squash the bootstrap-related commits into just one, and then I'm happy to r+

@Mark-Simulacrum All done!

I went as far as doing an x.py dist rustc from Windows to check that it produces the expected results, and it does:

❯ tar wtf .\build\dist\rustc-1.64.0-dev-x86_64-pc-windows-msvc.tar.gz | grep proc-macro-srv
rustc-1.64.0-dev-x86_64-pc-windows-msvc/rustc/libexec/rust-analyzer-proc-macro-srv.exe

@Mark-Simulacrum
Copy link
Member

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Jul 27, 2022

📌 Commit 6ea7d82 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2022
@bors
Copy link
Contributor

bors commented Jul 28, 2022

⌛ Testing commit 6ea7d82 with merge 05e678c...

@bors
Copy link
Contributor

bors commented Jul 28, 2022

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 05e678c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 28, 2022
@bors bors merged commit 05e678c into rust-lang:master Jul 28, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 28, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (05e678c): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.5% 2.5% 1
Improvements 🎉
(primary)
-2.0% -2.0% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -2.0% -2.0% 1

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
2.2% 2.2% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-2.5% -2.5% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -0.2% -2.5% 2

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.