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
name the trait in ambiguous-associated-items fully qualified suggestion
We have the trait at this point, so we can name it in the error message, rather than using "Trait" as a (potentially confusing) placeholder.
Thanks to Yuki "@JohnTitor" Okushi for pointing out where to look (in the same file) for a closely related issue for ambiguous associated types (as opposed to items; that was #59225, except that one won't be
quite as easy to resolve, because we actually don't have the trait `DefId` at that point).
r? @petrochenkov
rustbuild: Cleanup global lint settings
Lint settings do not depend on `if let Some(target) = target` in any way, so they are moved out of that clause.
Internal lints now respect `RUSTC_DENY_WARNINGS`.
Crate name treatment is cleaned up a bit.
cc https://github.com/rust-lang/rust/pull/61545 @flip1995
r? @Mark-Simulacrum
First question mark in doctest
We have had `?` for `Result`s in doctests for some time, but so far haven't used them in doctests. With this PR, I want to start the de-`unwrap`ping of doctests – and the discussion on where to do so.
There is one downside, which is that the code can no longer be copied into a plain `main()` method, on the other hand, there should be a workable error if one does this.
Now that procedural macros no longer link transitively to libsyntax,
this shouldn't be needed any more! This commit is an experiment in
removing all dynamic libraries from rustc except for librustc_driver
itself. Let's see how far we can get with that!