Skip to content

Commit

Permalink
Auto merge of #17168 - kennykerr:rust-analyzer-windows-sys, r=lnicola
Browse files Browse the repository at this point in the history
Update `rust-analyzer` to use `windows-sys` crate

I noticed that the `rust-analyzer` project already depends on `windows-sys`. This update merely replaces the remaining direct dependencies on the older `winapi` crate with `windows-sys` dependencies.

Originally posted here: rust-lang/rust#124578
  • Loading branch information
bors committed May 1, 2024
2 parents 49e502b + 99e2530 commit cfce2bb
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/profile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jemalloc-ctl = { version = "0.5.0", package = "tikv-jemalloc-ctl", optional = tr
perf-event = "=0.4.7"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["processthreadsapi", "psapi"] }
windows-sys = { version = "0.52", features = ["Win32_System_Threading", "Win32_System_ProcessStatus"] }

[features]
cpu_profiler = []
Expand Down
3 changes: 1 addition & 2 deletions crates/profile/src/memory_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ impl MemoryUsage {
// There doesn't seem to be an API for determining heap usage, so we try to
// approximate that by using the Commit Charge value.

use winapi::um::processthreadsapi::*;
use winapi::um::psapi::*;
use windows_sys::Win32::System::{Threading::*, ProcessStatus::*};
use std::mem::{MaybeUninit, size_of};

let proc = unsafe { GetCurrentProcess() };
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ vfs.workspace = true
paths.workspace = true

[target.'cfg(windows)'.dependencies]
winapi = "0.3.9"
windows-sys = { version = "0.52", features = ["Win32_System_Threading"] }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = { version = "0.5.0", package = "tikv-jemallocator", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn main_loop(config: Config, connection: Connection) -> anyhow::Result<()> {
// https://github.com/rust-lang/rust-analyzer/issues/2835
#[cfg(windows)]
unsafe {
use winapi::um::processthreadsapi::*;
use windows_sys::Win32::System::Threading::*;
let thread = GetCurrentThread();
let thread_priority_above_normal = 1;
SetThreadPriority(thread, thread_priority_above_normal);
Expand Down
2 changes: 1 addition & 1 deletion crates/stdx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ itertools.workspace = true

[target.'cfg(windows)'.dependencies]
miow = "0.6.0"
winapi = { version = "0.3.9", features = ["winerror"] }
windows-sys = { version = "0.52", features = ["Win32_Foundation"] }

[features]
# Uncomment to enable for the whole crate graph
Expand Down
2 changes: 1 addition & 1 deletion crates/stdx/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ mod imp {
pipe::NamedPipe,
Overlapped,
};
use winapi::shared::winerror::ERROR_BROKEN_PIPE;
use windows_sys::Win32::Foundation::ERROR_BROKEN_PIPE;

struct Pipe<'a> {
dst: &'a mut Vec<u8>,
Expand Down

0 comments on commit cfce2bb

Please sign in to comment.