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

add missing Win32_Foundation feature #18963

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

gvozdvmozgu
Copy link
Contributor

I tried using the crate ra_ap_profile from crates.io, but I encountered this error due to a missing feature:

error[E0425]: cannot find function, tuple struct or tuple variant `GetCurrentProcess` in this scope
   --> C:\Users\gvozdvmozgu\.cargo\git\checkouts\rust-analyzer-cf7e117ee9ee1d0a\cd199ea\crates\profile\src\memory_usage.rs:43:37
    |
43  |                 let proc = unsafe { GetCurrentProcess() };
    |                                     ^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `GetCurrentProcessId`
    |
   ::: C:\Users\gvozdvmozgu\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\System\Threading\mod.rs:179:1
    |
179 | ::windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcessId() -> u32);
    | --------------------------------------------------------------------------------- similarly named function `GetCurrentProcessId` defined here

error[E0425]: cannot find function, tuple struct or tuple variant `GetProcessMemoryInfo` in this scope
   --> C:\Users\gvozdvmozgu\.cargo\git\checkouts\rust-analyzer-cf7e117ee9ee1d0a\cd199ea\crates\profile\src\memory_usage.rs:46:36
    |
46  |                 let ret = unsafe { GetProcessMemoryInfo(proc, mem_counters.as_mut_ptr(), cb as u32) };
    |                                    ^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ProcessAppMemoryInfo`
    |
   ::: C:\Users\gvozdvmozgu\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.52.0\src\Windows\Win32\System\Threading\mod.rs:793:1
    |
793 | pub const ProcessAppMemoryInfo: PROCESS_INFORMATION_CLASS = 2i32;
    | --------------------------------------------------------- similarly named constant `ProcessAppMemoryInfo` defined here
    ```

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 17, 2025
@lnicola
Copy link
Member

lnicola commented Jan 17, 2025

I don't understand why this is needed, https://microsoft.github.io/windows-rs/features/#/master/search/GetCurrentProcess doesn't list Win32_Foundation. I'm also a bit confused about how features work in that crate:

[features]
Win32 = ["Win32_Foundation"]
Win32_Foundation = ["Win32"]

@gvozdvmozgu
Copy link
Contributor Author

Something might have changed in the newer versions of windows-sys, but here's how it works in the version used in the profile:
/~https://github.com/microsoft/windows-rs/blob/3a605cba064b26f2a198ac58085f8c8836f47c38/crates/libs/sys/src/Windows/Win32/System/Threading/mod.rs#L178

@lnicola lnicola added this pull request to the merge queue Jan 17, 2025
@lnicola
Copy link
Member

lnicola commented Jan 17, 2025

CC @kennykerr just in case you don't know about the incomplete docs.

Merged via the queue into rust-lang:master with commit f61bfa4 Jan 17, 2025
9 checks passed
@kennykerr
Copy link
Contributor

microsoft/windows-rs#2735 added defaulted Win32_Foundation features so that is no longer required. Here's what it looks like in the latest release:

/~https://github.com/microsoft/windows-rs/blob/0.59.0/crates/libs/sys/Cargo.toml#L56

I'd suggest upgrading to (the latest) 0.59.0 version of the windows-sys crate.

@gvozdvmozgu gvozdvmozgu deleted the Win32_Foundation branch January 17, 2025 19:18
@kennykerr
Copy link
Contributor

Here you go: #18965

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants