Skip to content

Commit 43998d5

Browse files
committed
Auto merge of rust-lang#95931 - matthiaskrgr:rollup-1c5zhit, r=matthiaskrgr
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
2 parents d00e770 + 5b8e2ea commit 43998d5

File tree

11 files changed

+157
-98
lines changed

11 files changed

+157
-98
lines changed

compiler/rustc_middle/src/ty/error.rs

+63-61
Large diffs are not rendered by default.

compiler/rustc_resolve/src/late/diagnostics.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1875,8 +1875,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
18751875
/// Returns whether to add `'static` lifetime to the suggested lifetime list.
18761876
crate fn report_elision_failure(
18771877
&mut self,
1878-
// FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
1879-
db: &mut Diagnostic,
1878+
diag: &mut Diagnostic,
18801879
params: &[ElisionFailureInfo],
18811880
) -> bool {
18821881
let mut m = String::new();
@@ -1891,7 +1890,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
18911890
let ElisionFailureInfo { parent, index, lifetime_count: n, have_bound_regions, span } =
18921891
info;
18931892

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

19251924
if len == 0 {
1926-
db.help(
1925+
diag.help(
19271926
"this function's return type contains a borrowed value, \
19281927
but there is no value for it to be borrowed from",
19291928
);
19301929
true
19311930
} else if elided_len == 0 {
1932-
db.help(
1931+
diag.help(
19331932
"this function's return type contains a borrowed value with \
19341933
an elided lifetime, but the lifetime cannot be derived from \
19351934
the arguments",
19361935
);
19371936
true
19381937
} else if elided_len == 1 {
1939-
db.help(&format!(
1938+
diag.help(&format!(
19401939
"this function's return type contains a borrowed value, \
19411940
but the signature does not say which {} it is borrowed from",
19421941
m
19431942
));
19441943
false
19451944
} else {
1946-
db.help(&format!(
1945+
diag.help(&format!(
19471946
"this function's return type contains a borrowed value, \
19481947
but the signature does not say whether it is borrowed from {}",
19491948
m

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
440440
}
441441
}
442442

443+
if Some(trait_ref.def_id()) == tcx.lang_items().drop_trait()
444+
&& predicate_is_const
445+
{
446+
err.note("`~const Drop` was renamed to `~const Destruct`");
447+
err.note("See <https://github.com/rust-lang/rust/pull/94901> for more details");
448+
}
449+
443450
let explanation = if let ObligationCauseCode::MainFunctionType =
444451
obligation.cause.code()
445452
{

library/alloc/src/collections/vec_deque/mod.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -2593,14 +2593,15 @@ impl<T, A: Allocator> VecDeque<T, A> {
25932593
/// ```
25942594
///
25952595
/// If you want to insert an item to a sorted deque, while maintaining
2596-
/// sort order:
2596+
/// sort order, consider using [`partition_point`]:
25972597
///
25982598
/// ```
25992599
/// use std::collections::VecDeque;
26002600
///
26012601
/// let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
26022602
/// let num = 42;
2603-
/// let idx = deque.binary_search(&num).unwrap_or_else(|x| x);
2603+
/// let idx = deque.partition_point(|&x| x < num);
2604+
/// // The above is equivalent to `let idx = deque.binary_search(&num).unwrap_or_else(|x| x);`
26042605
/// deque.insert(idx, num);
26052606
/// assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
26062607
/// ```
@@ -2744,6 +2745,19 @@ impl<T, A: Allocator> VecDeque<T, A> {
27442745
/// assert!(deque.iter().take(i).all(|&x| x < 5));
27452746
/// assert!(deque.iter().skip(i).all(|&x| !(x < 5)));
27462747
/// ```
2748+
///
2749+
/// If you want to insert an item to a sorted deque, while maintaining
2750+
/// sort order:
2751+
///
2752+
/// ```
2753+
/// use std::collections::VecDeque;
2754+
///
2755+
/// let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
2756+
/// let num = 42;
2757+
/// let idx = deque.partition_point(|&x| x < num);
2758+
/// deque.insert(idx, num);
2759+
/// assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
2760+
/// ```
27472761
#[stable(feature = "vecdeque_binary_search", since = "1.54.0")]
27482762
pub fn partition_point<P>(&self, mut pred: P) -> usize
27492763
where

library/alloc/tests/thin_box.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use alloc::boxed::ThinBox;
21
use core::mem::size_of;
2+
use std::boxed::ThinBox;
33

44
#[test]
55
fn want_niche_optimization() {

library/core/src/slice/mod.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -2331,12 +2331,13 @@ impl<T> [T] {
23312331
/// ```
23322332
///
23332333
/// If you want to insert an item to a sorted vector, while maintaining
2334-
/// sort order:
2334+
/// sort order, consider using [`partition_point`]:
23352335
///
23362336
/// ```
23372337
/// let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
23382338
/// let num = 42;
2339-
/// let idx = s.binary_search(&num).unwrap_or_else(|x| x);
2339+
/// let idx = s.partition_point(|&x| x < num);
2340+
/// // The above is equivalent to `let idx = s.binary_search(&num).unwrap_or_else(|x| x);`
23402341
/// s.insert(idx, num);
23412342
/// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
23422343
/// ```
@@ -3743,6 +3744,17 @@ impl<T> [T] {
37433744
/// assert!(v[..i].iter().all(|&x| x < 5));
37443745
/// assert!(v[i..].iter().all(|&x| !(x < 5)));
37453746
/// ```
3747+
///
3748+
/// If you want to insert an item to a sorted vector, while maintaining
3749+
/// sort order:
3750+
///
3751+
/// ```
3752+
/// let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
3753+
/// let num = 42;
3754+
/// let idx = s.partition_point(|&x| x < num);
3755+
/// s.insert(idx, num);
3756+
/// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
3757+
/// ```
37463758
#[stable(feature = "partition_point", since = "1.52.0")]
37473759
#[must_use]
37483760
pub fn partition_point<P>(&self, mut pred: P) -> usize

src/bootstrap/builder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,9 @@ impl<'a> Builder<'a> {
621621

622622
pub fn get_help(build: &Build, subcommand: &str) -> Option<String> {
623623
let kind = match subcommand {
624-
"build" => Kind::Build,
625-
"doc" => Kind::Doc,
626-
"test" => Kind::Test,
624+
"build" | "b" => Kind::Build,
625+
"doc" | "d" => Kind::Doc,
626+
"test" | "t" => Kind::Test,
627627
"bench" => Kind::Bench,
628628
"dist" => Kind::Dist,
629629
"install" => Kind::Install,

src/doc/rustc/src/linker-plugin-lto.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ able to get around this problem by setting `-Clinker=lld-link` in RUSTFLAGS
136136
```sh
137137
rustup toolchain install --profile minimal nightly
138138
MINOR_VERSION=$(rustc +nightly --version | cut -d . -f 2)
139-
LOWER_BOUND=44
139+
LOWER_BOUND=61
140140
141141
llvm_version() {
142142
toolchain="$1"
@@ -179,5 +179,19 @@ The following table shows known good combinations of toolchain versions.
179179
| Rust 1.44 | Clang 9 |
180180
| Rust 1.45 | Clang 10 |
181181
| Rust 1.46 | Clang 10 |
182+
| Rust 1.47 | Clang 11 |
183+
| Rust 1.48 | Clang 11 |
184+
| Rust 1.49 | Clang 11 |
185+
| Rust 1.50 | Clang 11 |
186+
| Rust 1.51 | Clang 11 |
187+
| Rust 1.52 | Clang 12 |
188+
| Rust 1.53 | Clang 12 |
189+
| Rust 1.54 | Clang 12 |
190+
| Rust 1.55 | Clang 12 |
191+
| Rust 1.56 | Clang 13 |
192+
| Rust 1.57 | Clang 13 |
193+
| Rust 1.58 | Clang 13 |
194+
| Rust 1.59 | Clang 13 |
195+
| Rust 1.60 | Clang 14 |
182196

183197
Note that the compatibility policy for this feature might change in the future.

src/doc/rustc/src/platform-support.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ All tier 1 targets with host tools support the full standard library.
3131
target | notes
3232
-------|-------
3333
`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.2, glibc 2.17+) [^missing-stack-probes]
34-
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+)
35-
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+)
34+
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+) [^windows-support]
35+
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+) [^windows-support]
3636
`i686-unknown-linux-gnu` | 32-bit Linux (kernel 2.6.32+, glibc 2.11+)
3737
`x86_64-apple-darwin` | 64-bit macOS (10.7+, Lion+)
38-
`x86_64-pc-windows-gnu` | 64-bit MinGW (Windows 7+)
39-
`x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+)
38+
`x86_64-pc-windows-gnu` | 64-bit MinGW (Windows 7+) [^windows-support]
39+
`x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+) [^windows-support]
4040
`x86_64-unknown-linux-gnu` | 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
4141

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

46+
[^windows-support]: Only Windows 10 currently undergoes automated testing. Earlier versions of Windows rely on testing and support from the community.
47+
4648
[77071]: https://github.com/rust-lang/rust/issues/77071
4749

4850
## Tier 1

src/librustdoc/clean/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -302,23 +302,13 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
302302

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

316-
#[cfg(bootstrap)]
317-
{
318-
// FIXME: remove `lang_items().drop_trait()` from above logic,
319-
// as well as the comment about `~const Drop` because it was renamed to `Destruct`.
320-
}
321-
322312
let poly_trait_ref = self.map_bound(|pred| pred.trait_ref);
323313
Some(WherePredicate::BoundPredicate {
324314
ty: poly_trait_ref.skip_binder().self_ty().clean(cx),

src/test/rustdoc/rfc-2632-const-trait-impl.rs

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test that we do not currently display `~const` in rustdoc
2-
// as that syntax is currently provisional; `~const Drop` has
2+
// as that syntax is currently provisional; `~const Destruct` has
33
// no effect on stable code so it should be hidden as well.
44
//
55
// To future blessers: make sure that `const_trait_impl` is
@@ -8,6 +8,8 @@
88
#![feature(const_trait_impl)]
99
#![crate_name = "foo"]
1010

11+
use std::marker::Destruct;
12+
1113
pub struct S<T>(T);
1214

1315
// @!has foo/trait.Tr.html '//pre[@class="rust trait"]/code/a[@class="trait"]' '~const'
@@ -20,22 +22,36 @@ pub trait Tr<T> {
2022
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
2123
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
2224
#[default_method_body_is_const]
23-
fn a<A: ~const Clone>() where Option<A>: ~const Clone {}
25+
fn a<A: ~const Clone + ~const Destruct>()
26+
where
27+
Option<A>: ~const Clone + ~const Destruct,
28+
{
29+
}
2430
}
2531

2632
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]' '~const'
2733
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Clone'
2834
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where"]' '~const'
2935
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' ': Clone'
30-
impl<T: ~const Clone> const Tr<T> for T where Option<T>: ~const Clone {
31-
fn a<A: ~const Clone>() where Option<A>: ~const Clone {}
36+
impl<T: ~const Clone + ~const Destruct> const Tr<T> for T
37+
where
38+
Option<T>: ~const Clone + ~const Destruct,
39+
{
40+
fn a<A: ~const Clone + ~const Destruct>()
41+
where
42+
Option<A>: ~const Clone + ~const Destruct,
43+
{
44+
}
3245
}
3346

3447
// @!has foo/fn.foo.html '//pre[@class="rust fn"]/code/a[@class="trait"]' '~const'
3548
// @has - '//pre[@class="rust fn"]/code/a[@class="trait"]' 'Clone'
3649
// @!has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' '~const'
3750
// @has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' ': Clone'
38-
pub const fn foo<F: ~const Clone>() where Option<F>: ~const Clone {
51+
pub const fn foo<F: ~const Clone + ~const Destruct>()
52+
where
53+
Option<F>: ~const Clone + ~const Destruct,
54+
{
3955
F::a()
4056
}
4157

@@ -44,7 +60,10 @@ impl<T> S<T> {
4460
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
4561
// @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const'
4662
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
47-
pub const fn foo<B: ~const Clone>() where B: ~const Clone {
63+
pub const fn foo<B: ~const Clone + ~const Destruct>()
64+
where
65+
B: ~const Clone + ~const Destruct,
66+
{
4867
B::a()
4968
}
5069
}

0 commit comments

Comments
 (0)