Skip to content

Commit 7850c28

Browse files
committed
Auto merge of #81578 - jonas-schievink:rollup-yhiyowl, r=jonas-schievink
Rollup of 18 pull requests Successful merges: - #78044 (Implement io::Seek for io::Empty) - #79285 (Stabilize Arc::{increment,decrement}_strong_count) - #80053 (stabilise `cargo test -- --include-ignored`) - #80279 (Implement missing `AsMut<str>` for `str`) - #80470 (Stabilize by-value `[T; N]` iterator `core::array::IntoIter`) - #80945 (Add Box::downcast() for dyn Any + Send + Sync) - #81048 (Stabilize `core::slice::fill_with`) - #81198 (Remove requirement that forces symmetric and transitive PartialEq impls to exist) - #81422 (Account for existing `_` field pattern when suggesting `..`) - #81472 (Clone entire `TokenCursor` when collecting tokens) - #81484 (Optimize decimal formatting of 128-bit integers) - #81491 (Balance sidebar `Deref` cycle check with main content) - #81509 (Add a regression test for ICE of bad_placeholder_type) - #81547 (Edit rustc_typeck top-level docs) - #81550 (Replace predecessor with range in collections documentation) - #81558 (Fix ascii art text wrapping in mobile) - #81562 (Clarify that InPlaceIterable guarantees extend to all advancing iterator methods.) - #81563 (Improve docblock readability on small screen) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b3897e3 + 8b281d9 commit 7850c28

File tree

35 files changed

+284
-118
lines changed

35 files changed

+284
-118
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1212
test(no_crate_inject, attr(deny(warnings)))
1313
)]
14-
#![feature(array_value_iter_slice)]
1514
#![feature(dropck_eyepatch)]
1615
#![feature(new_uninit)]
1716
#![feature(maybe_uninit_slice)]
18-
#![feature(array_value_iter)]
1917
#![cfg_attr(bootstrap, feature(min_const_generics))]
2018
#![feature(min_specialization)]
2119
#![cfg_attr(test, feature(test))]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
//! get confused if the spans from leaf AST nodes occur in multiple places
3131
//! in the HIR, especially for multiple identifiers.
3232
33-
#![feature(array_value_iter)]
3433
#![feature(crate_visibility_modifier)]
3534
#![feature(or_patterns)]
3635
#![recursion_limit = "256"]

compiler/rustc_hir/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
44
5-
#![feature(array_value_iter)]
65
#![feature(crate_visibility_modifier)]
76
#![feature(const_fn)] // For the unsizing cast on `&[]`
87
#![feature(const_panic)]

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,15 +1254,7 @@ impl<'a> Parser<'a> {
12541254
f: impl FnOnce(&mut Self) -> PResult<'a, (R, TrailingToken)>,
12551255
) -> PResult<'a, R> {
12561256
let start_token = (self.token.clone(), self.token_spacing);
1257-
let cursor_snapshot = TokenCursor {
1258-
frame: self.token_cursor.frame.clone(),
1259-
// We only ever capture tokens within our current frame,
1260-
// so we can just use an empty frame stack
1261-
stack: vec![],
1262-
desugar_doc_comments: self.token_cursor.desugar_doc_comments,
1263-
num_next_calls: self.token_cursor.num_next_calls,
1264-
append_unglued_token: self.token_cursor.append_unglued_token.clone(),
1265-
};
1257+
let cursor_snapshot = self.token_cursor.clone();
12661258

12671259
let (mut ret, trailing_token) = f(self)?;
12681260

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! This API is completely unstable and subject to change.
1212
1313
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
14-
#![feature(array_value_iter)]
1514
#![feature(bool_to_option)]
1615
#![feature(box_patterns)]
1716
#![feature(drain_filter)]

compiler/rustc_typeck/src/check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ The types of top-level items, which never contain unbound type
5252
variables, are stored directly into the `tcx` typeck_results.
5353
5454
N.B., a type variable is not the same thing as a type parameter. A
55-
type variable is rather an "instance" of a type parameter: that is,
56-
given a generic function `fn foo<T>(t: T)`: while checking the
55+
type variable is an instance of a type parameter. That is,
56+
given a generic function `fn foo<T>(t: T)`, while checking the
5757
function `foo`, the type `ty_param(0)` refers to the type `T`, which
58-
is treated in abstract. When `foo()` is called, however, `T` will be
58+
is treated in abstract. However, when `foo()` is called, `T` will be
5959
substituted for a fresh type variable `N`. This variable will
6060
eventually be resolved to some concrete type (which might itself be
61-
type parameter).
61+
a type parameter).
6262
6363
*/
6464

compiler/rustc_typeck/src/check/pat.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,12 +1041,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10411041
vec![(left, "(".to_string()), (right.shrink_to_hi(), ")".to_string())],
10421042
Applicability::MachineApplicable,
10431043
);
1044-
} else if fields.len() > subpats.len() {
1045-
let after_fields_span = if pat_span == DUMMY_SP {
1046-
pat_span
1047-
} else {
1048-
pat_span.with_hi(pat_span.hi() - BytePos(1)).shrink_to_hi()
1049-
};
1044+
} else if fields.len() > subpats.len() && pat_span != DUMMY_SP {
1045+
let after_fields_span = pat_span.with_hi(pat_span.hi() - BytePos(1)).shrink_to_hi();
10501046
let all_fields_span = match subpats {
10511047
[] => after_fields_span,
10521048
[field] => field.span,
@@ -1055,7 +1051,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10551051

10561052
// Check if all the fields in the pattern are wildcards.
10571053
let all_wildcards = subpats.iter().all(|pat| matches!(pat.kind, PatKind::Wild));
1054+
let first_tail_wildcard =
1055+
subpats.iter().enumerate().fold(None, |acc, (pos, pat)| match (acc, &pat.kind) {
1056+
(None, PatKind::Wild) => Some(pos),
1057+
(Some(_), PatKind::Wild) => acc,
1058+
_ => None,
1059+
});
1060+
let tail_span = match first_tail_wildcard {
1061+
None => after_fields_span,
1062+
Some(0) => subpats[0].span.to(after_fields_span),
1063+
Some(pos) => subpats[pos - 1].span.shrink_to_hi().to(after_fields_span),
1064+
};
10581065

1066+
// FIXME: heuristic-based suggestion to check current types for where to add `_`.
10591067
let mut wildcard_sugg = vec!["_"; fields.len() - subpats.len()].join(", ");
10601068
if !subpats.is_empty() {
10611069
wildcard_sugg = String::from(", ") + &wildcard_sugg;
@@ -1080,7 +1088,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10801088
);
10811089
} else {
10821090
err.span_suggestion_verbose(
1083-
after_fields_span,
1091+
tail_span,
10841092
"use `..` to ignore the rest of the fields",
10851093
String::from(", .."),
10861094
Applicability::MaybeIncorrect,

compiler/rustc_typeck/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ The type checker is responsible for:
77
1. Determining the type of each expression.
88
2. Resolving methods and traits.
99
3. Guaranteeing that most type rules are met. ("Most?", you say, "why most?"
10-
Well, dear reader, read on)
10+
Well, dear reader, read on.)
1111
12-
The main entry point is `check_crate()`. Type checking operates in
12+
The main entry point is [`check_crate()`]. Type checking operates in
1313
several major phases:
1414
1515
1. The collect phase first passes over all items and determines their
@@ -25,7 +25,7 @@ several major phases:
2525
containing function). Inference is used to supply types wherever
2626
they are unknown. The actual checking of a function itself has
2727
several phases (check, regionck, writeback), as discussed in the
28-
documentation for the `check` module.
28+
documentation for the [`check`] module.
2929
3030
The type checker is defined into various submodules which are documented
3131
independently:
@@ -56,7 +56,6 @@ This API is completely unstable and subject to change.
5656
*/
5757

5858
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
59-
#![feature(array_value_iter)]
6059
#![feature(bool_to_option)]
6160
#![feature(box_syntax)]
6261
#![feature(crate_visibility_modifier)]

library/alloc/src/boxed.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,39 @@ impl<A: Allocator> Box<dyn Any + Send, A> {
13721372
}
13731373
}
13741374

1375+
impl<A: Allocator> Box<dyn Any + Send + Sync, A> {
1376+
#[inline]
1377+
#[stable(feature = "box_send_sync_any_downcast", since = "1.51.0")]
1378+
/// Attempt to downcast the box to a concrete type.
1379+
///
1380+
/// # Examples
1381+
///
1382+
/// ```
1383+
/// use std::any::Any;
1384+
///
1385+
/// fn print_if_string(value: Box<dyn Any + Send + Sync>) {
1386+
/// if let Ok(string) = value.downcast::<String>() {
1387+
/// println!("String ({}): {}", string.len(), string);
1388+
/// }
1389+
/// }
1390+
///
1391+
/// let my_string = "Hello World".to_string();
1392+
/// print_if_string(Box::new(my_string));
1393+
/// print_if_string(Box::new(0i8));
1394+
/// ```
1395+
pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> {
1396+
if self.is::<T>() {
1397+
unsafe {
1398+
let (raw, alloc): (*mut (dyn Any + Send + Sync), _) =
1399+
Box::into_raw_with_allocator(self);
1400+
Ok(Box::from_raw_in(raw as *mut T, alloc))
1401+
}
1402+
} else {
1403+
Err(self)
1404+
}
1405+
}
1406+
}
1407+
13751408
#[stable(feature = "rust1", since = "1.0.0")]
13761409
impl<T: fmt::Display + ?Sized, A: Allocator> fmt::Display for Box<T, A> {
13771410
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

library/alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
#![feature(allocator_api)]
7979
#![feature(array_chunks)]
8080
#![feature(array_methods)]
81-
#![feature(array_value_iter)]
8281
#![feature(array_windows)]
8382
#![feature(allow_internal_unstable)]
8483
#![feature(arbitrary_self_types)]

0 commit comments

Comments
 (0)