Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Stebalien/tempfile
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.4.0
Choose a base ref
...
head repository: Stebalien/tempfile
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.5.0
Choose a head ref
  • 13 commits
  • 8 files changed
  • 6 contributors

Commits on Feb 25, 2023

  1. ci: replace unmaintained actions-rs/cargo actions in CI workflows (#214)

    Basically all of the `actions-rs/*` actions are unmaintained. See
    <actions-rs/toolchain#216> for more
    information. Due to their age they generate several warnings in
    CI runs.
    
    To get rid of some of those warnings the occurrences of
    `actions-rs/cargo` are replaced by direct invocations of `cargo`.
    striezel authored Feb 25, 2023
    Copy the full SHA
    5df4343 View commit details
  2. Copy the full SHA
    cd26d8b View commit details
  3. Fix a typo in NEWS (#212)

    striezel authored Feb 25, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    MikeGoldsmith Mike Goldsmith
    Copy the full SHA
    19f03f1 View commit details

Commits on Feb 26, 2023

  1. Update windows-sys to 0.45, redox_syscall to 0.3 (#216)

    * Update windows-sys to 0.45
    
    * Update redox_syscall to 0.3
    
    * Fix unused_variables warning on redox
    taiki-e authored Feb 26, 2023
    Copy the full SHA
    ecab2b6 View commit details
  2. ci: replace unmaintained actions-rs/toolchain action in CI workflows (#…

    …215)
    
    Basically all of the `actions-rs/*` actions are unmaintained. See
    <actions-rs/toolchain#216> for more
    information. Due to their age they generate several warnings in
    CI runs.
    
    To get rid of some of those warnings the occurrences of
    `actions-rs/toolchain` are replaced by `dtolnay/rust-toolchain`.
    striezel authored Feb 26, 2023
    Copy the full SHA
    7d21182 View commit details

Commits on Mar 1, 2023

  1. Add a Dependabot config (#217)

    With this Dependabot will automatically file PRs to update dependencies. The cargo section watches
    `Cargo.toml` for semver-incompatible crate updates while the github-actions section watches the
    workflow files in `.github/workflows` for possible updates to any of the action in use.
    LingMan authored Mar 1, 2023
    Copy the full SHA
    f32650b View commit details
  2. Silence unused variable warnings (#219)

    These two are intentionally unused but are warned about when building e.g. wasm32-unknown-unknown.
    LingMan authored Mar 1, 2023
    Copy the full SHA
    279098a View commit details
  3. Specify the MSRV in the Cargo.toml (#220)

    It's good to have the MSRV available in a standarized, machine readable format.
    LingMan authored Mar 1, 2023
    Copy the full SHA
    089358d View commit details
  4. Fix and expand CI (#218)

    * Use rust-toolchain's stable and nightly branches
    
    Same behavior as before, just written a bit shorter.
    
    * Use rust-toolchain's `targets` input
    
    `target` exists as an alias, but `targets` is the documented name of this input, so let's use that.
    
    * Add rustfmt and clippy to CI
    
    * Downgrade to XCode 13 if Rust <= 1.53 on macOS
    
    On current macOS CI images XCode 14 is enabled by default. There's some incompatibility with
    Rust <= 1.53 causing link failures.
    The workaround is to revert back to XCode 13 while our MSRV is lower than 1.54.
    
    * Run CI on stable as well
    LingMan authored Mar 1, 2023
    Copy the full SHA
    7db7474 View commit details
  5. Copy the full SHA
    68fb23c View commit details

Commits on Mar 6, 2023

  1. build(deps): update rustix requirement from 0.36.0 to 0.37.1 (#222)

    Updates the requirements on [rustix](https://github.com/bytecodealliance/rustix) to permit the latest version.
    - [Release notes](https://github.com/bytecodealliance/rustix/releases)
    - [Commits](bytecodealliance/rustix@v0.36.0...v0.37.1)
    
    ---
    updated-dependencies:
    - dependency-name: rustix
      dependency-type: direct:production
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 6, 2023
    Copy the full SHA
    7c77c19 View commit details

Commits on Mar 29, 2023

  1. NamedTempFile: Fix infinite recursion in trait bounds (#225)

    Due to bug rust-lang/rust#96634, these generic bounds may cause an
    infinite recursion in the compiler, even in unrelated code.
    
    This specializes the `Write for &NamedTempFile<F>` impl on `File`
    instead. This keeps the API the same as before the generic parameter `F`
    was added, so it shouldn't break any code.
    jasonwhite authored Mar 29, 2023
    Copy the full SHA
    8ad7b8c View commit details
  2. chore: release 3.5.0

    Stebalien committed Mar 29, 2023
    Copy the full SHA
    c773849 View commit details
Showing with 87 additions and 51 deletions.
  1. +10 −0 .github/dependabot.yml
  2. +32 −30 .github/workflows/ci.yml
  3. +5 −4 Cargo.toml
  4. +9 −2 NEWS
  5. +2 −2 src/file/imp/other.rs
  6. +1 −1 src/file/imp/unix.rs
  7. +3 −12 src/file/mod.rs
  8. +25 −0 tests/namedtempfile.rs
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
62 changes: 32 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ jobs:
matrix:
rust-version:
- nightly
- stable
- "1.48"
os:
- ubuntu-latest
@@ -21,55 +22,56 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
default: true
- name: Build
uses: actions-rs/cargo@v1
# Workaround link failures if XCode 14 is combined with Rust <= 1.53
- name: Downgrade to XCode 13
if: ${{ matrix.os == 'macos-latest' && matrix.rust-version == '1.48' }}
uses: maxim-lobanov/setup-xcode@v1
with:
command: build
xcode-version: '13'
- name: Build
run: cargo build
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
run: cargo test
wasi:
name: WASI Test Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
uses: dtolnay/rust-toolchain@nightly
- name: Install Cargo WASI
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-wasi
run: cargo install cargo-wasi
- name: Build
uses: actions-rs/cargo@v1
with:
command: wasi
args: build --features nightly
run: cargo wasi build --features nightly
wasm:
name: WASM Test Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
toolchain: stable
default: true
targets: wasm32-unknown-unknown
- name: Build
uses: actions-rs/cargo@v1
run: cargo build --target wasm32-unknown-unknown
lint:
name: Clippy and fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
command: build
args: --target wasm32-unknown-unknown
components: clippy, rustfmt
- name: Check formatting
run: cargo fmt --check
- name: Check for clippy lints
run: cargo clippy
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tempfile"
version = "3.4.0"
version = "3.5.0"
authors = [
"Steven Allen <steven@stebalien.com>",
"The Rust Project Developers",
@@ -9,6 +9,7 @@ authors = [
]
documentation = "https://docs.rs/tempfile"
edition = "2018"
rust-version = "1.48"
homepage = "https://stebalien.com/projects/tempfile-rs/"
keywords = ["tempfile", "tmpfile", "filesystem"]
license = "MIT OR Apache-2.0"
@@ -20,17 +21,17 @@ cfg-if = "1"
fastrand = "1.6.0"

[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
rustix = { version = "0.36.0", features = ["fs"] }
rustix = { version = "0.37.1", features = ["fs"] }

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.42"
version = "0.45"
features = [
"Win32_Storage_FileSystem",
"Win32_Foundation",
]

[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.2.9"
redox_syscall = "0.3"

[dev-dependencies]
doc-comment = "0.3"
11 changes: 9 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
3.5.0
=====

- Update rustix from 0.36 to 0.37.1. This makes wasi work on rust stable
- Update `windows-sys`, `redox_syscall`
- BREAKING: Remove the implementation of `Write for &NamedTempFile<F> where &F: Write`. Unfortunately, this can cause compile issues in unrelated code (https://github.com/Stebalien/tempfile/issues/224).

3.4.0
=====

SECURITY: Prior `tempfile` releases depended on `remove_dir_all` version 0.5.0 which was vulnerabiel to a [TOCTOU race](https://github.com/XAMPPRocky/remove_dir_all/security/advisories/GHSA-mc8h-8q98-g5hr). This same race is present in rust versions prior to 1.58.1.
SECURITY: Prior `tempfile` releases depended on `remove_dir_all` version 0.5.0 which was vulnerable to a [TOCTOU race](https://github.com/XAMPPRocky/remove_dir_all/security/advisories/GHSA-mc8h-8q98-g5hr). This same race is present in rust versions prior to 1.58.1.

Features:

@@ -235,7 +242,7 @@ Add LFS Support.
2.0.0
=====

This release replaces `TempFile` with a `tempfile()` function that returnes
This release replaces `TempFile` with a `tempfile()` function that returns
`std::fs::File` objects. These are significantly more useful because most rust
libraries expect normal `File` objects.

4 changes: 2 additions & 2 deletions src/file/imp/other.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ fn not_supported<T>() -> io::Result<T> {
))
}

pub fn create_named(_path: &Path, open_options: &mut OpenOptions) -> io::Result<File> {
pub fn create_named(_path: &Path, _open_options: &mut OpenOptions) -> io::Result<File> {
not_supported()
}

@@ -25,6 +25,6 @@ pub fn persist(_old_path: &Path, _new_path: &Path, _overwrite: bool) -> io::Resu
not_supported()
}

pub fn keep(path: &Path) -> io::Result<()> {
pub fn keep(_path: &Path) -> io::Result<()> {
not_supported()
}
2 changes: 1 addition & 1 deletion src/file/imp/unix.rs
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
}

#[cfg(target_os = "redox")]
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
pub fn persist(_old_path: &Path, _new_path: &Path, _overwrite: bool) -> io::Result<()> {
// XXX implement when possible
Err(io::Error::from_raw_os_error(syscall::ENOSYS))
}
15 changes: 3 additions & 12 deletions src/file/mod.rs
Original file line number Diff line number Diff line change
@@ -918,10 +918,7 @@ impl<F: Read> Read for NamedTempFile<F> {
}
}

impl<'a, F> Read for &'a NamedTempFile<F>
where
&'a F: Read,
{
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())
}
@@ -937,10 +934,7 @@ impl<F: Write> Write for NamedTempFile<F> {
}
}

impl<'a, F> Write for &'a NamedTempFile<F>
where
&'a F: Write,
{
impl Write for &NamedTempFile<File> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.as_file().write(buf).with_err_path(|| self.path())
}
@@ -956,10 +950,7 @@ impl<F: Seek> Seek for NamedTempFile<F> {
}
}

impl<'a, F> Seek for &'a NamedTempFile<F>
where
&'a F: Seek,
{
impl Seek for &NamedTempFile<File> {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
self.as_file().seek(pos).with_err_path(|| self.path())
}
25 changes: 25 additions & 0 deletions tests/namedtempfile.rs
Original file line number Diff line number Diff line change
@@ -439,3 +439,28 @@ fn test_make_uds_conflict() {
assert!(socket.path().exists());
}
}

// Issue #224.
#[test]
fn test_overly_generic_bounds() {
pub struct Foo<T>(T);

impl<T> Foo<T>
where
T: Sync + Send + 'static,
for<'a> &'a T: Write + Read,
{
pub fn new(foo: T) -> Self {
Self(foo)
}
}

// Don't really need to run this. Only care if it compiles.
if let Ok(file) = File::open("i_do_not_exist") {
let mut f;
let _x = {
f = Foo::new(file);
&mut f
};
}
}