-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
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. |
It's specifically @nrc that needs to look at this PR to guide me in completing the work. |
r? @nrc |
Thanks @jonhoo I was aware of the feature but unsure whether it applied to wip stuff. |
Ping from triage, @nrc! |
src/librustc_save_analysis/lib.rs
Outdated
@@ -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), |
There was a problem hiding this comment.
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
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/librustc_save_analysis/lib.rs
Outdated
kind: kind, | ||
span: span, | ||
value: String::new(), // ??? | ||
parent: None, // ??? enclosing module? |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok i fix.
There was a problem hiding this comment.
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?
src/librustc_save_analysis/lib.rs
Outdated
id: impl_id, | ||
kind: kind, | ||
span: span, | ||
value: String::new(), // ??? |
There was a problem hiding this comment.
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)
src/librustc_save_analysis/lib.rs
Outdated
.collect(), | ||
docs: "".to_string(), // ??? trait docs? | ||
sig: None, // ??? trait sig? | ||
attributes: vec![], // ??? trait attrs? |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fix
There was a problem hiding this comment.
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
src/librustc_save_analysis/lib.rs
Outdated
let hash = hasher.finish(); | ||
|
||
// is this a good idea? | ||
(hash ^ hash << 32) as u32 |
There was a problem hiding this comment.
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)
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). |
Ok. I remove the hashing. |
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? |
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": []
}
]
} |
8f033f1
to
c7709fd
Compare
@nrc I've updated to rls-data 0.15 and squashed the commits. |
Hm. maybe i rebase.. |
c7709fd
to
93d3ebc
Compare
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 |
Oh. I check. |
93d3ebc
to
38c517c
Compare
@nrc sorted. submodule free and one Cargo.lock. |
and rebased off master again. |
Thanks! @bors: r+ |
📌 Commit 38c517c has been approved by |
🔒 Merge conflict |
@nrc do i rebase off master again? |
@algesten Yes please rebase. Also, remove the |
Why this PR is always merge-conflicting 😂 (Please rebase again) |
f70dddd
to
9a6afa8
Compare
Done |
@bors r=nrc |
📌 Commit 9a6afa8 has been approved by |
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.~~
💔 Test failed - status-appveyor |
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.~~
☀️ Test successful - status-appveyor, status-travis |
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).
@nrc @algesten FYI the
|
@kennytm this is expected (I think) and should be solved by updating the RLS and then updating the version in the Repo |
As discussed on internals.rust-lang, this PR emits
rls-data::Impl
in the save-analysis.A number of questions are outstanding:
???
around row 356. We need to discuss what goes here, if anything.Derivingid
for impl using hashing. Is this going to clash with rustc defids?Derivingid
for impl using hashing. Is the conversion from 64 bit -> 32 bit problematic?id
field inImpl
struct.Need a new rls-data whichderive
Hash
forImplKind
enum.