Skip to content

Commit

Permalink
Auto merge of rust-lang#95931 - matthiaskrgr:rollup-1c5zhit, r=matthi…
Browse files Browse the repository at this point in the history
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#95743 (Update binary_search example to instead redirect to partition_point)
 - rust-lang#95771 (Update linker-plugin-lto.md to 1.60)
 - rust-lang#95861 (Note that CI tests Windows 10)
 - rust-lang#95875 (bootstrap: show available paths help text for aliased subcommands)
 - rust-lang#95876 (Add a note for unsatisfied `~const Drop` bounds)
 - rust-lang#95907 (address fixme for diagnostic variable name)
 - rust-lang#95917 (thin_box test: import from std, not alloc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 11, 2022
2 parents d00e770 + 5b8e2ea commit 43998d5
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 98 deletions.
124 changes: 63 additions & 61 deletions compiler/rustc_middle/src/ty/error.rs

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
/// Returns whether to add `'static` lifetime to the suggested lifetime list.
crate fn report_elision_failure(
&mut self,
// FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
db: &mut Diagnostic,
diag: &mut Diagnostic,
params: &[ElisionFailureInfo],
) -> bool {
let mut m = String::new();
Expand All @@ -1891,7 +1890,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
let ElisionFailureInfo { parent, index, lifetime_count: n, have_bound_regions, span } =
info;

db.span_label(span, "");
diag.span_label(span, "");
let help_name = if let Some(ident) =
parent.and_then(|body| self.tcx.hir().body(body).params[index].pat.simple_ident())
{
Expand Down Expand Up @@ -1923,27 +1922,27 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}

if len == 0 {
db.help(
diag.help(
"this function's return type contains a borrowed value, \
but there is no value for it to be borrowed from",
);
true
} else if elided_len == 0 {
db.help(
diag.help(
"this function's return type contains a borrowed value with \
an elided lifetime, but the lifetime cannot be derived from \
the arguments",
);
true
} else if elided_len == 1 {
db.help(&format!(
diag.help(&format!(
"this function's return type contains a borrowed value, \
but the signature does not say which {} it is borrowed from",
m
));
false
} else {
db.help(&format!(
diag.help(&format!(
"this function's return type contains a borrowed value, \
but the signature does not say whether it is borrowed from {}",
m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
}
}

if Some(trait_ref.def_id()) == tcx.lang_items().drop_trait()
&& predicate_is_const
{
err.note("`~const Drop` was renamed to `~const Destruct`");
err.note("See <https://github.com/rust-lang/rust/pull/94901> for more details");
}

let explanation = if let ObligationCauseCode::MainFunctionType =
obligation.cause.code()
{
Expand Down
18 changes: 16 additions & 2 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2593,14 +2593,15 @@ impl<T, A: Allocator> VecDeque<T, A> {
/// ```
///
/// If you want to insert an item to a sorted deque, while maintaining
/// sort order:
/// sort order, consider using [`partition_point`]:
///
/// ```
/// use std::collections::VecDeque;
///
/// let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
/// let num = 42;
/// let idx = deque.binary_search(&num).unwrap_or_else(|x| x);
/// let idx = deque.partition_point(|&x| x < num);
/// // The above is equivalent to `let idx = deque.binary_search(&num).unwrap_or_else(|x| x);`
/// deque.insert(idx, num);
/// assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
/// ```
Expand Down Expand Up @@ -2744,6 +2745,19 @@ impl<T, A: Allocator> VecDeque<T, A> {
/// assert!(deque.iter().take(i).all(|&x| x < 5));
/// assert!(deque.iter().skip(i).all(|&x| !(x < 5)));
/// ```
///
/// If you want to insert an item to a sorted deque, while maintaining
/// sort order:
///
/// ```
/// use std::collections::VecDeque;
///
/// let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
/// let num = 42;
/// let idx = deque.partition_point(|&x| x < num);
/// deque.insert(idx, num);
/// assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
/// ```
#[stable(feature = "vecdeque_binary_search", since = "1.54.0")]
pub fn partition_point<P>(&self, mut pred: P) -> usize
where
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/tests/thin_box.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloc::boxed::ThinBox;
use core::mem::size_of;
use std::boxed::ThinBox;

#[test]
fn want_niche_optimization() {
Expand Down
16 changes: 14 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2331,12 +2331,13 @@ impl<T> [T] {
/// ```
///
/// If you want to insert an item to a sorted vector, while maintaining
/// sort order:
/// sort order, consider using [`partition_point`]:
///
/// ```
/// let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
/// let num = 42;
/// let idx = s.binary_search(&num).unwrap_or_else(|x| x);
/// let idx = s.partition_point(|&x| x < num);
/// // The above is equivalent to `let idx = s.binary_search(&num).unwrap_or_else(|x| x);`
/// s.insert(idx, num);
/// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
/// ```
Expand Down Expand Up @@ -3743,6 +3744,17 @@ impl<T> [T] {
/// assert!(v[..i].iter().all(|&x| x < 5));
/// assert!(v[i..].iter().all(|&x| !(x < 5)));
/// ```
///
/// If you want to insert an item to a sorted vector, while maintaining
/// sort order:
///
/// ```
/// let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
/// let num = 42;
/// let idx = s.partition_point(|&x| x < num);
/// s.insert(idx, num);
/// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
/// ```
#[stable(feature = "partition_point", since = "1.52.0")]
#[must_use]
pub fn partition_point<P>(&self, mut pred: P) -> usize
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ impl<'a> Builder<'a> {

pub fn get_help(build: &Build, subcommand: &str) -> Option<String> {
let kind = match subcommand {
"build" => Kind::Build,
"doc" => Kind::Doc,
"test" => Kind::Test,
"build" | "b" => Kind::Build,
"doc" | "d" => Kind::Doc,
"test" | "t" => Kind::Test,
"bench" => Kind::Bench,
"dist" => Kind::Dist,
"install" => Kind::Install,
Expand Down
16 changes: 15 additions & 1 deletion src/doc/rustc/src/linker-plugin-lto.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ able to get around this problem by setting `-Clinker=lld-link` in RUSTFLAGS
```sh
rustup toolchain install --profile minimal nightly
MINOR_VERSION=$(rustc +nightly --version | cut -d . -f 2)
LOWER_BOUND=44
LOWER_BOUND=61
llvm_version() {
toolchain="$1"
Expand Down Expand Up @@ -179,5 +179,19 @@ The following table shows known good combinations of toolchain versions.
| Rust 1.44 | Clang 9 |
| Rust 1.45 | Clang 10 |
| Rust 1.46 | Clang 10 |
| Rust 1.47 | Clang 11 |
| Rust 1.48 | Clang 11 |
| Rust 1.49 | Clang 11 |
| Rust 1.50 | Clang 11 |
| Rust 1.51 | Clang 11 |
| Rust 1.52 | Clang 12 |
| Rust 1.53 | Clang 12 |
| Rust 1.54 | Clang 12 |
| Rust 1.55 | Clang 12 |
| Rust 1.56 | Clang 13 |
| Rust 1.57 | Clang 13 |
| Rust 1.58 | Clang 13 |
| Rust 1.59 | Clang 13 |
| Rust 1.60 | Clang 14 |

Note that the compatibility policy for this feature might change in the future.
10 changes: 6 additions & 4 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ All tier 1 targets with host tools support the full standard library.
target | notes
-------|-------
`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.2, glibc 2.17+) [^missing-stack-probes]
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+)
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+)
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+) [^windows-support]
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+) [^windows-support]
`i686-unknown-linux-gnu` | 32-bit Linux (kernel 2.6.32+, glibc 2.11+)
`x86_64-apple-darwin` | 64-bit macOS (10.7+, Lion+)
`x86_64-pc-windows-gnu` | 64-bit MinGW (Windows 7+)
`x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+)
`x86_64-pc-windows-gnu` | 64-bit MinGW (Windows 7+) [^windows-support]
`x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+) [^windows-support]
`x86_64-unknown-linux-gnu` | 64-bit Linux (kernel 2.6.32+, glibc 2.11+)

[^missing-stack-probes]: Stack probes support is missing on
`aarch64-unknown-linux-gnu`, but it's planned to be implemented in the near
future. The implementation is tracked on [issue #77071][77071].

[^windows-support]: Only Windows 10 currently undergoes automated testing. Earlier versions of Windows rely on testing and support from the community.

[77071]: https://github.com/rust-lang/rust/issues/77071

## Tier 1
Expand Down
12 changes: 1 addition & 11 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,13 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {

impl<'a> Clean<Option<WherePredicate>> for ty::PolyTraitPredicate<'a> {
fn clean(&self, cx: &mut DocContext<'_>) -> Option<WherePredicate> {
// `T: ~const Drop` is not equivalent to `T: Drop`, and we don't currently document `~const` bounds
// because of its experimental status, so just don't show these.
// `T: ~const Destruct` is hidden because `T: Destruct` is a no-op.
if self.skip_binder().constness == ty::BoundConstness::ConstIfConst
&& [cx.tcx.lang_items().drop_trait(), cx.tcx.lang_items().destruct_trait()]
.iter()
.any(|tr| *tr == Some(self.skip_binder().def_id()))
&& Some(self.skip_binder().def_id()) == cx.tcx.lang_items().destruct_trait()
{
return None;
}

#[cfg(bootstrap)]
{
// FIXME: remove `lang_items().drop_trait()` from above logic,
// as well as the comment about `~const Drop` because it was renamed to `Destruct`.
}

let poly_trait_ref = self.map_bound(|pred| pred.trait_ref);
Some(WherePredicate::BoundPredicate {
ty: poly_trait_ref.skip_binder().self_ty().clean(cx),
Expand Down
31 changes: 25 additions & 6 deletions src/test/rustdoc/rfc-2632-const-trait-impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Test that we do not currently display `~const` in rustdoc
// as that syntax is currently provisional; `~const Drop` has
// as that syntax is currently provisional; `~const Destruct` has
// no effect on stable code so it should be hidden as well.
//
// To future blessers: make sure that `const_trait_impl` is
Expand All @@ -8,6 +8,8 @@
#![feature(const_trait_impl)]
#![crate_name = "foo"]

use std::marker::Destruct;

pub struct S<T>(T);

// @!has foo/trait.Tr.html '//pre[@class="rust trait"]/code/a[@class="trait"]' '~const'
Expand All @@ -20,22 +22,36 @@ pub trait Tr<T> {
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
#[default_method_body_is_const]
fn a<A: ~const Clone>() where Option<A>: ~const Clone {}
fn a<A: ~const Clone + ~const Destruct>()
where
Option<A>: ~const Clone + ~const Destruct,
{
}
}

// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Clone'
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' ': Clone'
impl<T: ~const Clone> const Tr<T> for T where Option<T>: ~const Clone {
fn a<A: ~const Clone>() where Option<A>: ~const Clone {}
impl<T: ~const Clone + ~const Destruct> const Tr<T> for T
where
Option<T>: ~const Clone + ~const Destruct,
{
fn a<A: ~const Clone + ~const Destruct>()
where
Option<A>: ~const Clone + ~const Destruct,
{
}
}

// @!has foo/fn.foo.html '//pre[@class="rust fn"]/code/a[@class="trait"]' '~const'
// @has - '//pre[@class="rust fn"]/code/a[@class="trait"]' 'Clone'
// @!has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' '~const'
// @has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' ': Clone'
pub const fn foo<F: ~const Clone>() where Option<F>: ~const Clone {
pub const fn foo<F: ~const Clone + ~const Destruct>()
where
Option<F>: ~const Clone + ~const Destruct,
{
F::a()
}

Expand All @@ -44,7 +60,10 @@ impl<T> S<T> {
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
// @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const'
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
pub const fn foo<B: ~const Clone>() where B: ~const Clone {
pub const fn foo<B: ~const Clone + ~const Destruct>()
where
B: ~const Clone + ~const Destruct,
{
B::a()
}
}

0 comments on commit 43998d5

Please sign in to comment.