Skip to content

Commit 1d2c511

Browse files
Apply suggestions from code review
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
1 parent e766034 commit 1d2c511

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

posts/2021-03-25-Rust-1.51.0.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ from the appropriate page on our website, and check out the
2424
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1510-2021-03-25
2525

2626
## What's in 1.51.0 stable
27-
This release represents one of the largest additions to the Rust language and cargo in quite a while. With the stabilization of const generics, and the new feature resolver, along with more minor additions such as the `split-debuginfo` option, and the `addr_of!` API. Let's dive right into it!
27+
This release represents one of the largest additions to the Rust language and Cargo in quite a while, stabilizing an MVP of const generics and a new feature resolver for Cargo. Let's dive right into it!
2828

2929

3030
### Const Generics MVP
31-
Before this release, Rust allowed you to haves your types be parameterized over lifetimes or types. For example if we wanted to have a `struct` that is generic over an array of 32 items, we'd write the following:
31+
Before this release, Rust allowed you to haves your types be parameterized over lifetimes or types. For example if we wanted to have a `struct` that is generic over the element type of an array, we'd write the following:
3232

3333
```rust
3434
struct FixedArray<T> {
@@ -46,7 +46,7 @@ struct FixedArray<u8> {
4646
}
4747
```
4848

49-
This is a powerful feature that allows you to write reusable code with no runtime overhead. Enabling to have types that fit a wide variety of use-cases and types. However, until this release it hasn't been possible to easily be generic over the *values* of those types. This was most notable in arrays where they include their length in their type definition (`[T; N]`). Now with 1.51.0 you can write code that is generic over the values of any integer, `bool`, or `char` type! (Using `struct` or `enum` values is still unstable.)
49+
This is a powerful feature that allows you to write reusable code with no runtime overhead. However, until this release it hasn't been possible to easily be generic over the *values* of those types. This was most notable in arrays which include their length in their type definition (`[T; N]`), which previously you could not be generic over. Now with 1.51.0 you can write code that is generic over the values of any integer, `bool`, or `char` type! (Using `struct` or `enum` values is still unstable.)
5050

5151
This change now lets us have our own array struct that's generic over its type *and* its length. Let's look at an example definition, and how it can be used.
5252

@@ -129,11 +129,11 @@ resolver = "2"
129129
[feature-resolver@2.0]: https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2
130130

131131
### Splitting Debug Information
132-
While not often highlighted in the release, the Rust teams are constantly working on improving Rust's compile times, and this release marks one of the biggest improvements in a long time for Rust on macOS platforms. Debug information is code that maps the binary code back to your source code, so that the program can give you more information about what went wrong at run time. In macOS this is done with a tool called `dsymutil` which collects all the debug information into a single `.dSYM` folder.
132+
While not often highlighted in the release, the Rust teams are constantly working on improving Rust's compile times, and this release marks one of the largest improvements in a long time for Rust on macOS platforms. Debug information is code that maps the binary code back to your source code, so that the program can give you more information about what went wrong at runtime. In macOS, debug info is typically collected using a tool called `dsymutil` which places all the debug information into a single `.dSYM` folder.
133133

134-
This tool provides a lot of benefits, however, one of the drawbacks has been that `dsymutil` is not really compatible with incremental recompilation. This means that even when you make a small change such as a function name, `dsymutil` will need to run over the entire final binary to produce the final `.dSYM` folder. This can sometimes add a lot to the build time, (especially for larger projects), but this has been a necessary step as without it Rust wouldn't be able to parse debug info on macOS.
134+
This tool provides a lot of benefits, however, one of the drawbacks has been that `dsymutil` is not really compatible with incremental recompilation. This means that even when you make a small change such as a function name, `dsymutil` will need to run over the entire final binary to produce the final `.dSYM` folder. This can sometimes add a lot to the build time, especially for larger projects, as each dependency needs to be recollected, but this has been a necessary step as without it Rust wouldn't be able to load the debug info on macOS.
135135

136-
With the implementation of the Rust-based `backtrace` crate backend, we can now parse debuginfo even without running `dsymutil`. This can significantly speed up builds that include debuginfo and significantly reduce the amount of disk space used. We haven't run extensive benchmarks but have seen a lot of anecdata of people's builds building a lot faster on macOS with this behaviour.
136+
Recently, Rust backtraces switched to using a different backend which supports loading debuginfo without needing to run `dsymutil`. This can significantly speed up builds that include debuginfo and significantly reduce the amount of disk space used. We haven't run extensive benchmarks but have seen a lot of reports of people's builds being a lot faster on macOS with this behavior.
137137

138138
You can enable this new behaviour by setting the `-Csplit-debuginfo=unpacked` flag when running `rustc`, or by setting the [`split-debuginfo`] `[profile]` option to `unpacked` in Cargo. The "unpacked" option instructs rustc to leave the .o object files in the build output directory instead of deleting them, and skips the step of running dsymutil. Rust's backtrace support is smart enough to know how to find these .o files. Tools such as lldb also know how to do this. This should work as long as you don't need to move the binary to a different location while retaining the debug information.
139139

@@ -146,7 +146,7 @@ split-debuginfo = "unpacked"
146146

147147
### Stabilized APIs
148148

149-
In total, this release saw the stabilisation of 18 new methods for various types like `slice` and `Peekable`. One notable addition is the stabilisation of `ptr::addr_of!` and `ptr::addr_of_mut!`, which allow you to create unaligned references to data. Previously this wasn't possible because Rust requires `&/&mut` to be aligned and point to initialized data, and `&addr as *const _` would cause undefined behaviour as `&addr` needs to be aligned. These two macros now let you safely create unaligned references.
149+
In total, this release saw the stabilisation of 18 new methods for various types like `slice` and `Peekable`. One notable addition is the stabilisation of `ptr::addr_of!` and `ptr::addr_of_mut!`, which allow you to create raw pointers to unaligned fields. Previously this wasn't possible because Rust requires `&/&mut` to be aligned and point to initialized data, and `&addr as *const _` would then cause undefined behaviour as `&addr` needs to be aligned. These two macros now let you safely create unaligned pointers.
150150

151151
```rust
152152
use std::ptr;
@@ -189,8 +189,8 @@ The following methods were stabilised.
189189
[`panic::panic_any`]: https://doc.rust-lang.org/stable/std/panic/fn.panic_any.html
190190
[`slice::strip_prefix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
191191
[`slice::strip_suffix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
192-
[`Arc::increment_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.increment_strong_count
193-
[`Arc::decrement_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.decrement_strong_count
192+
[`Arc::increment_strong_count`]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.increment_strong_count
193+
[`Arc::decrement_strong_count`]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.decrement_strong_count
194194
[`slice::fill_with`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.fill_with
195195
[`ptr::addr_of!`]: https://doc.rust-lang.org/nightly/std/ptr/macro.addr_of.html
196196
[`ptr::addr_of_mut!`]: https://doc.rust-lang.org/nightly/std/ptr/macro.addr_of_mut.html

0 commit comments

Comments
 (0)