Skip to content

Commit afaf3e0

Browse files
committed
Auto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #105526 (libcore: make result of iter::from_generator Clone) - #106563 (Fix `unused_braces` on generic const expr macro call) - #106661 (Stop probing for statx unless necessary) - #106820 (Deprioritize fulfillment errors that come from expansions.) - #106828 (rustdoc: remove `docblock` class from notable trait popover) - #106849 (Allocate one less vec while parsing arrays) - #106855 (rustdoc: few small cleanups) - #106860 (Remove various double spaces in the libraries.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b8f9cb3 + e0eb63a commit afaf3e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+221
-161
lines changed

compiler/rustc_lint/src/unused.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,7 @@ impl UnusedDelimLint for UnusedBraces {
11051105
|| matches!(expr.kind, ast::ExprKind::Lit(_)))
11061106
&& !cx.sess().source_map().is_multiline(value.span)
11071107
&& value.attrs.is_empty()
1108+
&& !expr.span.from_expansion()
11081109
&& !value.span.from_expansion()
11091110
&& !inner.span.from_expansion()
11101111
{

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,9 +1475,8 @@ impl<'a> Parser<'a> {
14751475
} else if self.eat(&token::Comma) {
14761476
// Vector with two or more elements.
14771477
let sep = SeqSep::trailing_allowed(token::Comma);
1478-
let (remaining_exprs, _) = self.parse_seq_to_end(close, sep, |p| p.parse_expr())?;
1479-
let mut exprs = vec![first_expr];
1480-
exprs.extend(remaining_exprs);
1478+
let (mut exprs, _) = self.parse_seq_to_end(close, sep, |p| p.parse_expr())?;
1479+
exprs.insert(0, first_expr);
14811480
ExprKind::Array(exprs)
14821481
} else {
14831482
// Vector with one element

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
454454
}
455455
}
456456

457-
for (error, suppressed) in iter::zip(errors, is_suppressed) {
458-
if !suppressed {
459-
self.report_fulfillment_error(error, body_id);
457+
for from_expansion in [false, true] {
458+
for (error, suppressed) in iter::zip(errors, &is_suppressed) {
459+
if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion {
460+
self.report_fulfillment_error(error, body_id);
461+
}
460462
}
461463
}
462464

library/alloc/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::marker::Destruct;
2020
mod tests;
2121

2222
extern "Rust" {
23-
// These are the magic symbols to call the global allocator. rustc generates
23+
// These are the magic symbols to call the global allocator. rustc generates
2424
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
2525
// (the code expanding that attribute macro generates those functions), or to call
2626
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
@@ -353,7 +353,7 @@ pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Dest
353353

354354
#[cfg(not(no_global_oom_handling))]
355355
extern "Rust" {
356-
// This is the magic symbol to call the global alloc error handler. rustc generates
356+
// This is the magic symbol to call the global alloc error handler. rustc generates
357357
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
358358
// default implementations below (`__rdl_oom`) otherwise.
359359
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;

library/alloc/src/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ pub struct Weak<T: ?Sized> {
21792179
// This is a `NonNull` to allow optimizing the size of this type in enums,
21802180
// but it is not necessarily a valid pointer.
21812181
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
2182-
// to allocate space on the heap. That's not a value a real pointer
2182+
// to allocate space on the heap. That's not a value a real pointer
21832183
// will ever have because RcBox has alignment at least 2.
21842184
// This is only possible when `T: Sized`; unsized `T` never dangle.
21852185
ptr: NonNull<RcBox<T>>,

library/alloc/src/sync.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub struct Weak<T: ?Sized> {
295295
// This is a `NonNull` to allow optimizing the size of this type in enums,
296296
// but it is not necessarily a valid pointer.
297297
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
298-
// to allocate space on the heap. That's not a value a real pointer
298+
// to allocate space on the heap. That's not a value a real pointer
299299
// will ever have because RcBox has alignment at least 2.
300300
// This is only possible when `T: Sized`; unsized `T` never dangle.
301301
ptr: NonNull<ArcInner<T>>,
@@ -1656,7 +1656,7 @@ impl<T: ?Sized> Arc<T> {
16561656
//
16571657
// The acquire label here ensures a happens-before relationship with any
16581658
// writes to `strong` (in particular in `Weak::upgrade`) prior to decrements
1659-
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
1659+
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
16601660
// weak ref was never dropped, the CAS here will fail so we do not care to synchronize.
16611661
if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
16621662
// This needs to be an `Acquire` to synchronize with the decrement of the `strong`
@@ -1712,7 +1712,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
17121712
}
17131713

17141714
// This fence is needed to prevent reordering of use of the data and
1715-
// deletion of the data. Because it is marked `Release`, the decreasing
1715+
// deletion of the data. Because it is marked `Release`, the decreasing
17161716
// of the reference count synchronizes with this `Acquire` fence. This
17171717
// means that use of the data happens before decreasing the reference
17181718
// count, which happens before this fence, which happens before the
@@ -2172,7 +2172,7 @@ impl<T: ?Sized> Clone for Weak<T> {
21722172
} else {
21732173
return Weak { ptr: self.ptr };
21742174
};
2175-
// See comments in Arc::clone() for why this is relaxed. This can use a
2175+
// See comments in Arc::clone() for why this is relaxed. This can use a
21762176
// fetch_add (ignoring the lock) because the weak count is only locked
21772177
// where are *no other* weak pointers in existence. (So we can't be
21782178
// running this code in that case).

library/alloc/src/vec/into_iter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct IntoIter<
4040
// to avoid dropping the allocator twice we need to wrap it into ManuallyDrop
4141
pub(super) alloc: ManuallyDrop<A>,
4242
pub(super) ptr: *const T,
43-
pub(super) end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
43+
pub(super) end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that
4444
// ptr == end is a quick test for the Iterator being empty, that works
4545
// for both ZST and non-ZST.
4646
}
@@ -146,9 +146,9 @@ impl<T, A: Allocator> IntoIter<T, A> {
146146
let mut this = ManuallyDrop::new(self);
147147

148148
// SAFETY: This allocation originally came from a `Vec`, so it passes
149-
// all those checks. We have `this.buf` ≤ `this.ptr` ≤ `this.end`,
149+
// all those checks. We have `this.buf` ≤ `this.ptr` ≤ `this.end`,
150150
// so the `sub_ptr`s below cannot wrap, and will produce a well-formed
151-
// range. `end` ≤ `buf + cap`, so the range will be in-bounds.
151+
// range. `end` ≤ `buf + cap`, so the range will be in-bounds.
152152
// Taking `alloc` is ok because nothing else is going to look at it,
153153
// since our `Drop` impl isn't going to run so there's no more code.
154154
unsafe {

library/alloc/src/vec/is_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ unsafe impl<T: IsZero, const N: usize> IsZero for [T; N] {
5757
#[inline]
5858
fn is_zero(&self) -> bool {
5959
// Because this is generated as a runtime check, it's not obvious that
60-
// it's worth doing if the array is really long. The threshold here
60+
// it's worth doing if the array is really long. The threshold here
6161
// is largely arbitrary, but was picked because as of 2022-07-01 LLVM
6262
// fails to const-fold the check in `vec![[1; 32]; n]`
6363
// See https://github.com/rust-lang/rust/pull/97581#issuecomment-1166628022

library/alloc/src/vec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
24292429
self.reserve(range.len());
24302430

24312431
// SAFETY:
2432-
// - `slice::range` guarantees that the given range is valid for indexing self
2432+
// - `slice::range` guarantees that the given range is valid for indexing self
24332433
unsafe {
24342434
self.spec_extend_from_within(range);
24352435
}
@@ -2686,7 +2686,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
26862686

26872687
// HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is
26882688
// required for this method definition, is not available. Instead use the
2689-
// `slice::to_vec` function which is only available with cfg(test)
2689+
// `slice::to_vec` function which is only available with cfg(test)
26902690
// NB see the slice::hack module in slice.rs for more information
26912691
#[cfg(test)]
26922692
fn clone(&self) -> Self {

library/alloc/tests/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ fn test_stable_pointers() {
18491849
}
18501850

18511851
// Test that, if we reserved enough space, adding and removing elements does not
1852-
// invalidate references into the vector (such as `v0`). This test also
1852+
// invalidate references into the vector (such as `v0`). This test also
18531853
// runs in Miri, which would detect such problems.
18541854
// Note that this test does *not* constitute a stable guarantee that all these functions do not
18551855
// reallocate! Only what is explicitly documented at

0 commit comments

Comments
 (0)