You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current content of this page only talks about the drop order within a block, and gives an example of code that does not compile in 2021 but does in 2024. However, the 2021 rules allow temporaries to outlive the block into the enclosing expression, such as the String in the following program:
// compiles in 2021; fails in 2024fnfoo(){{&mutString::new()}.push_str("hello");}
This program cannot be fixed merely by reordering or introducing variables within the affected block. This case should be documented in order to help users with situations such as rust-lang/rust#134003.
Thanks for the report! Yea, the chapter was pretty light and definitely could use some expansion. I have posted #345 to try to address this. There's probably still more that can be said, but it's a bit of a tricky topic to describe succinctly.
Thanks for looking at this, @ehuss. Should this issue be labeled Edition-2024 for the record? I tried to do that but wasn't allowed. Could you do so if it is appropriate?
Location:
https://github.com/rust-lang/edition-guide/blob/4efbefa611258543294f77ee03643eb16800b399/src/rust-2024/temporary-tail-expr-scope.md
The current content of this page only talks about the drop order within a block, and gives an example of code that does not compile in 2021 but does in 2024. However, the 2021 rules allow temporaries to outlive the block into the enclosing expression, such as the
String
in the following program:This program cannot be fixed merely by reordering or introducing variables within the affected block. This case should be documented in order to help users with situations such as rust-lang/rust#134003.
@rustbot label Edition-2024
The text was updated successfully, but these errors were encountered: