Rust 1.77.0: 70 highlights in 30 minutes
Vložit
- čas přidán 5. 04. 2024
- New changes Rust 1.77.0!
Links:
Rust 1.77.0 Blog Post - blog.rust-lang.org/2024/03/21...
Rust 1.77.1 Blog Post - blog.rust-lang.org/2024/03/28...
async fn calls PR - github.com/rust-lang/rust/pul...
Exhaustiveness: reveal opaque types properly - github.com/rust-lang/rust/pul...
Changes to u128/i128 layout - blog.rust-lang.org/2024/03/30...
Error on incorrect implied bounds in well-formedness check - github.com/rust-lang/rust/pul...
Internal fixes - github.com/rust-lang/rust/pul...
New cargo:: build directive - github.com/rust-lang/cargo/pu...
Cargo documentation updates - github.com/rust-lang/cargo/bl...
The Ferris-the-crab image on today's title picture is by Abi Broom, who is currently the Operations Manager of the Rust Foundation. This Ferris appears to have been hand-drawn in black marker on a piece of paper with hasty strokes for the main body, with a particular jaunty top of the head that evokes the image of a Calvin-and-Hobbes hairdo, with special attention given to providing ferris with adorable shiny eyes. The mouth is reminiscent of Leonardo Da Vinci's Mona Lisa smile, suggesting the artist has been influenced by old Italian culture, and may enjoy pizza and pasta. If you would like to add a copy of this ferris to your collection, you can download the image at foundation.rust-lang.org/img/...
0:21 1. C-string literals
1:02 2. Recursive async fn
2:12 3. offset_of!
2:38 4. std debuginfo is now stripped
3:52 5. incompatible_msrv lint
4:56 Other Rust Changes
5:07 6. Exhaustiveness: reveal opaque types properly
5:31 7. Stabilize THIR unsafeck
6:00 8. New static_mut_refs lint
6:20 9. Undeprecate unstable_features lint
6:38 10. coinductive_overlap_in_coherence promoted to hard error
6:54 11. Eliminate type-driven traversal in const-eval interning
7:22 12. Deny braced macro invocations in let-else statements.
8:12 13. soft_unstable lints now shows up in future breakage reports
8:23 14. Make i128 and u128 16-byte aligned on x86-based targets
8:59 15. Diagnostics now emit more information with --verbose
9:16 16. Improve spacing between printed tokens
9:27 17. Merge unused_tuple_struct_fields into dead_code
9:42 18. Error on incorrect implied bounds in well-formedness check
10:16 19. Fix coverage instrumentation/reports for non-ASCll source code.
10:41 20. Internal fixes
11:06 21. Target Promotions
11:19 22. New Tier 3 Targets
11:55 23. Implement From(&[T; N]) for Cow([T])
12:13 24. Remove special-case handling of Vec::split_off(0)
12:45 Stabilized APIs
12:56 25. array::each_ref & array::each_mut
13:12 26. core::net
13:44 27. round_ties_even for f32 & f64
14:09 28. slice chunk methods
15:29 29. Bound::map
16:00 30. File::create_new
16:37 31. Mutex::clear_poison & RwLock::clear_poison
17:12 Rustdoc
17:17 32. Links allowed in markdown headings
17:24 33. Docs search box supports parens-based type expression syntax
17:44 34. New icon to expand files pane in docs source code view
18:04 35. Prevent JS injection from localStorage
18:21 36. Recommend version-sorting in the Style Guide
18:43 37. More weirdness in weird-exprs .rs
21:00 Cargo
21:03 38. Extend build directive syntax with cargo::
21:28 39. Stabilize id format as PackageIDSpec
21:51 40. cargo-util-schemas
22:09 41. Inherit jobserver from env for all kinds of runner
22:30 42. rustc plugin support deprecated in cargo
22:44 43. Add colors to -Zhelp console output
22:53 44. Add rustc style errors for Cargo.toml parsing
23:05 45. Hold the mutate exclusive lock when vendoring
23:17 46. Set Content-Type: application/json only for requests with a body payload
23:32 47. Set OUT_DIR for all units with build scripts
23:42 48. Fix cargo add selecting the wrong package
23:58 49. cargo fix calls rustc fewer times
24:06 50. Don't inherit workspace if new package is on exclude list
24:17 51. Fix cargo update --precise to accept git branches and tags
24:31 52. Warn about unused keys in the [lints] section of Cargo.toml
24:43 53. Support inserting new lines in cargo fix
24:56 54. Various documentation updates
25:09 Clippy
25:12 55. multiple_crate_versions (feature)
25:34 56. single_call_fn (fix)
25:48 57. unit_arg (fix)
26:02 58. indexing_slicing (fix)
26:24 59. suspicious_open_options
26:44 60. option_as_ref_cloned
26:59 61. thread_local_initializer_can_be_made_const
27:20 62. str_split_at_newline
27:41 63. empty_enum_variants_with_brackets
27:53 64. manual_is_variant_and
28:12 65. pub_underscore_fields
28:34 66. eager_transmute
28:57 67. iter_filter_is_some
29:07 68. iter_filter_is_ok
29:21 69. result_filter_map
29:37 70. unconditional_recursion
Visit ultimaterustcourses.com for Ultimate Rust Crash Course and other Rust courses! - Věda a technologie
Recursion is useful for functional-style programming because you can avoid mutable variables. The usual advantages of functional programming apply; being more amenable to tree-like structures and inductive reasoning on them rather than reasoning about state transitions and invariants. The former is often more intuitive and functional code tends to more directly express what is happening at a high level. The usual disadvantages also apply; mainly having to rely on the compiler for performance, which makes it harder to optimize the code.
Thanks! Very concise and informative!
*Timestamps*
00:21 1. C-string literals
01:02 2. Recursive async fn
02:12 3. offset_of!
02:38 4. std debuginfo is now stripped
03:52 5. incompatible_msrv lint
*Other Rust Changes*
05:07 6. Exhaustiveness: reveal opaque types properly
05:31 7. Stabilize THIR unsafeck
06:00 8. New static_mut_refs lint
06:20 9. Undeprecate unstable_features lint
06:38 10. coinductive_overlap_in_coherence promoted to hard error
06:54 11. Eliminate type-driven traversal in const-eval interning
07:22 12. Deny braced macro invocations in let-else statements.
08:12 13. soft_unstable lints now shows up in future breakage reports
08:23 14. Make i128 and u128 16-byte aligned on x86-based targets
08:59 15. Diagnostics now emit more information with --verbose
09:16 16. Improve spacing between printed tokens
09:27 17. Merge unused_tuple_struct_fields into dead_code
09:42 18. Error on incorrect implied bounds in well-formedness check
10:16 19. Fix coverage instrumentation/reports for non-ASCll source code.
10:41 20. Internal fixes
11:06 21. Target Promotions
11:19 22. New Tier 3 Targets
11:55 23. Implement From for Cow
12:13 24. Remove special-case handling of Vec::split_off(0)
*Stabilized APIs*
12:56 25. array::each_ref & array::each_mut
13:12 26. core::net
13:44 27. round_ties_even for f32 & f64
14:09 28. slice chunk methods
15:29 29. Bound::map
16:00 30. File::create_new
16:37 31. Mutex::clear_poison & RwLock::clear_poison
*Rustdoc*
17:17 32. Links allowed in markdown headings
17:24 33. Docs search box supports parens-based type expression syntax
17:44 34. New icon to expand files pane in docs source code view
18:04 35. Prevent JS injection from localStorage
18:21 36. Recommend version-sorting in the Style Guide
18:43 37. More weirdness in weird-exprs .rs
*Cargo*
21:03 38. Extend build directive syntax with cargo::
21:28 39. Stabilize id format as PackageIDSpec
21:51 40. cargo-util-schemas
22:09 41. Inherit jobserver from env for all kinds of runner
22:30 42. rustc plugin support deprecated in cargo
22:44 43. Add colors to -Zhelp console output
22:53 44. Add rustc style errors for Cargo.toml parsing
23:05 45. Hold the mutate exclusive lock when vendoring
23:17 46. Set Content-Type: application/json only for requests with a body payload
23:32 47. Set OUT_DIR for all units with build scripts
23:42 48. Fix cargo add selecting the wrong package
23:58 49. cargo fix calls rustc fewer times
24:06 50. Don't inherit workspace if new package is on exclude list
24:17 51. Fix cargo update --precise to accept git branches and tags
24:31 52. Warn about unused keys in the [lints] section of Cargo.toml
24:43 53. Support inserting new lines in cargo fix
24:56 54. Various documentation updates
*Clippy*
25:12 55. multiple_crate_versions (feature)
25:34 56. single_call_fn (fix)
25:48 57. unit_arg (fix)
26:02 58. indexing_slicing (fix)
26:24 59. suspicious_open_options
26:44 60. option_as_ref_cloned
26:59 61. thread_local_initializer_can_be_made_const
27:20 62. str_split_at_newline
27:41 63. empty_enum_variants_with_brackets
27:53 64. manual_is_variant_and
28:12 65. pub_underscore_fields
28:34 66. eager_transmute
28:57 67. iter_filter_is_some
29:07 68. iter_filter_is_ok
29:21 69. result_filter_map
29:37 70. unconditional_recursion
You're my new favorite commenter! You just saved me a bunch of time! Thanks!
@@NathanStocks you're welcome!
Thank you for making these Nathan. I very much appreciate the time you put into them - very informative and useful. Do you have a donation link? Would love to buy you a coffee(s) for your hard work.
That would be awesome! I'm up to ~20 hours to produce each of these videos, and its getting really hard to find the time to continue (which is why this video was late). If I could get some sponsors, that would help immensely. Sponsor me on GitHub to support these videos: github.com/sponsors/CleanCut
Another great video, thank you as always. Awesome to see Josh's great work featured again with a pic this time too - I've been playing around with his cool crate io-mux lately
You're welcome! io-mux looks interesting, thanks for mentioning it!
Informative and concise. Useful especially for us maintainers.
Subscribed!
Thank you! Informative and concise are two things I specifically strive for. Another one is "not boring". Dunno whether I'm accomplishing that one. 😆
@@NathanStocks definitely "no boring" was the cherry on top!
Good stuff, makes some features easier to understand. Thanks
You're welcome! I'm glad it helped. 😄
About the recursion vs iteration: There is a whole class of algorithms that are impossible to implement without recursion. Famous example is Ackerman's function, Computerphile has a few great videos about that with prof. Brailsford. Also there are algorithms that are simply easier to implement recursively than iteratively, for example graph/tree exploration.
Edit: I have been corrected, apparently all recursion can be implement with loops. But the second part is correct, some of them are so complicated it is way easier and more practical to do them recursively.
Any recursive function can be written without recursion, for example by simulating the call stack with a vector, though you might need to use while loops. Ackermann's function is one such function that requires while loops (or recursion). This is of theoretical interest because use of general recursion and while loops makes it more difficult to reason about termination and runtime. Well founded recursion can help reason about termination, but not about runtime.
This is more of a theoretic consideration though. What's important is the readability, maintainability and utility of production code, which Ackermann's function is not going to be part of. I agree with your tree example.
@@gamekiller0123 Interesting. I was under the impression that there is a class of algorithms that can not be de-recursed, based on this video: czcams.com/video/i7sm9dzFtEI/video.html (especially first 40 seconds). But maybe I misunderstood, I'm not an expert in this area.
@@thornuridbahir8309 He did explicitly mention for loops a few times. For the final statement "Well, there are some things which are so fundamentally recursive that you just have to do them recursively" he's likely working in a computational model where there are no while loops, or considers while loops comparable to recursion. Or maybe he was just a bit imprecise there.
@@gamekiller0123 oh I see, i didn't differentiate for loop and while loop. Now looking back, it should be obvious that while loops are more powerful. Thanks, I learned something new today.
All recursion algorithms can be implemented with loops, proof by Turing-completeness. However, the loop implementation is disgusting sometimes.
A quite simple and practical example of why you would use recursive async functions would be to delete a large folder with multiple threads. If you were to do it in a loop you would need to set up a queue and collectors and write logic to determining what files can be deleted when. With a recursive delete you simply iterate over every child of a folder and call delte recursively then finally delete the folder. All of the logic and scheduling is done by recursion implicitly.
Alright. So what I'm hearing is "for algorithmic simplicity". I can buy that.
@@NathanStocks Yep! I mean from my experience recursive vs loop solution usually comes down to... do you have a tree like data structure and are you concerned about stack depth.
@@lapissea1190 I tried recursion a couple times early on in my career in Python -- maxed out stack depth each time. 🤣
@@NathanStocks Oof yeah. I have plenty of bad experiences with python. Maybe because I'm a bit of a performance nut and like to optimize things
One really important use for recursive calls is compilers.
Ah, interesting!
3:23 it seems strip removes debuginfo and symbols. So stack traces won’t have line numbers or function names.
I think the file, line and column numbers will still be in there with strip=true and need -Zlocation-detail=none to get removed
Y'all are going to tantalize me with possibilities until I go and do the research myself to find out for sure, aren't you? 😆
Well recursion makes the code simpler in many cases.
If you're depth-first traversing any kind of branched structure, recursion might be a lot simpler to code, because it handles all the backtracking for you correctly, you will at most need to manually code how to undo a single step. No off-by-one errors on how far to step back, no fear of mixing things up when backtracking many messy steps, easier to remember to go down all paths.
Oh boy recursive `async fn` is huge!
One use case for recursive fn is when you are talking to another stateful service and needs to 'redirect' the request to another upstream server
Interesting! I haven't considered that case before.
Regarding recursion: NURBS curves and surfaces (massively used in industry) are defined by recursive basis functions, so to evaluate them, it can be useful to do so recursively.
TIL about Non-Uniform Rational B-Splines modeling. Sounds like you are saying that using recursion is a simpler way to model recursive concepts. Makes sense, thanks! 😄
6:43 Isn't that breaking backwards-compatibility?
> Rust logo
not affiliated with the Rust Foundation
Are you asking a question? Or...?
@@NathanStocks just memeing around
Isn’t Cow clone on write? Not copy. Oops @12 or so min 12:00
Ha! You caught me. It's totally clone-on-write. My bad!
10:08 Anyone else feel uncomfortable by this? If it was an exception for warnings, that would've seemed reasonable. But errors protect the parse and semantic rules of a language. So we're literally breaking the language for a project? It's pragmatic sure, but it feels... wrong and unfair. Should've just not introduced the error till Bevy got patched.
I held off replying to see if we would get any other comments first, but it looks like we're not going to get any.
I do not feel that way at all. I view this as *not* breaking the language for a specific project. I'm not sure how breaking a large, popular project unnecessarily would be the "right and fair" choice. Take a look at the projects affected by this change. From what I can tell, the list consists entirely of Bevy and projects that use Bevy: crater-reports.s3.amazonaws.com/pr-109482-1/retry-regressed-list.txt
Rust 1.77! Brand new! Now with even bigger chunks of pineapple!
I'm...at a loss for words. Is this from a meme or something, or just a random statement? I mean, I do like grilled pineapple...😄
@@NathanStocks I don't think it's a meme, or maybe this will be starting one! I was just gently making fun of the Rust development cycle, and the kind of marketing that tends to go around it. Glad you like grilled pineapple, so that has resonated with you at least on some level.😁
@@joseoncrack Ah, okay. I get it. Also, grilled pineapple is a must at any cookout. Pairs well with...everything. 😉
Bevy was not any library. There are plenty snippets specifically for Bevy in rustc
EDIT:
Sorry. Corrected: only one snippet
All the snippets I can find only relate to the exception mentioned in the video. The remaining mentions are in tests, not the compiler.
@@gamekiller0123 You are right. I was wrong. There is one and exactly one piece of consecutive code.