Skip to content

Commit 3847e14

Browse files
Clean up: Applied x test tidy --bless. NOT COMPILABLE
1 parent 6d87db2 commit 3847e14

File tree

27 files changed

+828
-347
lines changed

27 files changed

+828
-347
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 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/mir/index.html
44
5-
use core::alloc::GlobalCoAllocMeta;
65
use crate::mir::interpret::{
76
AllocRange, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, LitToConstInput, Scalar,
87
};
@@ -14,6 +13,7 @@ use crate::ty::visit::{TypeVisitable, TypeVisitor};
1413
use crate::ty::{self, DefIdTree, List, Ty, TyCtxt};
1514
use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex};
1615
use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
16+
use core::alloc::GlobalCoAllocMeta;
1717

1818
use rustc_data_structures::captures::Captures;
1919
use rustc_errors::ErrorGuaranteed;

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! This is in a dedicated file so that changes to this file can be reviewed more carefully.
44
//! The intention is that this file only contains datatype declarations, no code.
55
6+
use super::{BasicBlock, Constant, Field, Local, SwitchTargets, UserTypeProjection};
67
use core::alloc::GlobalCoAllocMeta;
78
use core::mem;
8-
use super::{BasicBlock, Constant, Field, Local, SwitchTargets, UserTypeProjection};
99

1010
use crate::mir::coverage::{CodeRegion, CoverageKind};
1111
use crate::traits::Reveal;

compiler/rustc_parse/src/parser/attr_wrapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken};
12
use core::alloc::GlobalCoAllocMeta;
23
use core::mem;
3-
use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken};
44
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
55
use rustc_ast::tokenstream::{AttrTokenStream, AttributesData, ToAttrTokenStream};
66
use rustc_ast::tokenstream::{AttrTokenTree, DelimSpan, LazyAttrTokenStream, Spacing};

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ mod stmt;
1111
mod ty;
1212

1313
use crate::lexer::UnmatchedBrace;
14-
use core::alloc::GlobalCoAllocMeta;
1514
pub use attr_wrapper::AttrWrapper;
15+
use core::alloc::GlobalCoAllocMeta;
1616
pub use diagnostics::AttemptLocalParseRecovery;
1717
pub(crate) use item::FnParseMode;
1818
pub use pat::{CommaRecoveryMode, RecoverColon, RecoverComma};
@@ -169,7 +169,10 @@ pub struct Parser<'a> {
169169
// This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure
170170
// it doesn't unintentionally get bigger.
171171
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
172-
rustc_data_structures::static_assert_size!(Parser<'_>, 336 + 4 * mem::size_of::<GlobalCoAllocMeta>());
172+
rustc_data_structures::static_assert_size!(
173+
Parser<'_>,
174+
336 + 4 * mem::size_of::<GlobalCoAllocMeta>()
175+
);
173176

174177
/// Stores span information about a closure.
175178
#[derive(Clone)]

library/alloc/src/boxed.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,12 @@ impl<T> Box<[T]> {
700700
Err(_) => return Err(AllocError),
701701
};
702702
let ptr = Global.allocate(layout)?;
703-
Ok(RawVec::<T, Global, false>::from_raw_parts_in(ptr.as_mut_ptr() as *mut _, len, Global).into_box(len))
703+
Ok(RawVec::<T, Global, false>::from_raw_parts_in(
704+
ptr.as_mut_ptr() as *mut _,
705+
len,
706+
Global,
707+
)
708+
.into_box(len))
704709
}
705710
}
706711

@@ -732,13 +737,20 @@ impl<T> Box<[T]> {
732737
Err(_) => return Err(AllocError),
733738
};
734739
let ptr = Global.allocate_zeroed(layout)?;
735-
Ok(RawVec::<T, Global, false>::from_raw_parts_in(ptr.as_mut_ptr() as *mut _, len, Global).into_box(len))
740+
Ok(RawVec::<T, Global, false>::from_raw_parts_in(
741+
ptr.as_mut_ptr() as *mut _,
742+
len,
743+
Global,
744+
)
745+
.into_box(len))
736746
}
737747
}
738748
}
739749

740750
impl<T, A: Allocator> Box<[T], A>
741-
where [(); core::alloc::co_alloc_metadata_num_slots::<A>()]: {
751+
where
752+
[(); core::alloc::co_alloc_metadata_num_slots::<A>()]:,
753+
{
742754
/// Constructs a new boxed slice with uninitialized contents in the provided allocator.
743755
///
744756
/// # Examples
@@ -766,7 +778,10 @@ where [(); core::alloc::co_alloc_metadata_num_slots::<A>()]: {
766778
// #[unstable(feature = "new_uninit", issue = "63291")]
767779
#[must_use]
768780
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
769-
unsafe { RawVec::<T, A, {alloc::SHORT_TERM_VEC_PREFERS_COOP}>::with_capacity_in(len, alloc).into_box(len) }
781+
unsafe {
782+
RawVec::<T, A, { alloc::SHORT_TERM_VEC_PREFERS_COOP }>::with_capacity_in(len, alloc)
783+
.into_box(len)
784+
}
770785
}
771786

772787
/// Constructs a new boxed slice with uninitialized contents in the provided allocator,
@@ -794,7 +809,12 @@ where [(); core::alloc::co_alloc_metadata_num_slots::<A>()]: {
794809
// #[unstable(feature = "new_uninit", issue = "63291")]
795810
#[must_use]
796811
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
797-
unsafe { RawVec::<T, A, {alloc::SHORT_TERM_VEC_PREFERS_COOP}>::with_capacity_zeroed_in(len, alloc).into_box(len) }
812+
unsafe {
813+
RawVec::<T, A, { alloc::SHORT_TERM_VEC_PREFERS_COOP }>::with_capacity_zeroed_in(
814+
len, alloc,
815+
)
816+
.into_box(len)
817+
}
798818
}
799819
}
800820

@@ -2052,7 +2072,9 @@ impl<I> FromIterator<I> for Box<[I]> {
20522072
#[cfg(not(no_global_oom_handling))]
20532073
#[stable(feature = "box_slice_clone", since = "1.3.0")]
20542074
impl<T: Clone, A: Allocator + Clone> Clone for Box<[T], A>
2055-
where [(); core::alloc::co_alloc_metadata_num_slots::<A>()]: {
2075+
where
2076+
[(); core::alloc::co_alloc_metadata_num_slots::<A>()]:,
2077+
{
20562078
fn clone(&self) -> Self {
20572079
let alloc = Box::allocator(self).clone();
20582080
self.to_vec_in(alloc).into_boxed_slice()

library/alloc/src/collections/binary_heap.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@
143143
#![allow(missing_docs)]
144144
#![stable(feature = "rust1", since = "1.0.0")]
145145

146-
use core::{alloc, fmt};
147146
use core::iter::{FromIterator, FusedIterator, InPlaceIterable, SourceIter, TrustedLen};
148147
use core::mem::{self, swap, ManuallyDrop};
149148
use core::ops::{Deref, DerefMut};
150149
use core::ptr;
150+
use core::{alloc, fmt};
151151

152152
use crate::alloc::Global;
153153

@@ -1198,7 +1198,7 @@ impl<T> BinaryHeap<T> {
11981198
/// ```
11991199
#[inline]
12001200
#[stable(feature = "drain", since = "1.6.0")]
1201-
pub fn drain(&mut self) -> Drain<'_, T, {alloc::SHORT_TERM_VEC_PREFERS_COOP}> {
1201+
pub fn drain(&mut self) -> Drain<'_, T, { alloc::SHORT_TERM_VEC_PREFERS_COOP }> {
12021202
Drain { iter: self.data.drain(..) }
12031203
}
12041204

@@ -1479,13 +1479,17 @@ unsafe impl<T: Ord> TrustedLen for IntoIterSorted<T> {}
14791479
#[stable(feature = "drain", since = "1.6.0")]
14801480
#[derive(Debug)]
14811481
pub struct Drain<'a, T: 'a, const COOP_PREFERRED: bool>
1482-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]: {
1482+
where
1483+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1484+
{
14831485
iter: vec::Drain<'a, T, Global, COOP_PREFERRED>,
14841486
}
14851487

14861488
#[stable(feature = "drain", since = "1.6.0")]
14871489
impl<T, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, COOP_PREFERRED>
1488-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]: {
1490+
where
1491+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1492+
{
14891493
type Item = T;
14901494

14911495
#[inline]

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

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ pub struct Drain<
1919
'a,
2020
T: 'a,
2121
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
22-
const COOP_PREFERRED: bool = {alloc::SHORT_TERM_VEC_PREFERS_COOP}
23-
>
24-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
22+
const COOP_PREFERRED: bool = { alloc::SHORT_TERM_VEC_PREFERS_COOP },
23+
> where
24+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
25+
{
2526
// We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
2627
// and we want it to be covariant instead
2728
deque: NonNull<VecDeque<T, A, COOP_PREFERRED>>,
@@ -37,7 +38,9 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
3738
}
3839

3940
impl<'a, T, A: Allocator, const COOP_PREFERRED: bool> Drain<'a, T, A, COOP_PREFERRED>
40-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
41+
where
42+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
43+
{
4144
pub(super) unsafe fn new(
4245
deque: &'a mut VecDeque<T, A, COOP_PREFERRED>,
4346
drain_start: usize,
@@ -91,8 +94,11 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
9194
}
9295

9396
#[stable(feature = "collection_debug", since = "1.17.0")]
94-
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug for Drain<'_, T, A, COOP_PREFERRED>
95-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
97+
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug
98+
for Drain<'_, T, A, COOP_PREFERRED>
99+
where
100+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
101+
{
96102
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
97103
f.debug_tuple("Drain")
98104
.field(&self.drain_len)
@@ -104,21 +110,37 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
104110
}
105111

106112
#[stable(feature = "drain", since = "1.6.0")]
107-
unsafe impl<T: Sync, A: Allocator + Sync, const COOP_PREFERRED: bool> Sync for Drain<'_, T, A, COOP_PREFERRED>
108-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {}
113+
unsafe impl<T: Sync, A: Allocator + Sync, const COOP_PREFERRED: bool> Sync
114+
for Drain<'_, T, A, COOP_PREFERRED>
115+
where
116+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
117+
{
118+
}
109119
#[stable(feature = "drain", since = "1.6.0")]
110-
unsafe impl<T: Send, A: Allocator + Send, const COOP_PREFERRED: bool> Send for Drain<'_, T, A, COOP_PREFERRED>
111-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {}
120+
unsafe impl<T: Send, A: Allocator + Send, const COOP_PREFERRED: bool> Send
121+
for Drain<'_, T, A, COOP_PREFERRED>
122+
where
123+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
124+
{
125+
}
112126

113127
#[stable(feature = "drain", since = "1.6.0")]
114128
impl<T, A: Allocator, const COOP_PREFERRED: bool> Drop for Drain<'_, T, A, COOP_PREFERRED>
115-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
129+
where
130+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
131+
{
116132
fn drop(&mut self) {
117-
struct DropGuard<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool> (&'r mut Drain<'a, T, A, COOP_PREFERRED>)
118-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:;
133+
struct DropGuard<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool>(
134+
&'r mut Drain<'a, T, A, COOP_PREFERRED>,
135+
)
136+
where
137+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:;
119138

120-
impl<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool> Drop for DropGuard<'r, 'a, T, A, COOP_PREFERRED>
121-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
139+
impl<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool> Drop
140+
for DropGuard<'r, 'a, T, A, COOP_PREFERRED>
141+
where
142+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
143+
{
122144
fn drop(&mut self) {
123145
if self.0.remaining != 0 {
124146
unsafe {
@@ -200,7 +222,9 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
200222

201223
#[stable(feature = "drain", since = "1.6.0")]
202224
impl<T, A: Allocator, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, A, COOP_PREFERRED>
203-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
225+
where
226+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
227+
{
204228
type Item = T;
205229

206230
#[inline]
@@ -222,8 +246,11 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
222246
}
223247

224248
#[stable(feature = "drain", since = "1.6.0")]
225-
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator for Drain<'_, T, A, COOP_PREFERRED>
226-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
249+
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator
250+
for Drain<'_, T, A, COOP_PREFERRED>
251+
where
252+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
253+
{
227254
#[inline]
228255
fn next_back(&mut self) -> Option<T> {
229256
if self.remaining == 0 {
@@ -236,9 +263,15 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
236263
}
237264

238265
#[stable(feature = "drain", since = "1.6.0")]
239-
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator for Drain<'_, T, A, COOP_PREFERRED>
240-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {}
266+
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator
267+
for Drain<'_, T, A, COOP_PREFERRED>
268+
where
269+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
270+
{
271+
}
241272

242273
#[stable(feature = "fused", since = "1.26.0")]
243-
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for Drain<'_, T, A, COOP_PREFERRED>
244-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {}
274+
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for Drain<'_, T, A, COOP_PREFERRED> where
275+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
276+
{
277+
}

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use core::{alloc, fmt};
21
use core::iter::{FusedIterator, TrustedLen};
2+
use core::{alloc, fmt};
33

44
use crate::alloc::{Allocator, Global};
55

@@ -17,14 +17,17 @@ use super::VecDeque;
1717
pub struct IntoIter<
1818
T,
1919
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
20-
const COOP_PREFERRED: bool = true
21-
>
22-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]: {
20+
const COOP_PREFERRED: bool = true,
21+
> where
22+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
23+
{
2324
inner: VecDeque<T, A, COOP_PREFERRED>,
2425
}
2526

2627
impl<T, A: Allocator, const COOP_PREFERRED: bool> IntoIter<T, A, COOP_PREFERRED>
27-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
28+
where
29+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:,
30+
{
2831
pub(super) fn new(inner: VecDeque<T, A, COOP_PREFERRED>) -> Self {
2932
IntoIter { inner }
3033
}
@@ -36,15 +39,19 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
3639

3740
#[stable(feature = "collection_debug", since = "1.17.0")]
3841
impl<T: fmt::Debug, A: Allocator> fmt::Debug for IntoIter<T, A>
39-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
42+
where
43+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:,
44+
{
4045
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4146
f.debug_tuple("IntoIter").field(&self.inner).finish()
4247
}
4348
}
4449

4550
#[stable(feature = "rust1", since = "1.0.0")]
4651
impl<T, A: Allocator> Iterator for IntoIter<T, A>
47-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
52+
where
53+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:,
54+
{
4855
type Item = T;
4956

5057
#[inline]
@@ -61,7 +68,9 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
6168

6269
#[stable(feature = "rust1", since = "1.0.0")]
6370
impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A>
64-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
71+
where
72+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:,
73+
{
6574
#[inline]
6675
fn next_back(&mut self) -> Option<T> {
6776
self.inner.pop_back()
@@ -70,16 +79,22 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
7079

7180
#[stable(feature = "rust1", since = "1.0.0")]
7281
impl<T, A: Allocator> ExactSizeIterator for IntoIter<T, A>
73-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
82+
where
83+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:,
84+
{
7485
fn is_empty(&self) -> bool {
7586
self.inner.is_empty()
7687
}
7788
}
7889

7990
#[stable(feature = "fused", since = "1.26.0")]
80-
impl<T, A: Allocator> FusedIterator for IntoIter<T, A>
81-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {}
91+
impl<T, A: Allocator> FusedIterator for IntoIter<T, A> where
92+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:
93+
{
94+
}
8295

8396
#[unstable(feature = "trusted_len", issue = "37572")]
84-
unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A>
85-
where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {}
97+
unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A> where
98+
[(); alloc::co_alloc_metadata_num_slots::<A>()]:
99+
{
100+
}

0 commit comments

Comments
 (0)