Exit arm scopes
Due to a bug in the HIR CFG construction, borrows for arm scopes were incorrectly leaking into other arms.
This PR also includes some drive-by improvements to `-Zunpretty=hir,identified` that would have been helpful while investigating this.
Closes#62107
Replace SliceConcatExt trait with inherent methods and SliceConcat helper trait
Before this change `SliceConcatExt` was an unstable extension trait with stable methods. It was in the libstd prelude, so that its methods could be used on the stable channel.
This replaces it with inherent methods, which can be used without any addition to the prelude. Since the methods are stable and very generic (with for example a return type that depends on the types of parameters), an helper trait is still needed. But now that trait does not need to be in scope for the methods to be used.
Removing this depedency on the libstd prelude allows the methods to be used in `#![no_std]` crate that use liballoc, which does not have its own implicitly-imported prelude.
Add key and value methods to DebugMap
Implementation PR for an active (not approved) RFC: https://github.com/rust-lang/rfcs/pull/2696.
Add two new methods to `std::fmt::DebugMap` for writing the key and value part of a map entry separately:
```rust
impl<'a, 'b: 'a> DebugMap<'a, 'b> {
pub fn key(&mut self, key: &dyn Debug) -> &mut Self;
pub fn value(&mut self, value: &dyn Debug) -> &mut Self;
}
```
I want to do this so that I can write a `serde::Serializer` that forwards to our format builders, so that any `T: Serialize` can also be treated like a `T: Debug`.
Prevent Vec::drain_filter from double dropping on panic
Fixes: #60977
The changes in this PR prevent leaking and double-panicking in addition to double-drop.
Tracking issue: #43244
Only call the closure parameter of Iterator::is_sorted_by_key once per item
See https://github.com/rust-lang/rust/issues/53485#issuecomment-472314004.
This changes `Iterator::is_sorted_by_key` to only call the given closure once for each item, which allows us to pass the items to the closure by value instead of by reference.
**Important**: `is_sorted_by_key` for slices and slice iterators is now no longer implemented in terms of the custom `slice::Iter::is_sorted_by` implementation. It's a trade-off: we could forward `slice::Iter::is_sorted_by_key` to it directly for potential SIMD benefits, but that would mean that the closure is potentially called twice for (almost) every element of the slice.
Rollup of 5 pull requests
Successful merges:
- #62356 (Implement Option::contains and Result::contains)
- #62462 (Document `while` keyword)
- #62472 (Normalize use of backticks in compiler messages p2)
- #62477 (Re-add bootstrap attribute to libunwind for llvm-libunwind feature)
- #62478 (normalize use of backticks for compiler messages in librustc_codegen)
Failed merges:
r? @ghost
Re-add bootstrap attribute to libunwind for llvm-libunwind feature
This was removed in 8a7dded, but since #62286 hasn't yet made it into
beta, this is breaking the build with llvm-libunwind feature enabled.
Furthemore, restrict the link attribute to Fuchsia and Linux, matching
the logic in build.rs since llvm-libunwind feature isn't yet supported
on other systems.
This was removed in 8a7dded, but since #62286 hasn't yet made it into
beta, this is breaking the build with llvm-libunwind feature enabled.
Furthemore, restrict the link attribute to Fuchsia and Linux, matching
the logic in build.rs since llvm-libunwind feature isn't yet supported
on other systems.
- uses a never-stable core::array::LengthAtMost32 to bound the impls
- includes a custom error message to avoid mentioning LengthAtMost32 too often
- doesn't use macros for the slice implementations to avoid #62433
Rollup of 4 pull requests
Successful merges:
- #61883 (`non_ascii_idents` lint (part of RFC 2457))
- #62042 (Support stability and deprecation checking for all macros)
- #62213 (rustdoc: set cfg(doctest) when collecting doctests)
- #62286 (Check if the archive has already been added to avoid duplicates)
Failed merges:
r? @ghost
Check if the archive has already been added to avoid duplicates
This avoids adding archives multiple times, which results in duplicate
objects in the resulting rlib, leading to symbol collision and link
failures. This could happen when crate contains multiple link attributes
that all reference the same archive.
rustdoc: set cfg(doctest) when collecting doctests
Note: This PR builds on top of https://github.com/rust-lang/rust/pull/61199; only the last commit is specific to this PR.
As discussed in https://github.com/rust-lang/rust/pull/61199, we want the ability to isolate items to only when rustdoc is collecting doctests, but we can't use `cfg(test)` because of libcore's `#![cfg(not(test))]`. This PR proposes a new cfg flag, `cfg(doctest)`, specific to this situation, rather than reusing an existing flag. I've isolated it behind a feature gate so that we can contain the effects to nightly only. (A stable workaround that can be used in lieu of `#[cfg(doctest)]` is `#[cfg(rustdoc)] #[doc(hidden)]`, at least once https://github.com/rust-lang/rust/pull/61351 lands.)
Tracking issue: https://github.com/rust-lang/rust/issues/62210
`non_ascii_idents` lint (part of RFC 2457)
RFC 2457 [declares](121bbeff50/text/2457-non-ascii-idents.md): "A `non_ascii_idents` lint is added to the compiler. This lint is allow by default."
(Part of #55467.)
r? @Manishearth