diff options
| author | bors <bors@rust-lang.org> | 2021-12-09 07:08:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-09 07:08:32 +0000 |
| commit | 600820da45daa50870fe711d53938fc6a52edd35 (patch) | |
| tree | c5664462839bd20b23683f20ded11f594c758cdc /library/std | |
| parent | e25077704164071a1ef87cdc90fe7dd1872ba3fa (diff) | |
| parent | ab92eca61248f89cd1355690f49e32fcb1708d80 (diff) | |
| download | rust-600820da45daa50870fe711d53938fc6a52edd35.tar.gz rust-600820da45daa50870fe711d53938fc6a52edd35.zip | |
Auto merge of #91692 - matthiaskrgr:rollup-u7dvh0n, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #87599 (Implement concat_bytes!) - #89999 (Update std::env::temp_dir to use GetTempPath2 on Windows when available.) - #90796 (Remove the reg_thumb register class for asm! on ARM) - #91042 (Use Vec extend instead of repeated pushes on several places) - #91634 (Do not attempt to suggest help for overly malformed struct/function call) - #91685 (Install llvm tools to sysroot when assembling local toolchain) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/env.rs | 21 | ||||
| -rw-r--r-- | library/std/src/lib.rs | 9 | ||||
| -rw-r--r-- | library/std/src/prelude/v1.rs | 9 | ||||
| -rw-r--r-- | library/std/src/sys/windows/c.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/windows/os.rs | 2 |
5 files changed, 34 insertions, 13 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs index c6af708f6cd..c06928647d3 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -583,28 +583,25 @@ pub fn home_dir() -> Option<PathBuf> { /// may result in "insecure temporary file" security vulnerabilities. Consider /// using a crate that securely creates temporary files or directories. /// -/// # Unix +/// # Platform-specific behavior /// -/// Returns the value of the `TMPDIR` environment variable if it is +/// On Unix, returns the value of the `TMPDIR` environment variable if it is /// set, otherwise for non-Android it returns `/tmp`. If Android, since there /// is no global temporary folder (it is usually allocated per-app), it returns /// `/data/local/tmp`. +/// On Windows, the behavior is equivalent to that of [`GetTempPath2`][GetTempPath2] / +/// [`GetTempPath`][GetTempPath], which this function uses internally. +/// Note that, this [may change in the future][changes]. /// -/// # Windows -/// -/// Returns the value of, in order, the `TMP`, `TEMP`, -/// `USERPROFILE` environment variable if any are set and not the empty -/// string. Otherwise, `temp_dir` returns the path of the Windows directory. -/// This behavior is identical to that of [`GetTempPath`][msdn], which this -/// function uses internally. -/// -/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha +/// [changes]: io#platform-specific-behavior +/// [GetTempPath2]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a +/// [GetTempPath]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha /// /// ```no_run /// use std::env; /// /// fn main() { -/// let mut dir = env::temp_dir(); +/// let dir = env::temp_dir(); /// println!("Temporary directory: {}", dir.display()); /// } /// ``` diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 67846e78835..367f072ffc7 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -250,6 +250,7 @@ #![feature(cfg_target_thread_local)] #![feature(char_error_internals)] #![feature(char_internals)] +#![cfg_attr(not(bootstrap), feature(concat_bytes))] #![feature(concat_idents)] #![feature(const_cstr_unchecked)] #![feature(const_fn_floating_point_arithmetic)] @@ -576,6 +577,14 @@ pub use core::{ log_syntax, module_path, option_env, stringify, trace_macros, }; +#[unstable( + feature = "concat_bytes", + issue = "87555", + reason = "`concat_bytes` is not stable enough for use and is subject to change" +)] +#[cfg(not(bootstrap))] +pub use core::concat_bytes; + #[stable(feature = "core_primitive", since = "1.43.0")] pub use core::primitive; diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 772044f0149..9b23aa37e31 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -46,6 +46,15 @@ pub use core::prelude::v1::{ }; #[unstable( + feature = "concat_bytes", + issue = "87555", + reason = "`concat_bytes` is not stable enough for use and is subject to change" +)] +#[cfg(not(bootstrap))] +#[doc(no_inline)] +pub use core::prelude::v1::concat_bytes; + +#[unstable( feature = "asm", issue = "72016", reason = "inline assembly is not stable enough for use and is subject to change" diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 50c4547de85..b87b6b5d88e 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -1110,6 +1110,12 @@ compat_fn! { -> () { GetSystemTimeAsFileTime(lpSystemTimeAsFileTime) } + + // >= Win11 / Server 2022 + // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a + pub fn GetTempPath2W(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD { + GetTempPathW(nBufferLength, lpBuffer) + } } compat_fn! { diff --git a/library/std/src/sys/windows/os.rs b/library/std/src/sys/windows/os.rs index b5209aa690b..5f8556c3bc3 100644 --- a/library/std/src/sys/windows/os.rs +++ b/library/std/src/sys/windows/os.rs @@ -275,7 +275,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> { } pub fn temp_dir() -> PathBuf { - super::fill_utf16_buf(|buf, sz| unsafe { c::GetTempPathW(sz, buf) }, super::os2path).unwrap() + super::fill_utf16_buf(|buf, sz| unsafe { c::GetTempPath2W(sz, buf) }, super::os2path).unwrap() } #[cfg(not(target_vendor = "uwp"))] |
