Restore compatibility with windows-sys 0.52#238
Closed
hanna-kruppe wants to merge 2 commits into
Closed
Conversation
windows-sys 0.59 changed `HANDLE` from `isize` to `*mut c_void`. This only matters in two places that check for null. Doing that check in terms of std's `RawHandle` before converting to the windows-sys type makes the code compatible with either version.
hanna-kruppe
commented
Jan 11, 2025
Comment on lines
-12
to
+18
| INITIAL | ||
| .get_or_init(|| get_colors_(&std::io::stdout())) | ||
| .clone() | ||
| .map_err(Into::into) | ||
| (*INITIAL.get_or_init(|| get_colors_(&std::io::stdout()))).map_err(Into::into) | ||
| } | ||
|
|
||
| /// Cached [`get_colors`] call for [`std::io::stderr`] | ||
| pub fn stderr_initial_colors() -> StdioColorResult { | ||
| static INITIAL: std::sync::OnceLock<StdioColorInnerResult> = std::sync::OnceLock::new(); | ||
| INITIAL | ||
| .get_or_init(|| get_colors_(&std::io::stderr())) | ||
| .clone() | ||
| .map_err(Into::into) | ||
| (*INITIAL.get_or_init(|| get_colors_(&std::io::stderr()))).map_err(Into::into) |
Contributor
Author
There was a problem hiding this comment.
I applied the suggestion for clippy::clone_on_copy but I was not sure what to do about the other warning about OnceLock being too new for the MSRV:
warning: current MSRV (Minimum Supported Rust Version) is `1.66.0` but this item is stable since `1.70.0`
--> crates\anstyle-wincon\src\windows.rs:13:10
|
13 | .get_or_init(|| get_colors_(&std::io::stdout()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv
= note: `#[warn(clippy::incompatible_msrv)]` on by default
Collaborator
|
I've pulled the clippy changes out into #239. As for the main change, I would like to hold off for now. Multi-major versions add risks and with this being a less well tested platform, deals with unsafe, and is for an API I'm less familiar with, I'm uncomfortable doing this at this point. So far I only do this for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
windows-sys 0.59 has been out for half a year, but a good chunk of the ecosystem hasn't fully moved off 0.52 yet. In fact, crates.io still reports slightly higher daily download numbers for 0.52 than for 0.59 up to this day. This often leads to larger workspaces pulling in both versions. Some libraries that can easily remain compatible with both versions are mitigating this by relaxing their version requirements, making it easier to stay exclusively on 0.52 until all transitive dependencies are compatible with 0.59.
It turns out that anstyle-{query,wincon} can also be made compatible with both versions, see first commit for the details.
The second commit fixes accumulated clippy warnings in windows-specific code. I guess the clippy job in CI only runs on Linux and people rarely touch this code?
Similarly, I think the compatibility with windows-sys 0.52 won't be tested in CI because the minimal-versions job only runs on Linux. I did test it manually.