-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Confusing suggestion for dropping_copy_types #125189
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.L-dropping_copy_typesLint: dropping_copy_typesLint: dropping_copy_typesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.L-dropping_copy_typesLint: dropping_copy_typesLint: dropping_copy_typesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
I had the following code:
if we compile this,
rustcrightly warns us:This bit, however:
… I'm not clear on. Let's take the compiler's suggestion and modify the code:
Now we'll get an even more confusing diagnostic:
…we're now
note'd to do something we're already doing.A competing interpretation of this diagnostic, in my mind, is that it means to do
let _ = <the original expression where we compute w_fd>. But we cannot do that, as we usew_fd. I suppose we could inline all the uses, but I wonder ifrustcshouldn't realize that no, the variable must be named / that suggestion breaks the compile. Or, shouldrustcunderstand that we cannotlet _ =this variable, and that we'd need to inline it? But here there are two inlines, and in the general case, side-effects in the expression could make this tricky.The higher level thing here is that I was attempting to drop a variable from scope, essentially, by moving it with
drop. Obviously, that doesn't work forCopytypes. I guess I could use{}to scopew_fd… but unfortunately I need bothcmd_stdoutandcmd_stderrlater.Current output
Desired output
No response
Rationale and extra context
No response
Other cases
No response
Rust Version
Anything else?
No response