Skip to content

Commit 001abef

Browse files
authored
Unrolled build for #147604
Rollup merge of #147604 - Kivooeo:tear-prev-pr, r=nnethercote Some clippy cleanups in compiler This extracts some of the changes from #147591 that were worth preserving in my opinion r? compiler
2 parents ff6dc92 + dc05250 commit 001abef

File tree

11 files changed

+23
-26
lines changed

11 files changed

+23
-26
lines changed

compiler/rustc_arena/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ impl<T> TypedArena<T> {
1919
unsafe {
2020
// Clear the last chunk, which is partially filled.
2121
let mut chunks_borrow = self.chunks.borrow_mut();
22-
if let Some(mut last_chunk) = chunks_borrow.last_mut() {
23-
self.clear_last_chunk(&mut last_chunk);
22+
if let Some(last_chunk) = chunks_borrow.last_mut() {
23+
self.clear_last_chunk(last_chunk);
2424
let len = chunks_borrow.len();
2525
// If `T` is ZST, code below has no effect.
2626
for mut chunk in chunks_borrow.drain(..len - 1) {

compiler/rustc_fluent_macro/src/fluent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
265265
Level::Error,
266266
format!("referenced message `{mref}` does not exist (in message `{name}`)"),
267267
)
268-
.help(&format!("you may have meant to use a variable reference (`{{${mref}}}`)"))
268+
.help(format!("you may have meant to use a variable reference (`{{${mref}}}`)"))
269269
.emit();
270270
}
271271
}

compiler/rustc_graphviz/src/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ impl NodeLabels<&'static str> {
6363
}
6464

6565
fn len(&self) -> usize {
66-
match self {
67-
&UnlabelledNodes(len) => len,
68-
&AllNodesLabelled(ref lbls) => lbls.len(),
69-
&SomeNodesLabelled(ref lbls) => lbls.len(),
66+
match *self {
67+
UnlabelledNodes(len) => len,
68+
AllNodesLabelled(ref lbls) => lbls.len(),
69+
SomeNodesLabelled(ref lbls) => lbls.len(),
7070
}
7171
}
7272
}

compiler/rustc_hashes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl FromStableHash for Hash64 {
5454
type Hash = StableHasherHash;
5555

5656
#[inline]
57-
fn from(StableHasherHash([_0, __1]): Self::Hash) -> Self {
57+
fn from(StableHasherHash([_0, _]): Self::Hash) -> Self {
5858
Self { inner: _0 }
5959
}
6060
}

compiler/rustc_llvm/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn main() {
197197

198198
// Include path contains host directory, replace it with target
199199
if is_crossed && flag.starts_with("-I") {
200-
cfg.flag(&flag.replace(&host, &target));
200+
cfg.flag(flag.replace(&host, &target));
201201
continue;
202202
}
203203

compiler/rustc_log/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl LoggerConfig {
7373

7474
/// Initialize the logger with the given values for the filter, coloring, and other options env variables.
7575
pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
76-
init_logger_with_additional_layer(cfg, || Registry::default())
76+
init_logger_with_additional_layer(cfg, Registry::default)
7777
}
7878

7979
/// Trait alias for the complex return type of `build_subscriber` in
@@ -145,14 +145,11 @@ where
145145
.with_thread_ids(verbose_thread_ids)
146146
.with_thread_names(verbose_thread_ids);
147147

148-
match cfg.wraptree {
149-
Ok(v) => match v.parse::<usize>() {
150-
Ok(v) => {
151-
layer = layer.with_wraparound(v);
152-
}
148+
if let Ok(v) = cfg.wraptree {
149+
match v.parse::<usize>() {
150+
Ok(v) => layer = layer.with_wraparound(v),
153151
Err(_) => return Err(Error::InvalidWraptree(v)),
154-
},
155-
Err(_) => {} // no wraptree
152+
}
156153
}
157154

158155
let subscriber = build_subscriber().with(layer.with_filter(filter));

compiler/rustc_thread_pool/src/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ impl WorkerThread {
808808
latch: &L,
809809
mut all_jobs_started: impl FnMut() -> bool,
810810
mut is_job: impl FnMut(&JobRef) -> bool,
811-
mut execute_job: impl FnMut(JobRef) -> (),
811+
mut execute_job: impl FnMut(JobRef),
812812
) {
813813
let mut jobs = SmallVec::<[JobRef; 8]>::new();
814814
let mut broadcast_jobs = SmallVec::<[JobRef; 8]>::new();

compiler/rustc_thread_pool/src/scope/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn the_final_countdown<'scope>(
168168
let top_of_stack = 0;
169169
let p = bottom_of_stack as *const i32 as usize;
170170
let q = &top_of_stack as *const i32 as usize;
171-
let diff = if p > q { p - q } else { q - p };
171+
let diff = p.abs_diff(q);
172172

173173
let mut data = max.lock().unwrap();
174174
*data = Ord::max(diff, *data);

compiler/rustc_thread_pool/src/thread_pool/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn failed_thread_stack() {
9797
// macOS and Windows weren't fazed, or at least didn't fail the way we want.
9898
// They work with `isize::MAX`, but 32-bit platforms may feasibly allocate a
9999
// 2GB stack, so it might not fail until the second thread.
100-
let stack_size = ::std::isize::MAX as usize;
100+
let stack_size = isize::MAX as usize;
101101

102102
let (start_count, start_handler) = count_handler();
103103
let (exit_count, exit_handler) = count_handler();

compiler/rustc_thread_pool/src/worker_local.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<T> WorkerLocal<T> {
4343
unsafe {
4444
let worker_thread = WorkerThread::current();
4545
if worker_thread.is_null()
46-
|| &*(*worker_thread).registry as *const _ != &*self.registry as *const _
46+
|| !std::ptr::eq(&*(*worker_thread).registry, &*self.registry)
4747
{
4848
panic!("WorkerLocal can only be used on the thread pool it was created on")
4949
}
@@ -55,7 +55,7 @@ impl<T> WorkerLocal<T> {
5555
impl<T> WorkerLocal<Vec<T>> {
5656
/// Joins the elements of all the worker locals into one Vec
5757
pub fn join(self) -> Vec<T> {
58-
self.into_inner().into_iter().flat_map(|v| v).collect()
58+
self.into_inner().into_iter().flatten().collect()
5959
}
6060
}
6161

0 commit comments

Comments
 (0)