Opened 2 years ago
Closed 2 years ago
#20145 closed enhancement (fixed)
rustc-1.80.0
| Reported by: | Bruce Dubbs | Owned by: | Xi Ruoyao |
|---|---|---|---|
| Priority: | normal | Milestone: | 12.2 |
| Component: | BOOK | Version: | git |
| Severity: | medium | Keywords: | |
| Cc: |
Description
New minor version.
Change History (9)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Summary: | rustc-1.80,0 → rustc-1.80.0 |
follow-up: 4 comment:3 by , 2 years ago
For some reason running the test suite triggers a rebuild of the package. I'm investigating...
follow-up: 5 comment:4 by , 2 years ago
Replying to Xi Ruoyao:
For some reason running the test suite triggers a rebuild of the package. I'm investigating...
Dirty libc v0.2.155: the rustflags changed
Hmm need to compare the rustflags in testing and building phases.
comment:5 by , 2 years ago
Replying to Xi Ruoyao:
Replying to Xi Ruoyao:
For some reason running the test suite triggers a rebuild of the package. I'm investigating...
Dirty libc v0.2.155: the rustflags changedHmm need to compare the rustflags in testing and building phases.
One upstream developer suggested to just use --keep-stage-std 1 and I'm testing it.
comment:6 by , 2 years ago
And x.py install insists to rebuild cargo etc. for unknown reason even with --stage=1. I'll install them manually for now.
I hope they'll fix this in the next release (they do consider such "stupid rebuild" bugs but they don't consider them release blockers).
comment:7 by , 2 years ago
librsvg test is broken: https://github.com/rust-lang/rust/issues/127343#issuecomment-2218261296
comment:9 by , 2 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |

What's in 1.80.0 stable
LazyCellandLazyLockThese "lazy" types delay the initialization of their data until first access. They are similar to the
OnceCellandOnceLocktypes stabilized in 1.70, but with the initialization function included in the cell. This completes the stabilization of functionality adopted into the standard library from the popular lazy_static and once_cell crates.LazyLockis the thread-safe option, making it suitable for places likestaticvalues. For example, both thespawnthread and the mainscopewill see the exact same duration below, sinceLAZY_TIMEwill be initialized once, by whichever ends up accessing the static first. Neither use has to know *how* to initialize it, unlike they would withOnceLock::get_or_init().use std::sync::LazyLock; use std::time::Instant; static LAZY_TIME: LazyLock<Instant> = LazyLock::new(Instant::now); fn main() { let start = Instant::now(); std::thread::scope(|s| { s.spawn(|| { println!("Thread lazy time is {:?}", LAZY_TIME.duration_since(start)); }); println!("Main lazy time is {:?}", LAZY_TIME.duration_since(start)); }); }LazyCelldoes the same thing without thread synchronization, so it doesn't implementSync, which is needed forstatic, but it can still be used inthread_local!statics (with distinct initialization per thread). Either type can also be used in other data structures as well, depending on thread-safety needs, so lazy initialization is available everywhere!Checked
cfgnames and valuesIn 1.79,
rustcstabilized a --check-cfg flag, and now Cargo 1.80 is enabling those checks for allcfgnames and values that it knows (in addition to the well known names and values fromrustc). This includes feature names fromCargo.tomlas well as newcargo::rustc-check-cfgoutput from build scripts.Unexpected cfgs are reported by the warn-by-default
unexpected_cfgslint, which is meant to catch typos or other misconfiguration. For example, in a project with an optionalrayondependency, this code is configured for the wrongfeaturevalue:fn main() { println!("Hello, world!"); #[cfg(feature = "crayon")] rayon::join( || println!("Hello, Thing One!"), || println!("Hello, Thing Two!"), ); }The same warning is reported regardless of whether the actual
rayonfeature is enabled or not.The
[lints]table in theCargo.tomlmanifest can also be used to extend the list of known names and values for customcfg.rustcautomatically provides the syntax to use in the warning.[lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }You can read more about this feature in a previous blog post announcing the availability of the feature on nightly.
Exclusive ranges in patterns
Rust ranged patterns can now use exclusive endpoints, written
a..bor..bsimilar to theRangeandRangeToexpression types. For example, the following patterns can now use the same constants for the end of one pattern and the start of the next:pub fn size_prefix(n: u32) -> &'static str { const K: u32 = 10u32.pow(3); const M: u32 = 10u32.pow(6); const G: u32 = 10u32.pow(9); match n { ..K => "", K..M => "k", M..G => "M", G.. => "G", } }Previously, only inclusive (
a..=bor..=b) or open (a..) ranges were allowed in patterns, so code like this would require separate constants for inclusive endpoints likeK - 1.Exclusive ranges have been implemented as an unstable feature for a long time, but the blocking concern was that they might add confusion and increase the chance of off-by-one errors in patterns. To that end, exhaustiveness checking has been enhanced to better detect gaps in pattern matching, and new lints
non_contiguous_range_endpointsandoverlapping_range_endpointswill help detect cases where you might want to switch exclusive patterns to inclusive, or vice versa.Stabilized APIs
impl Default for Rc<CStr>(https://doc.rust-lang.org/stable/alloc/rc/struct.Rc.html#impl-Default-for-Rc%3CCStr%3E)impl Default for Rc<str>(https://doc.rust-lang.org/stable/alloc/rc/struct.Rc.html#impl-Default-for-Rc%3Cstr%3E)impl Default for Rc<[T]>(https://doc.rust-lang.org/stable/alloc/rc/struct.Rc.html#impl-Default-for-Rc%3C%5BT%5D%3E)impl Default for Arc<str>(https://doc.rust-lang.org/stable/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3Cstr%3E)impl Default for Arc<CStr>(https://doc.rust-lang.org/stable/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3CCStr%3E)impl Default for Arc<[T]>(https://doc.rust-lang.org/stable/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3C%5BT%5D%3E)impl IntoIterator for Box<[T]>(https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html#impl-IntoIterator-for-Box%3C%5BI%5D,+A%3E)impl FromIterator<String> for Box<str>(https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html#impl-FromIterator%3CString%3E-for-Box%3Cstr%3E)impl FromIterator<char> for Box<str>(https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html#impl-FromIterator%3Cchar%3E-for-Box%3Cstr%3E)LazyCell(https://doc.rust-lang.org/stable/core/cell/struct.LazyCell.html)LazyLock(https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html)Duration::div_duration_f32(https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f32)Duration::div_duration_f64(https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f64)Option::take_if(https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.take_if)Seek::seek_relative(https://doc.rust-lang.org/stable/std/io/trait.Seek.html#method.seek_relative)BinaryHeap::as_slice(https://doc.rust-lang.org/stable/std/collections/struct.BinaryHeap.html#method.as_slice)NonNull::offset(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.offset)NonNull::byte_offset(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.byte_offset)NonNull::add(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.add)NonNull::byte_add(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.byte_add)NonNull::sub(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.sub)NonNull::byte_sub(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.byte_sub)NonNull::offset_from(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.offset_from)NonNull::byte_offset_from(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.byte_offset_from)NonNull::read(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.read)NonNull::read_volatile(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.read_volatile)NonNull::read_unaligned(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.read_unaligned)NonNull::write(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.write)NonNull::write_volatile(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.write_volatile)NonNull::write_unaligned(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.write_unaligned)NonNull::write_bytes(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.write_bytes)NonNull::copy_to(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.copy_to)NonNull::copy_to_nonoverlapping(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.copy_to_nonoverlapping)NonNull::copy_from(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.copy_from)NonNull::copy_from_nonoverlapping(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.copy_from_nonoverlapping)NonNull::replace(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.replace)NonNull::swap(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.swap)NonNull::drop_in_place(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.drop_in_place)NonNull::align_offset(https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.align_offset)<[T]>::split_at_checked(https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_at_checked)<[T]>::split_at_mut_checked(https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_at_mut_checked)str::split_at_checked(https://doc.rust-lang.org/stable/std/primitive.str.html#method.split_at_checked)str::split_at_mut_checked(https://doc.rust-lang.org/stable/std/primitive.str.html#method.split_at_mut_checked)str::trim_ascii(https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_ascii)str::trim_ascii_start(https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_ascii_start)str::trim_ascii_end(https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_ascii_end)<[u8]>::trim_ascii(https://doc.rust-lang.org/stable/core/primitive.slice.html#method.trim_ascii)<[u8]>::trim_ascii_start(https://doc.rust-lang.org/stable/core/primitive.slice.html#method.trim_ascii_start)<[u8]>::trim_ascii_end(https://doc.rust-lang.org/stable/core/primitive.slice.html#method.trim_ascii_end)Ipv4Addr::BITS(https://doc.rust-lang.org/stable/core/net/struct.Ipv4Addr.html#associatedconstant.BITS)Ipv4Addr::to_bits(https://doc.rust-lang.org/stable/core/net/struct.Ipv4Addr.html#method.to_bits)Ipv4Addr::from_bits(https://doc.rust-lang.org/stable/core/net/struct.Ipv4Addr.html#method.from_bits)Ipv6Addr::BITS(https://doc.rust-lang.org/stable/core/net/struct.Ipv6Addr.html#associatedconstant.BITS)Ipv6Addr::to_bits(https://doc.rust-lang.org/stable/core/net/struct.Ipv6Addr.html#method.to_bits)Ipv6Addr::from_bits(https://doc.rust-lang.org/stable/core/net/struct.Ipv6Addr.html#method.from_bits)Vec::<[T; N]>::into_flattened(https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html#method.into_flattened)<[[T; N]]>::as_flattened(https://doc.rust-lang.org/stable/core/primitive.slice.html#method.as_flattened)<[[T; N]]>::as_flattened_mut(https://doc.rust-lang.org/stable/core/primitive.slice.html#method.as_flattened_mut)These APIs are now stable in const contexts:
<[T]>::last_chunk(https://doc.rust-lang.org/stable/core/primitive.slice.html#method.last_chunk)BinaryHeap::new(https://doc.rust-lang.org/stable/std/collections/struct.BinaryHeap.html#method.new)Other changes
Check out everything that changed in Rust, Cargo, and Clippy.
Contributors to 1.80.0
Many people came together to create Rust 1.80.0. We couldn't have done it without all of you. Thanks!