|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Announcing Rust 1.73.0" |
| 4 | +author: The Rust Release Team |
| 5 | +release: true |
| 6 | +--- |
| 7 | + |
| 8 | +The Rust team is happy to announce a new version of Rust, 1.73.0. Rust is a programming language empowering everyone to build reliable and efficient software. |
| 9 | + |
| 10 | +If you have a previous version of Rust installed via rustup, you can get 1.73.0 with: |
| 11 | + |
| 12 | +```console |
| 13 | +rustup update stable |
| 14 | +``` |
| 15 | + |
| 16 | +If you don't have it already, you can [get `rustup`](https://www.rust-lang.org/install.html) from the appropriate page on our website, and check out the [detailed release notes for 1.73.0](https://github.com/rust-lang/rust/releases/tag/1.73.0) on GitHub. |
| 17 | + |
| 18 | +If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`). Please [report](https://github.com/rust-lang/rust/issues/new/choose) any bugs you might come across! |
| 19 | + |
| 20 | +## What's in 1.73.0 stable |
| 21 | + |
| 22 | +## Cleaner panic messages |
| 23 | + |
| 24 | +The output produced by the default panic handler has been changed |
| 25 | +to put the panic message on its own line instead of wrapping it in quotes. |
| 26 | +This can make panic messages easier to read, as shown in this example: |
| 27 | + |
| 28 | +<div style="margin:1em"><pre><code>fn main() { |
| 29 | + let file = "ferris.txt"; |
| 30 | + panic!("oh no! {file:?} not found!"); |
| 31 | +}</code></pre> |
| 32 | +Output before Rust 1.73: |
| 33 | +<pre style="margin-top:0"><code style="background:#000;color:#ccc" class="language-text">thread 'main' panicked at 'oh no! "ferris.txt" not found!', src/main.rs:3:5</code></pre> |
| 34 | +Output starting in Rust 1.73: |
| 35 | +<pre style="margin-top:0"><code style="background:#000;color:#ccc" class="language-text">thread 'main' panicked at src/main.rs:3:5: |
| 36 | +oh no! "ferris.txt" not found!</code></pre></div> |
| 37 | + |
| 38 | +This is especially useful when the message is long, contains nested quotes, or spans multiple lines. |
| 39 | + |
| 40 | +Additionally, the panic messages produced by `assert_eq` and `assert_ne` have |
| 41 | +been modified, moving the custom message (the third argument) |
| 42 | +and removing some unnecessary punctuation, as shown below: |
| 43 | + |
| 44 | +<div style="margin:1em"><pre><code>fn main() { |
| 45 | + assert_eq!("🦀", "🐟", "ferris is not a fish"); |
| 46 | +}</code></pre> |
| 47 | +Output before Rust 1.73: |
| 48 | +<pre style="margin-top:0"><code style="background:#000;color:#ccc" class="language-text">thread 'main' panicked at 'assertion failed: `(left == right)` |
| 49 | + left: `"🦀"`, |
| 50 | +right: `"🐟"`: ferris is not a fish', src/main.rs:2:5</code></pre> |
| 51 | +Output starting in Rust 1.73: |
| 52 | +<pre style="margin-top:0"><code style="background:#000;color:#ccc" class="language-text">thread 'main' panicked at src/main.rs:2:5: |
| 53 | +assertion `left == right` failed: ferris is not a fish |
| 54 | + left: "🦀" |
| 55 | +right: "🐟"</code></pre></div> |
| 56 | + |
| 57 | +### Thread local initialization |
| 58 | + |
| 59 | +As proposed in [RFC 3184](https://github.com/rust-lang/rfcs/blob/master/text/3184-thread-local-cell-methods.md), `LocalKey<Cell<T>>` and `LocalKey<RefCell<T>>` can now be directly manipulated with `get()`, `set()`, `take()`, and `replace()` methods, rather than jumping through a `with(|inner| ...)` closure as needed for general `LocalKey` work. `LocalKey<T>` is the type of `thread_local!` statics. |
| 60 | + |
| 61 | +The new methods make common code more concise and avoid running the extra initialization code for the default value specified in `thread_local!` for new threads. |
| 62 | + |
| 63 | +```rust |
| 64 | +thread_local! { |
| 65 | + static THINGS: Cell<Vec<i32>> = Cell::new(Vec::new()); |
| 66 | +} |
| 67 | + |
| 68 | +fn f() { |
| 69 | + // before: |
| 70 | + THINGS.with(|i| i.set(vec![1, 2, 3])); |
| 71 | + // now: |
| 72 | + THINGS.set(vec![1, 2, 3]); |
| 73 | + |
| 74 | + // ... |
| 75 | + |
| 76 | + // before: |
| 77 | + let v = THINGS.with(|i| i.take()); |
| 78 | + // now: |
| 79 | + let v: Vec<i32> = THINGS.take(); |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +### Stabilized APIs |
| 84 | + |
| 85 | +- [Unsigned `{integer}::div_ceil`](https://doc.rust-lang.org/stable/std/primitive.u32.html#method.div_ceil) |
| 86 | +- [Unsigned `{integer}::next_multiple_of`](https://doc.rust-lang.org/stable/std/primitive.u32.html#method.next_multiple_of) |
| 87 | +- [Unsigned `{integer}::checked_next_multiple_of`](https://doc.rust-lang.org/stable/std/primitive.u32.html#method.checked_next_multiple_of) |
| 88 | +- [`std::ffi::FromBytesUntilNulError`](https://doc.rust-lang.org/stable/std/ffi/struct.FromBytesUntilNulError.html) |
| 89 | +- [`std::os::unix::fs::chown`](https://doc.rust-lang.org/stable/std/os/unix/fs/fn.chown.html) |
| 90 | +- [`std::os::unix::fs::fchown`](https://doc.rust-lang.org/stable/std/os/unix/fs/fn.fchown.html) |
| 91 | +- [`std::os::unix::fs::lfchown`](https://doc.rust-lang.org/stable/std/os/unix/fs/fn.lchown.html) |
| 92 | +- [`LocalKey::<Cell<T>>::get`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.get) |
| 93 | +- [`LocalKey::<Cell<T>>::set`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.set) |
| 94 | +- [`LocalKey::<Cell<T>>::take`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.take) |
| 95 | +- [`LocalKey::<Cell<T>>::replace`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.replace) |
| 96 | +- [`LocalKey::<RefCell<T>>::with_borrow`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.with_borrow) |
| 97 | +- [`LocalKey::<RefCell<T>>::with_borrow_mut`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.with_borrow_mut) |
| 98 | +- [`LocalKey::<RefCell<T>>::set`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.set-1) |
| 99 | +- [`LocalKey::<RefCell<T>>::take`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.take-1) |
| 100 | +- [`LocalKey::<RefCell<T>>::replace`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.replace-1) |
| 101 | + |
| 102 | +These APIs are now stable in const contexts: |
| 103 | + |
| 104 | +- [`rc::Weak::new`](https://doc.rust-lang.org/stable/alloc/rc/struct.Weak.html#method.new) |
| 105 | +- [`sync::Weak::new`](https://doc.rust-lang.org/stable/alloc/sync/struct.Weak.html#method.new) |
| 106 | +- [`NonNull::as_ref`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.as_ref) |
| 107 | + |
| 108 | +### Other changes |
| 109 | + |
| 110 | +Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.73.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-173-2023-10-05), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-173). |
| 111 | + |
| 112 | +## Contributors to 1.73.0 |
| 113 | + |
| 114 | +Many people came together to create Rust 1.73.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.73.0/) |
0 commit comments