-
Notifications
You must be signed in to change notification settings - Fork 689
PollFd implementing Copy is a footgun #2630
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
Comments
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 14, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. This fixes nix-rust#2630
Good point. |
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 15, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes nix-rust#2630
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 15, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes nix-rust#2630
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 15, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes nix-rust#2630
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 15, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes nix-rust#2630
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 17, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes nix-rust#2630
JonathonReinhart
added a commit
to JonathonReinhart/nix
that referenced
this issue
Apr 22, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes nix-rust#2630
github-merge-queue bot
pushed a commit
that referenced
this issue
Apr 22, 2025
PollFd implementing Copy makes it easy to accidentally refer to the wrong object after putting one into an array. Remove Copy to force move semantics. This also updates some related docs to improve overall clarity. This fixes #2630
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this code speaks for itself:
The fact that
PollFd
implementsCopy
makes it easy to make this mistake.Normally, Rust doesn't let you make mistakes like this. If
PollFd
didn't implementCopy
, rust would complain if you tried to write this code. You'd have to call.clone()
and then there would be an explicit clue that you're not operating on the same object.The text was updated successfully, but these errors were encountered: