-
Notifications
You must be signed in to change notification settings - Fork 13k
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
edition 2024 migration of Command::before_exec
is suboptimal and doesn't compile
#134003
Comments
It’s because the fn foo() {
{
&mut String::new()
}.push_str("hello");
} The current version of the migration guide doesn’t really explain this part and describes things as if the issue is only about drop order within the block. I’ll file an issue about that. |
@kpreid thanks for the explanation! |
The main issue here is that there is currently no machine-applicable lint for If there were, then that would run along with the This also relates to... ...in that The other two maybe-actionable asks in this issue are:
|
I don't think it should.
That sounds reasonable. I wonder how hard it is to implement this. I can probably not just walk the contents and remove all unsafe blocks, because there might be functions which open another safe scope. |
Since the tail expression drop order is a likely issue for most |
See also: |
I ran
cargo +nightly fix --edition
on this code:And it made the following changes:
The output is unsatisfying in a few ways:
unsafe
blocks, triggering theunused_unsafe
lint.before_exec
is still deprecated, so perhaps it should just be replaced withpre_exec
?edition = "2024"
toCargo.toml
:I wouldn't have submitted an issue based on the first three, but since
cargo fix
is responsible for the new structure of the code, it seems like the failure to compile should have been avoidable.I am confused about why this doesn't build. Why does
pre_exec
/before_exec
cause there to be a dropped-while-borrowed temporary under the 2024 edition where none existed previously?To repair the broken build, I guess something like this is required? (The
let mut cmd
part.)Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: