Skip to content

Emit data::Impl in save-analysis - #47657

Merged
bors merged 1 commit into
rust-lang:masterfrom
algesten:save-analysis-impls
Feb 11, 2018
Merged

Emit data::Impl in save-analysis#47657
bors merged 1 commit into
rust-lang:masterfrom
algesten:save-analysis-impls

Conversation

@algesten

@algestenalgesten commented Jan 22, 2018

Copy link
Copy Markdown
Contributor

As discussed on internals.rust-lang, this PR emits rls-data::Impl in the save-analysis.

A number of questions are outstanding:

  • A few ??? around row 356. We need to discuss what goes here, if anything.
  • Deriving id for impl using hashing. Is this going to clash with rustc defids?
  • Deriving id for impl using hashing. Is the conversion from 64 bit -> 32 bit problematic?
  • Need a new rls-data with an id field in Impl struct.
  • Need a new rls-data which deriveHash for ImplKind enum.

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@algesten

Copy link
Copy Markdown
ContributorAuthor

It's specifically @nrc that needs to look at this PR to guide me in completing the work.

@jonhoo

Copy link
Copy Markdown
Contributor

@algesten you can make that happen by writing r? @nrc

@algesten

Copy link
Copy Markdown
ContributorAuthor

r? @nrc

@algesten

Copy link
Copy Markdown
ContributorAuthor

Thanks @jonhoo I was aware of the feature but unsure whether it applied to wip stuff.

@carols10centscarols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 22, 2018
@shepmaster

Copy link
Copy Markdown
Member

Ping from triage, @nrc!

Comment threadsrc/librustc_save_analysis/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need the _u32 here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the cast macro rather than if let here is preferred.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrc but the cast macro is written for super::Data enclosing one value. Since this is the only data emitting two values, I though it cleaner make this an exeption rather than changing the macro to handle a tuple as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment threadsrc/librustc_save_analysis/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be the enclosing module

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i fix.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrc sorry I feel stupid here. can I actually get the parent module? All other match arms of ast::ImplKind set parent: None. Is this case different?

Comment threadsrc/librustc_save_analysis/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine (I don't think we'll ever use it)

Comment threadsrc/librustc_save_analysis/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be attributes on the impl that should be recorded here (I think). We don't need anything else. For docs and sig, we can leave them as they are (though I would prefer to use only one way to make an empty string).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fix

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrc Unless I'm looking in the wrong place, there doesn't seem to be any attrs on the Impl level (there are on the ImplItem level).

https://manishearth.github.io/rust-internals-docs/syntax/ast/enum.ItemKind.html

Comment threadsrc/librustc_save_analysis/lib.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use the 64 bit hash - iirc, we use 32 bits for a local id (NodeId) and 64 for a global id (DefId)

@nrc

nrc commented Jan 29, 2018

Copy link
Copy Markdown
Member

So, having thought this through a little bit, I think the hashing scheme might be overkill (sorry). We could just use the count of impls as the id, as long as clients ensure that impl ids are in a separate namespace from other ids, then I think everything will be OK (and that should be OK, since impl ids and def ids are not interchangeable).

@algesten

Copy link
Copy Markdown
ContributorAuthor

Ok. I remove the hashing.

@nrc

nrc commented Feb 1, 2018

Copy link
Copy Markdown
Member

OK, this all looks. I've merged your changes to rls-data and released that as version 0.15. Could you also squash your commits please?

@algesten

Copy link
Copy Markdown
ContributorAuthor

Here's the new output. It looks ok.

{
"impls": [
{
"id": 0,
"kind": "Direct",
"span": {
"file_name": [
115,
114,
99,
47,
109,
97,
105,
110,
46,
114,
115
],
"byte_start": 234,
"byte_end": 242,
"line_start": 15,
"line_end": 15,
"column_start": 22,
"column_end": 30
},
"value": "",
"parent": null,
"children": [
{
"krate": 0,
"index": 22
},
{
"krate": 0,
"index": 24
}
],
"docs": "",
"sig": null,
"attributes": []
}
]
}

@algesten

Copy link
Copy Markdown
ContributorAuthor

@nrc I've updated to rls-data 0.15 and squashed the commits.

@algesten

Copy link
Copy Markdown
ContributorAuthor

Hm. maybe i rebase..

@nrc

nrc commented Feb 2, 2018

Copy link
Copy Markdown
Member

I think you don't want to change the submodules which are included in this PR? But you probably do need to build (and maybe update) in order to get rls-data 0.15 into the Cargo.lock

@algesten

Copy link
Copy Markdown
ContributorAuthor

Oh. I check.

@algesten

Copy link
Copy Markdown
ContributorAuthor

@nrc sorted. submodule free and one Cargo.lock.

@algesten

Copy link
Copy Markdown
ContributorAuthor

and rebased off master again.

@nrc

nrc commented Feb 5, 2018

Copy link
Copy Markdown
Member

Thanks!

@bors: r+

@bors

bors commented Feb 5, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 38c517c has been approved by nrc

@bors

bors commented Feb 5, 2018

Copy link
Copy Markdown
Collaborator

🔒 Merge conflict

@algesten

Copy link
Copy Markdown
ContributorAuthor

@nrc do i rebase off master again?

@kennytm

Copy link
Copy Markdown
Member

@algesten Yes please rebase. Also, remove the [wip] from the title if it is ready for merging.

@borsbors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 7, 2018
@kennytm

kennytm commented Feb 7, 2018

Copy link
Copy Markdown
Member

Why this PR is always merge-conflicting 😂

(Please rebase again)

@algesten

Copy link
Copy Markdown
ContributorAuthor

Done

@shepmaster

Copy link
Copy Markdown
Member

@bors r=nrc

@bors

bors commented Feb 10, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 9a6afa8 has been approved by nrc

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 10, 2018
@bors

bors commented Feb 10, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 9a6afa8 with merge eb0fdb6...

bors added a commit that referenced this pull request Feb 10, 2018
Emit data::Impl in save-analysis
As discussed on [internals.rust-lang](https://internals.rust-lang.org/t/rustdoc2-rls-analysis-and-the-compiler-help-wanted/6592/5), this PR emits `rls-data::Impl` in the save-analysis.
A number of questions are outstanding:
- [x] A few `???` around row 356. We need to discuss what goes here, if anything.
- [ ] ~~Deriving `id` for impl using hashing. Is this going to clash with rustc defids?~~
- [ ] ~~Deriving `id` for impl using hashing. Is the conversion from 64 bit -> 32 bit problematic?~~
- [x] Need a new rls-data with an `id` field in `Impl` struct.
- [ ] ~~Need a new rls-data which `derive` `Hash` for `ImplKind` enum.~~
@bors

bors commented Feb 10, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-appveyor

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 10, 2018
@kennytm

Copy link
Copy Markdown
Member

@bors retry #48116

@borsbors 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 Feb 10, 2018
@bors

bors commented Feb 11, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 9a6afa8 with merge 0bb8935...

bors added a commit that referenced this pull request Feb 11, 2018
Emit data::Impl in save-analysis
As discussed on [internals.rust-lang](https://internals.rust-lang.org/t/rustdoc2-rls-analysis-and-the-compiler-help-wanted/6592/5), this PR emits `rls-data::Impl` in the save-analysis.
A number of questions are outstanding:
- [x] A few `???` around row 356. We need to discuss what goes here, if anything.
- [ ] ~~Deriving `id` for impl using hashing. Is this going to clash with rustc defids?~~
- [ ] ~~Deriving `id` for impl using hashing. Is the conversion from 64 bit -> 32 bit problematic?~~
- [x] Need a new rls-data with an `id` field in `Impl` struct.
- [ ] ~~Need a new rls-data which `derive` `Hash` for `ImplKind` enum.~~
@bors

bors commented Feb 11, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: nrc
Pushing 0bb8935 to master...

@bors
bors merged commit 9a6afa8 into rust-lang:masterFeb 11, 2018
kennytm-githubbot added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Feb 11, 2018
Tested on commit rust-lang/rust@0bb8935.
💔 rls on windows: test-pass → test-fail (cc @nrc).
💔 rls on linux: test-pass → test-fail (cc @nrc).
@kennytm

Copy link
Copy Markdown
Member

@nrc@algesten FYI the rls tests failed on this PR.

Details
[01:26:35] failures:
[01:26:35] [01:26:35] ---- test::test_find_impls stdout ----
[01:26:35] expect_messages:
[01:26:35] results: [
[01:26:35] "{\"jsonrpc\":\"2.0\",\"id\":0,\"result\":{\"capabilities\":{\"textDocumentSync\":2,\"hoverProvider\":true,\"completionProvider\":{\"resolveProvider\":true,\"triggerCharacters\":[\".\",\":\"]},\"definitionProvider\":true,\"referencesProvider\":true,\"documentHighlightProvider\":true,\"documentSymbolProvider\":true,\"workspaceSymbolProvider\":true,\"codeActionProvider\":true,\"documentFormattingProvider\":true,\"documentRangeFormattingProvider\":false,\"renameProvider\":true,\"executeCommandProvider\":{\"commands\":[\"rls.applySuggestion\",\"rls.deglobImports\"]}}}}",
[01:26:35] "{\"jsonrpc\":\"2.0\",\"method\":\"rustDocument/beginBuild\"}",
[01:26:35] "{\"jsonrpc\":\"2.0\",\"method\":\"rustDocument/diagnosticsBegin\"}",
[01:26:35] "{\"jsonrpc\":\"2.0\",\"method\":\"rustDocument/diagnosticsEnd\"}"
[01:26:35] ],
[01:26:35] expected: [
[01:26:35] ExpectedMessage {
[01:26:35] id: Some(
[01:26:35] 0
[01:26:35] ),
[01:26:35] contains: [
[01:26:35] "capabilities"
[01:26:35] ]
[01:26:35] },
[01:26:35] ExpectedMessage {
[01:26:35] id: None,
[01:26:35] contains: [
[01:26:35] "beginBuild"
[01:26:35] ]
[01:26:35] },
[01:26:35] ExpectedMessage {
[01:26:35] id: None,
[01:26:35] contains: [
[01:26:35] "diagnosticsBegin"
[01:26:35] ]
[01:26:35] },
[01:26:35] ExpectedMessage {
[01:26:35] id: None,
[01:26:35] contains: [
[01:26:35] "diagnosticsEnd"
[01:26:35] ]
[01:26:35] }
[01:26:35] ]
[01:26:35] expect_messages:
[01:26:35] results: [
[01:26:35] "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":[{\"uri\":\"file:///checkout/src/tools/rls/test_data/find_impls/src/main.rs\",\"range\":{\"start\":{\"line\":18,\"character\":15},\"end\":{\"line\":18,\"character\":18}}}]}"
[01:26:35] ],
[01:26:35] expected: [
[01:26:35] ExpectedMessage {
[01:26:35] id: Some(
[01:26:35] 1
[01:26:35] ),
[01:26:35] contains: [
[01:26:35] "\"range\":{\"start\":{\"line\":18,\"character\":15},\"end\":{\"line\":18,\"character\":18}}",
[01:26:35] "\"range\":{\"start\":{\"line\":19,\"character\":12},\"end\":{\"line\":19,\"character\":15}}"
[01:26:35] ]
[01:26:35] }
[01:26:35] ]
[01:26:35] thread 'test::test_find_impls' panicked at 'Could not find `"range":{"start":{"line":19,"character":12},"end":{"line":19,"character":15}}` in `{"jsonrpc":"2.0","id":1,"result":[{"uri":"file:///checkout/src/tools/rls/test_data/find_impls/src/main.rs","range":{"start":{"line":18,"character":15},"end":{"line":18,"character":18}}}]}`', libcore/option.rs:917:5
[01:26:35] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:26:35] [01:26:35] [01:26:35] failures:
[01:26:35] test::test_find_impls
[01:26:35] [01:26:35] test result: FAILED. 39 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:26:35] [01:26:35] error: test failed, to rerun pass '--bin rls'

@nrc

nrc commented Feb 11, 2018

Copy link
Copy Markdown
Member

@kennytm this is expected (I think) and should be solved by updating the RLS and then updating the version in the Repo

@algesten
algesten deleted the save-analysis-impls branch March 3, 2018 09:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@algesten@rust-highfive@jonhoo@shepmaster@nrc@bors@kennytm@nikomatsakis@carols10cents