Skip to content

Commit 2ed65da

Browse files
committed
Auto merge of #104629 - JohnTitor:rollup-vp3m98i, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #103901 (Add tracking issue for `const_arguments_as_str`) - #104112 (rustdoc: Add copy to the description of repeat) - #104435 (`VecDeque::resize` should re-use the buffer in the passed-in element) - #104467 (Fix substraction with overflow in `wrong_number_of_generic_args.rs`) - #104608 (Cleanup macro matching recovery) - #104626 (Fix doctest errors related to rustc_middle) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7477c1f + d553811 commit 2ed65da

File tree

19 files changed

+377
-14
lines changed

19 files changed

+377
-14
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>(
495495
// hacky, but speeds up the `html5ever` benchmark significantly. (Issue
496496
// 68836 suggests a more comprehensive but more complex change to deal with
497497
// this situation.)
498-
// FIXME(Nilstrieb): Stop recovery from happening on this parser and retry later with recovery if the macro failed to match.
499498
let parser = parser_from_cx(sess, arg.clone(), T::recovery());
500499
// Try each arm's matchers.
501500
let mut tt_parser = TtParser::new(name);

compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
728728
&& let Some(trait_path_segment) = path.segments.get(0) {
729729
let num_generic_args_supplied_to_trait = trait_path_segment.args().num_generic_params();
730730

731-
if num_assoc_fn_excess_args == num_trait_generics_except_self - num_generic_args_supplied_to_trait {
731+
if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args == num_trait_generics_except_self
732+
{
732733
if let Some(span) = self.gen_args.span_ext()
733734
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
734735
let sugg = vec![

compiler/rustc_middle/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.0.0"
44
edition = "2021"
55

66
[lib]
7-
doctest = false
87

98
[dependencies]
109
bitflags = "1.2.1"

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,8 @@ rustc_queries! {
16481648
/// a generic type parameter will panic if you call this method on it:
16491649
///
16501650
/// ```
1651+
/// use std::fmt::Debug;
1652+
///
16511653
/// pub trait Foo<T: Debug> {}
16521654
/// ```
16531655
///

compiler/rustc_middle/src/ty/inhabitedness/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! # Example
77
//! ```rust
8-
//! enum Void {}
8+
//! #![feature(never_type)]
99
//! mod a {
1010
//! pub mod b {
1111
//! pub struct SecretlyUninhabited {
@@ -15,6 +15,7 @@
1515
//! }
1616
//!
1717
//! mod c {
18+
//! enum Void {}
1819
//! pub struct AlsoSecretlyUninhabited {
1920
//! _priv: Void,
2021
//! }
@@ -35,7 +36,7 @@
3536
//! `Foo`.
3637
//!
3738
//! # Example
38-
//! ```rust
39+
//! ```ignore(illustrative)
3940
//! let foo_result: Result<T, Foo> = ... ;
4041
//! let Ok(t) = foo_result;
4142
//! ```

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,12 +2078,7 @@ impl<'a> Parser<'a> {
20782078

20792079
if self.token.kind == TokenKind::Semi
20802080
&& matches!(self.token_cursor.frame.delim_sp, Some((Delimiter::Parenthesis, _)))
2081-
// HACK: This is needed so we can detect whether we're inside a macro,
2082-
// where regular assumptions about what tokens can follow other tokens
2083-
// don't necessarily apply.
20842081
&& self.may_recover()
2085-
// FIXME(Nilstrieb): Remove this check once `may_recover` actually stops recovery
2086-
&& self.subparser_name.is_none()
20872082
{
20882083
// It is likely that the closure body is a block but where the
20892084
// braces have been removed. We will recover and eat the next

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use core::cmp::{self, Ordering};
1111
use core::fmt;
1212
use core::hash::{Hash, Hasher};
13-
use core::iter::{repeat_with, FromIterator};
13+
use core::iter::{repeat_n, repeat_with, FromIterator};
1414
use core::marker::PhantomData;
1515
use core::mem::{ManuallyDrop, MaybeUninit, SizedTypeProperties};
1616
use core::ops::{Index, IndexMut, Range, RangeBounds};
@@ -2833,7 +2833,12 @@ impl<T: Clone, A: Allocator> VecDeque<T, A> {
28332833
/// ```
28342834
#[stable(feature = "deque_extras", since = "1.16.0")]
28352835
pub fn resize(&mut self, new_len: usize, value: T) {
2836-
self.resize_with(new_len, || value.clone());
2836+
if new_len > self.len() {
2837+
let extra = new_len - self.len();
2838+
self.extend(repeat_n(value, extra))
2839+
} else {
2840+
self.truncate(new_len);
2841+
}
28372842
}
28382843
}
28392844

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
#![feature(inplace_iteration)]
125125
#![feature(iter_advance_by)]
126126
#![feature(iter_next_chunk)]
127+
#![feature(iter_repeat_n)]
127128
#![feature(layout_for_ptr)]
128129
#![feature(maybe_uninit_slice)]
129130
#![feature(maybe_uninit_uninit_array)]

library/alloc/src/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl<T> [T] {
458458
hack::into_vec(self)
459459
}
460460

461-
/// Creates a vector by repeating a slice `n` times.
461+
/// Creates a vector by copying a slice `n` times.
462462
///
463463
/// # Panics
464464
///

library/alloc/tests/vec_deque.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,3 +1727,11 @@ fn test_from_zero_sized_vec() {
17271727
let queue = VecDeque::from(v);
17281728
assert_eq!(queue.len(), 100);
17291729
}
1730+
1731+
#[test]
1732+
fn test_resize_keeps_reserved_space_from_item() {
1733+
let v = Vec::<i32>::with_capacity(1234);
1734+
let mut d = VecDeque::new();
1735+
d.resize(1, v);
1736+
assert_eq!(d[0].capacity(), 1234);
1737+
}

0 commit comments

Comments
 (0)