|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Announcing Rust 1.63.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.63.0. Rust is a programming language |
| 9 | +empowering everyone to build reliable and efficient software. |
| 10 | + |
| 11 | +If you have a previous version of Rust installed via rustup, you can get 1.63.0 with: |
| 12 | + |
| 13 | +```console |
| 14 | +rustup update stable |
| 15 | +``` |
| 16 | + |
| 17 | +If you don't have it already, you can [get `rustup`][install] |
| 18 | +from the appropriate page on our website, and check out the |
| 19 | +[detailed release notes for 1.63.0][notes] on GitHub. |
| 20 | + |
| 21 | +If you'd like to help us out by testing future releases, you might consider updating locally to use |
| 22 | +the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`). |
| 23 | +Please [report] any bugs you might come across! |
| 24 | + |
| 25 | +[install]: https://www.rust-lang.org/install.html |
| 26 | +[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1620-2022-06-30 |
| 27 | +[report]: https://github.com/rust-lang/rust/issues/new/choose |
| 28 | + |
| 29 | +## What's in 1.63.0 stable |
| 30 | + |
| 31 | +### Rust ownership for raw file descriptors/handles (I/O Safety) |
| 32 | + |
| 33 | +Previously, Rust code working with platform APIs taking raw file descriptors (on |
| 34 | +unix-style platforms) or handles (on Windows) would typically work directly with |
| 35 | +a platform-specific representation of the descriptor (for example, a `c_int`). |
| 36 | +For Rust bindings to such native APIs, the type system then failed to encode |
| 37 | +whether the API would take ownership of the file descriptor (e.g., `close`) or |
| 38 | +merely borrow it (e.g., `dup`). |
| 39 | + |
| 40 | +Now, Rust provides wrapper types such as [`BorrowedFd`], which are marked as |
| 41 | +`#[repr(transparent)]`, meaning that `extern "C"` bindings can directly take |
| 42 | +these types to encode the ownership semantics. See the stabilized APIs section |
| 43 | +for the full list of wrapper types stabilized in 1.63, currently, they are |
| 44 | +available on cfg(unix) platforms, Windows, and WASI. |
| 45 | + |
| 46 | +We recommend that new APIs use these types instead of the previous type aliases |
| 47 | +(like [`RawFd`]). |
| 48 | + |
| 49 | +[`RawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/type.RawFd.html |
| 50 | +[`BorrowedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html |
| 51 | + |
| 52 | +### Turbofish for generics in functions with `impl Trait` |
| 53 | + |
| 54 | +The turbofish notation (`foo::<u32>()`) can be used to specify the types for explicit type |
| 55 | +parameters (`fn foo<T: Copy>`) even when `impl Trait` is used in the argument types. |
| 56 | +Specifying the type of an `impl Trait` argument via turbofish is still not possible. |
| 57 | + |
| 58 | +### Non-lexical lifetimes migration complete |
| 59 | + |
| 60 | +As detailed in [this blog post], we've fully removed the previous lexical borrow checker |
| 61 | +from rustc across all editions, fully enabling the non-lexical, new, version of the borrow |
| 62 | +checker. Since the borrow checker doesn't affect the output of rustc, this won't change |
| 63 | +the behavior of any programs, but it completes a long-running migration (started in the |
| 64 | +initial stabilization of NLL for the 2018 edition) to deliver the full benefits of the new |
| 65 | +borrow checker across all editions of Rust. For most users, this change will bring |
| 66 | +slightly better diagnostics for some borrow checking errors, but will not otherwise impact |
| 67 | +which code they can write. |
| 68 | + |
| 69 | +You can read more about non-lexical lifetimes in [this section of the 2018 edition announcement][nll]. |
| 70 | + |
| 71 | +[this blog post]: https://github.com/rust-lang/blog.rust-lang.org/pull/989 |
| 72 | +[nll]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html#non-lexical-lifetimes |
| 73 | + |
| 74 | +### Stabilized APIs |
| 75 | + |
| 76 | +The following methods and trait implementations are now stabilized: |
| 77 | + |
| 78 | +- [`array::from_fn`] |
| 79 | +- [`Box::into_pin`] |
| 80 | +- [`BinaryHeap::try_reserve_exact`] |
| 81 | +- [`BinaryHeap::try_reserve`] |
| 82 | +- [`OsString::try_reserve`] |
| 83 | +- [`OsString::try_reserve_exact`] |
| 84 | +- [`PathBuf::try_reserve`] |
| 85 | +- [`PathBuf::try_reserve_exact`] |
| 86 | +- [`Path::try_exists`] |
| 87 | +- [`Ref::filter_map`] |
| 88 | +- [`RefMut::filter_map`] |
| 89 | +- [`NonNull::<[T]>::len`] |
| 90 | +- [`ToOwned::clone_into`] |
| 91 | +- [`Ipv6Addr::to_ipv4_mapped`] |
| 92 | +- [`unix::io::AsFd`] |
| 93 | +- [`unix::io::BorrowedFd<'fd>`] |
| 94 | +- [`unix::io::OwnedFd`] |
| 95 | +- [`windows::io::AsHandle`] |
| 96 | +- [`windows::io::BorrowedHandle<'handle>`] |
| 97 | +- [`windows::io::OwnedHandle`] |
| 98 | +- [`windows::io::HandleOrInvalid`] |
| 99 | +- [`windows::io::HandleOrNull`] |
| 100 | +- [`windows::io::InvalidHandleError`] |
| 101 | +- [`windows::io::NullHandleError`] |
| 102 | +- [`windows::io::AsSocket`] |
| 103 | +- [`windows::io::BorrowedSocket<'handle>`] |
| 104 | +- [`windows::io::OwnedSocket`] |
| 105 | +- [`thread::scope`] |
| 106 | +- [`thread::Scope`] |
| 107 | +- [`thread::ScopedJoinHandle`] |
| 108 | + |
| 109 | +These APIs are now usable in const contexts: |
| 110 | + |
| 111 | +- [`array::from_ref`] |
| 112 | +- [`slice::from_ref`] |
| 113 | +- [`intrinsics::copy`] |
| 114 | +- [`intrinsics::copy_nonoverlapping`] |
| 115 | +- [`<*const T>::copy_to`] |
| 116 | +- [`<*const T>::copy_to_nonoverlapping`] |
| 117 | +- [`<*mut T>::copy_to`] |
| 118 | +- [`<*mut T>::copy_to_nonoverlapping`] |
| 119 | +- [`<*mut T>::copy_from`] |
| 120 | +- [`<*mut T>::copy_from_nonoverlapping`] |
| 121 | +- [`str::from_utf8`] |
| 122 | +- [`Utf8Error::error_len`] |
| 123 | +- [`Utf8Error::valid_up_to`] |
| 124 | +- [`Condvar::new`] |
| 125 | +- [`Mutex::new`] |
| 126 | +- [`RwLock::new`] |
| 127 | + |
| 128 | +(Links for stabilized APIs are a todo, waiting on release notes to have them.) |
| 129 | + |
| 130 | +### Other changes |
| 131 | + |
| 132 | +There are other changes in the Rust 1.63.0 release. Check out what changed in |
| 133 | +[Rust](https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1630-2022-08-11), |
| 134 | +[Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-163-2022-08-11), |
| 135 | +and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-163). |
| 136 | + |
| 137 | +### Contributors to 1.63.0 |
| 138 | + |
| 139 | +Many people came together to create Rust 1.63.0. |
| 140 | +We couldn't have done it without all of you. |
| 141 | +[Thanks!](https://thanks.rust-lang.org/rust/1.63.0/) |
| 142 | + |
0 commit comments