-
Notifications
You must be signed in to change notification settings - Fork 122
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
The generic version of NamedTempFile can break compilation #224
Comments
Sorry about that! I had been using the generic version of I suspect it is triggered by this impl: Lines 940 to 951 in 7c77c19
Then, the |
Here's another reproducer (without Ultimately, it seems that this is an issue with the compiler not supporting cycles in trait bounds: rust-lang/rust#96634 I think the easiest way to fix this is to change this impl<'a, F> Write for &'a NamedTempFile<F>
where
&'a F: Write,
{
// ...
} to this: impl Write for &NamedTempFile<File> {
// ...
} This makes it more specialized, but keeps the same requirements the same as before |
@Erk- Also, I am curious why |
It was from a larger piece of code where And thanks for the quick fix |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [tempfile](https://stebalien.com/projects/tempfile-rs/) ([source](https://togithub.com/Stebalien/tempfile)) | dev-dependencies | minor | `3.4.0` -> `3.7.1` | --- ### Release Notes <details> <summary>Stebalien/tempfile (tempfile)</summary> ### [`v3.7.1`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#371) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.7.0...v3.7.1) - Tempfile builds on haiku again. - Under the hood, we've switched from the unlinkat/linkat syscalls to the regular unlink/link syscalls where possible. ### [`v3.7.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#370) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.6.0...v3.7.0) BREAKING: This release updates the MSRV to 1.63. This isn't an API-breaking change (so no major release) but it's still a breaking change for some users. - Update fastrand from 1.6 to 2.0 - Update rustix to 0.38 - Updates the MSRV to 1.63. - Provide AsFd/AsRawFd on wasi. ### [`v3.6.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#360) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.5.0...v3.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. ### [`v3.5.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#350) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.4.0...v3.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](https://togithub.com/Stebalien/tempfile/issues/224)). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/knope-dev/knope). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMjcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dylan Anthony <[email protected]>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [tempfile](https://stebalien.com/projects/tempfile-rs/) ([source](https://togithub.com/Stebalien/tempfile)) | dev-dependencies | minor | `3.3.0` -> `3.10.1` | --- ### Release Notes <details> <summary>Stebalien/tempfile (tempfile)</summary> ### [`v3.10.1`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#3101) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.10.0...v3.10.1) - Handle potential integer overflows in 32-bit systems when seeking/truncating "spooled" temporary files past 4GiB (2³²). - Handle a theoretical 32-bit overflow when generating a temporary file name larger than 4GiB. Now it'll panic (on allocation failure) rather than silently succeeding due to wraparound. Thanks to [@​stoeckmann](https://togithub.com/stoeckmann) for finding and fixing both of these issues. ### [`v3.10.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#3100) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.9.0...v3.10.0) - Drop `redox_syscall` dependency, we now use `rustix` for Redox. - Add `Builder::permissions` for setting the permissions on temporary files and directories (thanks to [@​Byron](https://togithub.com/Byron)). - Update rustix to 0.38.31. - Update fastrand to 2.0.1. ### [`v3.9.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#390) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.8.1...v3.9.0) - Updates windows-sys to 0.52 - Updates minimum rustix version to 0.38.25 ### [`v3.8.1`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#381) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.8.0...v3.8.1) - Update rustix to fix a potential panic on `persist_noclobber` on android. - Update redox_syscall to 0.4 (on redox). - Fix some docs typos. ### [`v3.8.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#380) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.7.1...v3.8.0) - Added `with_prefix` and `with_prefix_in` to `TempDir` and `NamedTempFile` to make it easier to create temporary files/directories with nice prefixes. - Misc cleanups. ### [`v3.7.1`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#371) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.7.0...v3.7.1) - Tempfile builds on haiku again. - Under the hood, we've switched from the unlinkat/linkat syscalls to the regular unlink/link syscalls where possible. ### [`v3.7.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#370) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.6.0...v3.7.0) BREAKING: This release updates the MSRV to 1.63. This isn't an API-breaking change (so no major release) but it's still a breaking change for some users. - Update fastrand from 1.6 to 2.0 - Update rustix to 0.38 - Updates the MSRV to 1.63. - Provide AsFd/AsRawFd on wasi. ### [`v3.6.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#360) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.5.0...v3.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. ### [`v3.5.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#350) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.4.0...v3.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](https://togithub.com/Stebalien/tempfile/issues/224)). ### [`v3.4.0`](https://togithub.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#340) [Compare Source](https://togithub.com/Stebalien/tempfile/compare/v3.3.0...v3.4.0) SECURITY: Prior `tempfile` releases depended on `remove_dir_all` version 0.5.0 which was vulnerable to a [TOCTOU race](https://togithub.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: - Generalized temporary files: `NamedTempFile` can now abstract over different kinds of files (e.g., unix domain sockets, pipes, etc.): - Add `Builder::make` and `Builder::make_in` for generalized temp file creation. - Add `NamedTempFile::from_parts` to complement `NamedTempFile::into_parts`. - Add generic parameter to `NamedTempFile` to support wrapping non-File types. Bug Fixes/Improvements: - Don't try to create a temporary file multiple times if the file path has been fully specified by the user (no random characters). - `NamedTempFile::persist_noclobber` is now always atomic on linux when `renameat_with` is supported. Previously, it would first link the new path, then unlink the previous path. - Fix compiler warnings on windows. Trivia: - Switch from `libc` to `rustix` on wasi/unix. This now makes direct syscalls instead of calling through libc. - Remove `remove_dir_all` dependency. The rust standard library has optimized their internal version significantly. - Switch to official windows-sys windows bindings. Breaking: - The minimum rust version is now `1.48.0`. - Mark most functions as `must_use`. - Uses direct syscalls on linux by default, instead of libc. - The new type parameter in `NamedTempFile` may lead to type inference issues in some cases. </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 5am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/crate-ci/escargot). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjQyMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
The more generic version of
NamedTempFile
introduced in #177 by @jasonwhite can break compilation in some cases without even being involved itself. It seems to happen in some cases with generic where it will turn into a infinitely recursive type.Example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=671872049ef51f20f8bcc976177c6b62
if you comment the line
use tempfile;
the code will compile as expected.edit: Made the MRE smaller.
The text was updated successfully, but these errors were encountered: