Skip to content
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

NamedTempFile: Fix infinite recursion in trait bounds #225

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

jasonwhite
Copy link
Contributor

@jasonwhite jasonwhite commented Mar 24, 2023

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 in #177, so it shouldn't break any code. If/when the compiler bug is fixed, we can switch it back to the more generic version. Very few types implement Write for &T, however. The only other one I know of is UnixStream, which probably wouldn't be used with NamedTempFile anyway (it's counterpart UnixListener is used instead).

Fixes #224.

@jasonwhite jasonwhite marked this pull request as draft March 24, 2023 21:05
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 jasonwhite marked this pull request as ready for review March 24, 2023 21:10
Copy link
Owner

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoying but yeah, this should be reasonable breakage.

@Stebalien
Copy link
Owner

Thanks!

@Stebalien Stebalien merged commit 8ad7b8c into Stebalien:master Mar 29, 2023
@jasonwhite jasonwhite deleted the fix-generic-bounds branch March 29, 2023 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The generic version of NamedTempFile can break compilation
2 participants