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

Emit data::Impl in save-analysis #47657

Merged
merged 1 commit into from Feb 11, 2018

Conversation

Projects
None yet
9 participants
@algesten
Copy link
Contributor

algesten commented Jan 22, 2018

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 derive Hash for ImplKind enum.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 22, 2018

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

This comment has been minimized.

Copy link
Contributor Author

algesten commented Jan 22, 2018

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

@algesten algesten referenced this pull request Jan 22, 2018

Merged

Updates for save-analysis #14

@jonhoo

This comment has been minimized.

Copy link
Contributor

jonhoo commented Jan 22, 2018

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

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Jan 22, 2018

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned nikomatsakis Jan 22, 2018

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Jan 22, 2018

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

@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented Jan 26, 2018

Ping from triage, @nrc!

@@ -1088,6 +1139,7 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>(
analysis,
span_utils: SpanUtils::new(&tcx.sess),
config: find_config(config),
impl_counter: Cell::new(0_u32),

This comment has been minimized.

@nrc

nrc Jan 29, 2018

Member

You shouldn't need the _u32 here

self.dumper.dump_relation(impl_data);
if let super::Data::RelationData(rel, imp) = impl_data {
self.dumper.dump_relation(rel);
self.dumper.dump_impl(imp);

This comment has been minimized.

@nrc

nrc Jan 29, 2018

Member

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

This comment has been minimized.

@algesten

algesten Jan 29, 2018

Author Contributor

@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.

This comment has been minimized.

@nrc

nrc Feb 1, 2018

Member

ok

kind: kind,
span: span,
value: String::new(), // ???
parent: None, // ??? enclosing module?

This comment has been minimized.

@nrc

nrc Jan 29, 2018

Member

Yes, this should be the enclosing module

This comment has been minimized.

@algesten

algesten Jan 29, 2018

Author Contributor

Ok i fix.

This comment has been minimized.

@algesten

algesten Jan 29, 2018

Author Contributor

@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?

id: impl_id,
kind: kind,
span: span,
value: String::new(), // ???

This comment has been minimized.

@nrc

nrc Jan 29, 2018

Member

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

.collect(),
docs: "".to_string(), // ??? trait docs?
sig: None, // ??? trait sig?
attributes: vec![], // ??? trait attrs?

This comment has been minimized.

@nrc

nrc Jan 29, 2018

Member

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).

This comment has been minimized.

@algesten

algesten Jan 29, 2018

Author Contributor

I fix

This comment has been minimized.

@algesten

algesten Jan 29, 2018

Author Contributor

@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

let hash = hasher.finish();

// is this a good idea?
(hash ^ hash << 32) as u32

This comment has been minimized.

@nrc

nrc Jan 29, 2018

Member

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

This comment has been minimized.

Copy link
Member

nrc commented Jan 29, 2018

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

This comment has been minimized.

Copy link
Contributor Author

algesten commented Jan 29, 2018

Ok. I remove the hashing.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Feb 1, 2018

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

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 1, 2018

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 algesten force-pushed the algesten:save-analysis-impls branch from 8f033f1 to c7709fd Feb 1, 2018

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 1, 2018

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

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 1, 2018

Hm. maybe i rebase..

@algesten algesten force-pushed the algesten:save-analysis-impls branch from c7709fd to 93d3ebc Feb 1, 2018

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Feb 2, 2018

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

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 2, 2018

Oh. I check.

@algesten algesten force-pushed the algesten:save-analysis-impls branch from 93d3ebc to 38c517c Feb 2, 2018

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 2, 2018

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

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 2, 2018

and rebased off master again.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Feb 5, 2018

Thanks!

@bors: r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 5, 2018

📌 Commit 38c517c has been approved by nrc

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 5, 2018

🔒 Merge conflict

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 5, 2018

@nrc do i rebase off master again?

@kennytm

This comment has been minimized.

Copy link
Member

kennytm commented Feb 5, 2018

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

@kennytm

This comment has been minimized.

Copy link
Member

kennytm commented Feb 7, 2018

Why this PR is always merge-conflicting 😂

(Please rebase again)

@algesten algesten force-pushed the algesten:save-analysis-impls branch from f70dddd to 9a6afa8 Feb 10, 2018

@algesten

This comment has been minimized.

Copy link
Contributor Author

algesten commented Feb 10, 2018

Done

@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented Feb 10, 2018

@bors r=nrc

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 10, 2018

📌 Commit 9a6afa8 has been approved by nrc

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 10, 2018

⌛️ Testing commit 9a6afa8 with merge eb0fdb6...

bors added a commit that referenced this pull request Feb 10, 2018

Auto merge of #47657 - algesten:save-analysis-impls, r=nrc
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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 10, 2018

💔 Test failed - status-appveyor

@kennytm

This comment has been minimized.

Copy link
Member

kennytm commented Feb 10, 2018

@bors retry #48116

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 11, 2018

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

bors added a commit that referenced this pull request Feb 11, 2018

Auto merge of #47657 - algesten:save-analysis-impls, r=nrc
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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 11, 2018

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

@bors bors merged commit 9a6afa8 into rust-lang:master Feb 11, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

kennytm-githubbot added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Feb 11, 2018

📣 Toolstate changed by rust-lang/rust#47657!
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

This comment has been minimized.

Copy link
Member

kennytm commented Feb 11, 2018

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

[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

This comment has been minimized.

Copy link
Member

nrc commented Feb 11, 2018

@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 algesten:save-analysis-impls branch Mar 3, 2018

@algesten algesten referenced this pull request Mar 4, 2018

Closed

[wip] Expand Impl API #131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.