From c736c2a3aef0069fc9af918bea841d35dfba7b7a Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 22 Oct 2021 09:55:32 -0400 Subject: [PATCH] Add comment documenting why we can't use a simpler solution See #90144 for context. r? @joshtriplett --- library/std/src/sys/windows/os.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/std/src/sys/windows/os.rs b/library/std/src/sys/windows/os.rs index 883690c483167..b5209aa690b4c 100644 --- a/library/std/src/sys/windows/os.rs +++ b/library/std/src/sys/windows/os.rs @@ -281,6 +281,10 @@ pub fn temp_dir() -> PathBuf { #[cfg(not(target_vendor = "uwp"))] fn home_dir_crt() -> Option { unsafe { + // The magic constant -4 can be used as the token passed to GetUserProfileDirectoryW below + // instead of us having to go through these multiple steps to get a token. However this is + // not implemented on Windows 7, only Windows 8 and up. When we drop support for Windows 7 + // we can simplify this code. See #90144 for details. use crate::sys::handle::Handle; let me = c::GetCurrentProcess();