summaryrefslogtreecommitdiffstats
path: root/vendor/tempfile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tempfile
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tempfile')
-rw-r--r--vendor/tempfile/.cargo-checksum.json2
-rw-r--r--vendor/tempfile/Cargo.toml9
-rw-r--r--vendor/tempfile/NEWS10
-rw-r--r--vendor/tempfile/build.rs10
-rw-r--r--vendor/tempfile/src/dir.rs24
-rw-r--r--vendor/tempfile/src/file/imp/windows.rs3
-rw-r--r--vendor/tempfile/src/file/mod.rs96
-rw-r--r--vendor/tempfile/src/spooled.rs84
-rw-r--r--vendor/tempfile/src/util.rs9
9 files changed, 201 insertions, 46 deletions
diff --git a/vendor/tempfile/.cargo-checksum.json b/vendor/tempfile/.cargo-checksum.json
index 6633ccc75..94cac8312 100644
--- a/vendor/tempfile/.cargo-checksum.json
+++ b/vendor/tempfile/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"752e39e58b556c9d16d42fdfc7f772bbe853882bf4481cfe18922599c4bfbc04","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"8b427f5bc501764575e52ba4f9d95673cf8f6d80a86d0d06599852e1a9a20a36","NEWS":"5508856b86b8e1bf4f84c8df7fe3374968bed66f8585b8108d081cc67d425108","README.md":"5fb03bad7838354c686bab80e30323385f07efeb2aa1c5c35bdff7ec203dc5fa","src/dir.rs":"7efb94008d9d14dd3c19c105f2a0dd0695e102a1057ad91d80eed2bcb97e5bd0","src/error.rs":"cc7d8eace0fff11cb342158d2885d5637bfb14b24ef30755e808554772039c5f","src/file/imp/mod.rs":"f6da9fcd93f11889670a251fdd8231b5f4614e5a971b7b183f52b44af68568d5","src/file/imp/other.rs":"501cd1b444a5821127ea831fc8018706148f2d9f47c478f502b069963a42a2c7","src/file/imp/unix.rs":"c27c8c4e8b00e8a0e06c7243f072265eba8bc8e519e7b28ddf64d02cb4d99d01","src/file/imp/windows.rs":"3c064beb4b70677929bfe6372dba113756fbd8ea27aa6a36e86090d7b860f566","src/file/mod.rs":"10c141b5467b36f913f4946716d1d361d5a29bd7bf97ba8b6bb020d748ea0821","src/lib.rs":"6303e7470c680ad785f32eb717de2e512b88c2c5da0e1684e3704471fabd7398","src/spooled.rs":"05eef6a7aa9441ab834e602c0dd3df2222dcd4bcca91c5dfbc88591fb61a391f","src/util.rs":"6761c241cc6f4b99a85e45a827acd26b4d3bdf1d4efcb43a277f788b262ce0dc","tests/namedtempfile.rs":"a37c82908ed5df89cd2800c55abadf631d04caa55f09c966c8d1fd7a559a0ba6","tests/spooled.rs":"29e797d486d867cb6ac46d4cf126eb5868a069a4070c3f50ffa02fbb0b887934","tests/tempdir.rs":"abf08594f9d9ddc6c417de413bf63f9026150378af319d857e5ac8578f3fb665","tests/tempfile.rs":"9a2f8142151a6aa2fd047aa3749f9982ece4b080a3ace0d3c58d6bdb3f883c81"},"package":"b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998"} \ No newline at end of file
+{"files":{"Cargo.toml":"eeb596e82d73d7c439c4380711f21cace57d2bb3b27c8d3ca85e416a9d938f3c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"8b427f5bc501764575e52ba4f9d95673cf8f6d80a86d0d06599852e1a9a20a36","NEWS":"7e7ee38b4831754dafaec2d9228e63695d7f12dd804cb14f0f0ae8cfb6a7fa27","README.md":"5fb03bad7838354c686bab80e30323385f07efeb2aa1c5c35bdff7ec203dc5fa","build.rs":"722b5256228f84e6f0da87143303c76a51def2b48c1f68e2c6c448e70a879cd4","src/dir.rs":"b555ff1d4ace32c5ce9deba77113b95969145bba16e43a88efe22d8f3ab049e5","src/error.rs":"cc7d8eace0fff11cb342158d2885d5637bfb14b24ef30755e808554772039c5f","src/file/imp/mod.rs":"f6da9fcd93f11889670a251fdd8231b5f4614e5a971b7b183f52b44af68568d5","src/file/imp/other.rs":"501cd1b444a5821127ea831fc8018706148f2d9f47c478f502b069963a42a2c7","src/file/imp/unix.rs":"c27c8c4e8b00e8a0e06c7243f072265eba8bc8e519e7b28ddf64d02cb4d99d01","src/file/imp/windows.rs":"fa4211087c36290064de9a41b5e533e4e8c24a10fb8f8908835a67e00555c06e","src/file/mod.rs":"12364fdd4e898a9dd62cf9d6a100cce055358b2d294c4dfc6385fe7df17475ab","src/lib.rs":"6303e7470c680ad785f32eb717de2e512b88c2c5da0e1684e3704471fabd7398","src/spooled.rs":"de848218bb7c0733d9c46e337564137673c95f5a6cf9f6bb28baf218b2503247","src/util.rs":"63737b9180cb769c1fcac56f1fa928221ae41a8917872d3e878d0a915e877710","tests/namedtempfile.rs":"a37c82908ed5df89cd2800c55abadf631d04caa55f09c966c8d1fd7a559a0ba6","tests/spooled.rs":"29e797d486d867cb6ac46d4cf126eb5868a069a4070c3f50ffa02fbb0b887934","tests/tempdir.rs":"abf08594f9d9ddc6c417de413bf63f9026150378af319d857e5ac8578f3fb665","tests/tempfile.rs":"9a2f8142151a6aa2fd047aa3749f9982ece4b080a3ace0d3c58d6bdb3f883c81"},"package":"31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6"} \ No newline at end of file
diff --git a/vendor/tempfile/Cargo.toml b/vendor/tempfile/Cargo.toml
index 85006d831..1af120665 100644
--- a/vendor/tempfile/Cargo.toml
+++ b/vendor/tempfile/Cargo.toml
@@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.48"
name = "tempfile"
-version = "3.5.0"
+version = "3.6.0"
authors = [
"Steven Allen <steven@stebalien.com>",
"The Rust Project Developers",
@@ -41,18 +41,21 @@ version = "1.6.0"
[dev-dependencies.doc-comment]
version = "0.3"
+[build-dependencies.autocfg]
+version = "1"
+
[features]
nightly = []
[target."cfg(any(unix, target_os = \"wasi\"))".dependencies.rustix]
-version = "0.37.1"
+version = "0.37.11"
features = ["fs"]
[target."cfg(target_os = \"redox\")".dependencies.redox_syscall]
version = "0.3"
[target."cfg(windows)".dependencies.windows-sys]
-version = "0.45"
+version = "0.48"
features = [
"Win32_Storage_FileSystem",
"Win32_Foundation",
diff --git a/vendor/tempfile/NEWS b/vendor/tempfile/NEWS
index 14f8a9e4e..a75e04090 100644
--- a/vendor/tempfile/NEWS
+++ b/vendor/tempfile/NEWS
@@ -1,3 +1,13 @@
+3.6.0
+=====
+
+- Update windows-sys to 0.48.
+- Update rustix min version to 0.37.11
+- Forward some `NamedTempFile` and `SpooledTempFile` methods to the underlying `File` object for
+ better performance (especially vectorized writes, etc.).
+- Implement `AsFd` and `AsHandle`.
+- Misc documentation fixes and code cleanups.
+
3.5.0
=====
diff --git a/vendor/tempfile/build.rs b/vendor/tempfile/build.rs
new file mode 100644
index 000000000..5c1fb7749
--- /dev/null
+++ b/vendor/tempfile/build.rs
@@ -0,0 +1,10 @@
+fn main() {
+ let ac = autocfg::new();
+
+ #[cfg(unix)]
+ ac.emit_trait_cfg("std::os::fd::AsFd", "fd");
+ #[cfg(windows)]
+ ac.emit_trait_cfg("std::os::windows::io::AsHandle", "fd");
+
+ autocfg::rerun_path("build.rs");
+}
diff --git a/vendor/tempfile/src/dir.rs b/vendor/tempfile/src/dir.rs
index 917e47ec2..483b6d807 100644
--- a/vendor/tempfile/src/dir.rs
+++ b/vendor/tempfile/src/dir.rs
@@ -45,16 +45,16 @@ use crate::Builder;
/// # }
/// # fn run() -> Result<(), io::Error> {
/// // Create a directory inside of `std::env::temp_dir()`
-/// let dir = tempdir()?;
+/// let tmp_dir = tempdir()?;
///
-/// let file_path = dir.path().join("my-temporary-note.txt");
-/// let mut file = File::create(file_path)?;
-/// writeln!(file, "Brian was here. Briefly.")?;
+/// let file_path = tmp_dir.path().join("my-temporary-note.txt");
+/// let mut tmp_file = File::create(file_path)?;
+/// writeln!(tmp_file, "Brian was here. Briefly.")?;
///
/// // `tmp_dir` goes out of scope, the directory as well as
/// // `tmp_file` will be deleted here.
-/// drop(file);
-/// dir.close()?;
+/// drop(tmp_file);
+/// tmp_dir.close()?;
/// # Ok(())
/// # }
/// ```
@@ -94,16 +94,16 @@ pub fn tempdir() -> io::Result<TempDir> {
/// # }
/// # fn run() -> Result<(), io::Error> {
/// // Create a directory inside of the current directory.
-/// let dir = tempdir_in(".")?;
+/// let tmp_dir = tempdir_in(".")?;
///
-/// let file_path = dir.path().join("my-temporary-note.txt");
-/// let mut file = File::create(file_path)?;
-/// writeln!(file, "Brian was here. Briefly.")?;
+/// let file_path = tmp_dir.path().join("my-temporary-note.txt");
+/// let mut tmp_file = File::create(file_path)?;
+/// writeln!(tmp_file, "Brian was here. Briefly.")?;
///
/// // `tmp_dir` goes out of scope, the directory as well as
/// // `tmp_file` will be deleted here.
-/// drop(file);
-/// dir.close()?;
+/// drop(tmp_file);
+/// tmp_dir.close()?;
/// # Ok(())
/// # }
/// ```
diff --git a/vendor/tempfile/src/file/imp/windows.rs b/vendor/tempfile/src/file/imp/windows.rs
index cb2673b5a..9df65f9e8 100644
--- a/vendor/tempfile/src/file/imp/windows.rs
+++ b/vendor/tempfile/src/file/imp/windows.rs
@@ -75,9 +75,6 @@ pub fn keep(path: &Path) -> io::Result<()> {
}
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
- // TODO: We should probably do this in one-shot using SetFileInformationByHandle but the API is
- // really painful.
-
unsafe {
let old_path_w = to_utf16(old_path);
let new_path_w = to_utf16(new_path);
diff --git a/vendor/tempfile/src/file/mod.rs b/vendor/tempfile/src/file/mod.rs
index 023acd26a..7be8dc8c2 100644
--- a/vendor/tempfile/src/file/mod.rs
+++ b/vendor/tempfile/src/file/mod.rs
@@ -916,12 +916,58 @@ impl<F: Read> Read for NamedTempFile<F> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.as_file_mut().read(buf).with_err_path(|| self.path())
}
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result<usize> {
+ self.as_file_mut()
+ .read_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+ self.as_file_mut()
+ .read_to_end(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+ self.as_file_mut()
+ .read_to_string(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
+ self.as_file_mut()
+ .read_exact(buf)
+ .with_err_path(|| self.path())
+ }
}
impl Read for &NamedTempFile<File> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.as_file().read(buf).with_err_path(|| self.path())
}
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result<usize> {
+ self.as_file()
+ .read_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+ self.as_file()
+ .read_to_end(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+ self.as_file()
+ .read_to_string(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
+ self.as_file().read_exact(buf).with_err_path(|| self.path())
+ }
}
impl<F: Write> Write for NamedTempFile<F> {
@@ -932,6 +978,24 @@ impl<F: Write> Write for NamedTempFile<F> {
fn flush(&mut self) -> io::Result<()> {
self.as_file_mut().flush().with_err_path(|| self.path())
}
+
+ fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result<usize> {
+ self.as_file_mut()
+ .write_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
+ self.as_file_mut()
+ .write_all(buf)
+ .with_err_path(|| self.path())
+ }
+
+ fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
+ self.as_file_mut()
+ .write_fmt(fmt)
+ .with_err_path(|| self.path())
+ }
}
impl Write for &NamedTempFile<File> {
@@ -942,6 +1006,20 @@ impl Write for &NamedTempFile<File> {
fn flush(&mut self) -> io::Result<()> {
self.as_file().flush().with_err_path(|| self.path())
}
+
+ fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result<usize> {
+ self.as_file()
+ .write_vectored(bufs)
+ .with_err_path(|| self.path())
+ }
+
+ fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
+ self.as_file().write_all(buf).with_err_path(|| self.path())
+ }
+
+ fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
+ self.as_file().write_fmt(fmt).with_err_path(|| self.path())
+ }
}
impl<F: Seek> Seek for NamedTempFile<F> {
@@ -956,6 +1034,13 @@ impl Seek for &NamedTempFile<File> {
}
}
+#[cfg(all(fd, unix))]
+impl<F: std::os::unix::io::AsFd> std::os::unix::io::AsFd for NamedTempFile<F> {
+ fn as_fd(&self) -> std::os::unix::io::BorrowedFd<'_> {
+ self.as_file().as_fd()
+ }
+}
+
#[cfg(unix)]
impl<F> std::os::unix::io::AsRawFd for NamedTempFile<F>
where
@@ -967,6 +1052,17 @@ where
}
}
+#[cfg(all(fd, windows))]
+impl<F> std::os::windows::io::AsHandle for NamedTempFile<F>
+where
+ F: std::os::windows::io::AsHandle,
+{
+ #[inline]
+ fn as_handle(&self) -> std::os::windows::io::BorrowedHandle<'_> {
+ self.as_file().as_handle()
+ }
+}
+
#[cfg(windows)]
impl<F> std::os::windows::io::AsRawHandle for NamedTempFile<F>
where
diff --git a/vendor/tempfile/src/spooled.rs b/vendor/tempfile/src/spooled.rs
index db14967ca..2c8eaa4e5 100644
--- a/vendor/tempfile/src/spooled.rs
+++ b/vendor/tempfile/src/spooled.rs
@@ -86,7 +86,7 @@ impl SpooledTempFile {
pub fn roll(&mut self) -> io::Result<()> {
if !self.is_rolled() {
let mut file = tempfile()?;
- if let SpooledData::InMemory(ref mut cursor) = self.inner {
+ if let SpooledData::InMemory(cursor) = &mut self.inner {
file.write_all(cursor.get_ref())?;
file.seek(SeekFrom::Start(cursor.position()))?;
}
@@ -99,12 +99,12 @@ impl SpooledTempFile {
if size as usize > self.max_size {
self.roll()?; // does nothing if already rolled over
}
- match self.inner {
- SpooledData::InMemory(ref mut cursor) => {
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => {
cursor.get_mut().resize(size as usize, 0);
Ok(())
}
- SpooledData::OnDisk(ref mut file) => file.set_len(size),
+ SpooledData::OnDisk(file) => file.set_len(size),
}
}
@@ -117,9 +117,37 @@ impl SpooledTempFile {
impl Read for SpooledTempFile {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
- match self.inner {
- SpooledData::InMemory(ref mut cursor) => cursor.read(buf),
- SpooledData::OnDisk(ref mut file) => file.read(buf),
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.read(buf),
+ SpooledData::OnDisk(file) => file.read(buf),
+ }
+ }
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut<'_>]) -> io::Result<usize> {
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.read_vectored(bufs),
+ SpooledData::OnDisk(file) => file.read_vectored(bufs),
+ }
+ }
+
+ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.read_to_end(buf),
+ SpooledData::OnDisk(file) => file.read_to_end(buf),
+ }
+ }
+
+ fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.read_to_string(buf),
+ SpooledData::OnDisk(file) => file.read_to_string(buf),
+ }
+ }
+
+ fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.read_exact(buf),
+ SpooledData::OnDisk(file) => file.read_exact(buf),
}
}
}
@@ -127,35 +155,49 @@ impl Read for SpooledTempFile {
impl Write for SpooledTempFile {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
// roll over to file if necessary
- let mut rolling = false;
- if let SpooledData::InMemory(ref mut cursor) = self.inner {
- rolling = cursor.position() as usize + buf.len() > self.max_size;
- }
- if rolling {
+ if matches! {
+ &self.inner, SpooledData::InMemory(cursor)
+ if cursor.position() as usize + buf.len() > self.max_size
+ } {
self.roll()?;
}
// write the bytes
- match self.inner {
- SpooledData::InMemory(ref mut cursor) => cursor.write(buf),
- SpooledData::OnDisk(ref mut file) => file.write(buf),
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.write(buf),
+ SpooledData::OnDisk(file) => file.write(buf),
+ }
+ }
+
+ fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result<usize> {
+ if matches! {
+ &self.inner, SpooledData::InMemory(cursor)
+ // Borrowed from the rust standard library.
+ if cursor.position() as usize + bufs.iter()
+ .fold(0usize, |a, b| a.saturating_add(b.len())) > self.max_size
+ } {
+ self.roll()?;
+ }
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.write_vectored(bufs),
+ SpooledData::OnDisk(file) => file.write_vectored(bufs),
}
}
#[inline]
fn flush(&mut self) -> io::Result<()> {
- match self.inner {
- SpooledData::InMemory(ref mut cursor) => cursor.flush(),
- SpooledData::OnDisk(ref mut file) => file.flush(),
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.flush(),
+ SpooledData::OnDisk(file) => file.flush(),
}
}
}
impl Seek for SpooledTempFile {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
- match self.inner {
- SpooledData::InMemory(ref mut cursor) => cursor.seek(pos),
- SpooledData::OnDisk(ref mut file) => file.seek(pos),
+ match &mut self.inner {
+ SpooledData::InMemory(cursor) => cursor.seek(pos),
+ SpooledData::OnDisk(file) => file.seek(pos),
}
}
}
diff --git a/vendor/tempfile/src/util.rs b/vendor/tempfile/src/util.rs
index c61082d50..d426ba3d7 100644
--- a/vendor/tempfile/src/util.rs
+++ b/vendor/tempfile/src/util.rs
@@ -15,16 +15,13 @@ fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString {
buf
}
-pub fn create_helper<F, R>(
+pub fn create_helper<R>(
base: &Path,
prefix: &OsStr,
suffix: &OsStr,
random_len: usize,
- mut f: F,
-) -> io::Result<R>
-where
- F: FnMut(PathBuf) -> io::Result<R>,
-{
+ mut f: impl FnMut(PathBuf) -> io::Result<R>,
+) -> io::Result<R> {
let num_retries = if random_len != 0 {
crate::NUM_RETRIES
} else {