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

Replace winreg with windows-registry #3896

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

InfyniteHeap
Copy link
Contributor

@InfyniteHeap InfyniteHeap commented Jun 20, 2024

Closes #3779.

APIs provided by winreg crate is not safe, simple and abstract enough. Besides that, it probably also contains protential bugs. Because of that, it is better to replace it with windows-registry crate, which is officially published and maintained by Microsoft.

src/cli/self_update/test.rs Outdated Show resolved Hide resolved
@rami3l rami3l changed the title Change dependency to windows-registry Replace winreg with windows-registry Jun 20, 2024
@InfyniteHeap InfyniteHeap marked this pull request as ready for review June 20, 2024 16:04
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

I haven't done a complete review yet, because I think there's a bunch of stuff left to clean up. The core change looks great though, thanks for working on this!

Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/cli/self_update/test.rs Outdated Show resolved Hide resolved
src/cli/self_update/test.rs Outdated Show resolved Hide resolved
src/cli/self_update/test.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
@InfyniteHeap InfyniteHeap reopened this Jun 21, 2024
@InfyniteHeap InfyniteHeap deleted the change-dependency branch June 21, 2024 03:30
@InfyniteHeap InfyniteHeap restored the change-dependency branch June 21, 2024 03:31
@InfyniteHeap InfyniteHeap reopened this Jun 21, 2024
@InfyniteHeap InfyniteHeap reopened this Jun 21, 2024
@InfyniteHeap InfyniteHeap requested review from djc and rami3l June 21, 2024 06:32
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

Overall a really nice improvement!

src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
tests/suite/cli_paths.rs Outdated Show resolved Hide resolved
@djc
Copy link
Contributor

djc commented Jun 22, 2024

Sorry, but it turns out I had to make some changes to registry-related API in #3893. Hopefully it won't be too hard to rebase on top of my changes.

@InfyniteHeap
Copy link
Contributor Author

Sorry, but it turns out I had to make some changes to registry-related API in #3893. Hopefully it won't be too hard to rebase on top of my changes.

Oh, I think I'd better replace dependency from scratch lest appear some unexpect problems.😅

Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

This PR is getting even clearer than the previous iteration, modulo some eventual rebases (esp. after @kennykerr's possible API adjustments). Good job!

PS: As a favor, please consider listing @ChrisDenton as a co-author of some (or all) of your commits when applicable :)

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for all the work!

@kennykerr
Copy link
Contributor

I could implement Deref in place of as_wide and that would provide all of this directly.

@rami3l
Copy link
Member

rami3l commented Sep 22, 2024

Current status: Waiting for a new upstream release to ship microsoft/windows-rs#3148...

@kennykerr
Copy link
Contributor

Here's the Deref implementation for HSTRING. microsoft/windows-rs#3291

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

@kennykerr what's the rationale for using all-uppercase names for stuff like HSTRING and HRESULT? Are you trying to match the upstream names exactly? It looks rather unidiomatic.

src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
src/cli/self_update/windows.rs Show resolved Hide resolved
src/cli/self_update/windows.rs Outdated Show resolved Hide resolved
@kennykerr
Copy link
Contributor

what's the rationale for using all-uppercase names for stuff like HSTRING and HRESULT? Are you trying to match the upstream names exactly? It looks rather unidiomatic.

There are countless identifiers in the Windows API. It's just not very practical to come up with different names - it has been attempted. It also makes it a lot harder to cross-reference documentation and source code for equivalent types.

@InfyniteHeap
Copy link
Contributor Author

What about these changes?

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

I think this is looking great. @InfyniteHeap and @kennykerr thanks for all the work! Would be nice to get that windows-registry release out so that we can move forward with this.

@kennykerr
Copy link
Contributor

Coming up: microsoft/windows-rs#3293

@InfyniteHeap InfyniteHeap marked this pull request as ready for review September 25, 2024 05:05
@kennykerr
Copy link
Contributor

Version 0.3.0 of the windows-registry crate has been published. https://github.com/microsoft/windows-rs/releases/tag/0.60.0

@djc
Copy link
Contributor

djc commented Sep 25, 2024

Can you squash all of your changes into a single commit?

@InfyniteHeap
Copy link
Contributor Author

Can you squash all of your changes into a single commit?

I've done this.

Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

LGTM, and thanks for your work @InfyniteHeap!

PS: You may proceed with cleanup PRs such as the one discussed in #3896 (comment) shortly after.

@djc djc added this pull request to the merge queue Sep 26, 2024
Merged via the queue into rust-lang:master with commit bce3ed6 Sep 26, 2024
27 checks passed
@InfyniteHeap InfyniteHeap deleted the change-dependency branch September 26, 2024 07:47
@rami3l rami3l mentioned this pull request Oct 6, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustup fails to open non-existing windows registry path
5 participants