some cleanups in compiler

This commit is contained in:
Kivooeo
2025-10-12 08:08:30 +00:00
parent 3be68033b6
commit dc05250c2f
11 changed files with 23 additions and 26 deletions

View File

@@ -19,8 +19,8 @@ impl<T> TypedArena<T> {
unsafe {
// Clear the last chunk, which is partially filled.
let mut chunks_borrow = self.chunks.borrow_mut();
if let Some(mut last_chunk) = chunks_borrow.last_mut() {
self.clear_last_chunk(&mut last_chunk);
if let Some(last_chunk) = chunks_borrow.last_mut() {
self.clear_last_chunk(last_chunk);
let len = chunks_borrow.len();
// If `T` is ZST, code below has no effect.
for mut chunk in chunks_borrow.drain(..len - 1) {

View File

@@ -265,7 +265,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
Level::Error,
format!("referenced message `{mref}` does not exist (in message `{name}`)"),
)
.help(&format!("you may have meant to use a variable reference (`{{${mref}}}`)"))
.help(format!("you may have meant to use a variable reference (`{{${mref}}}`)"))
.emit();
}
}

View File

@@ -63,10 +63,10 @@ impl NodeLabels<&'static str> {
}
fn len(&self) -> usize {
match self {
&UnlabelledNodes(len) => len,
&AllNodesLabelled(ref lbls) => lbls.len(),
&SomeNodesLabelled(ref lbls) => lbls.len(),
match *self {
UnlabelledNodes(len) => len,
AllNodesLabelled(ref lbls) => lbls.len(),
SomeNodesLabelled(ref lbls) => lbls.len(),
}
}
}

View File

@@ -54,7 +54,7 @@ impl FromStableHash for Hash64 {
type Hash = StableHasherHash;
#[inline]
fn from(StableHasherHash([_0, __1]): Self::Hash) -> Self {
fn from(StableHasherHash([_0, _]): Self::Hash) -> Self {
Self { inner: _0 }
}
}

View File

@@ -197,7 +197,7 @@ fn main() {
// Include path contains host directory, replace it with target
if is_crossed && flag.starts_with("-I") {
cfg.flag(&flag.replace(&host, &target));
cfg.flag(flag.replace(&host, &target));
continue;
}

View File

@@ -73,7 +73,7 @@ impl LoggerConfig {
/// Initialize the logger with the given values for the filter, coloring, and other options env variables.
pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
init_logger_with_additional_layer(cfg, || Registry::default())
init_logger_with_additional_layer(cfg, Registry::default)
}
/// Trait alias for the complex return type of `build_subscriber` in
@@ -145,14 +145,11 @@ where
.with_thread_ids(verbose_thread_ids)
.with_thread_names(verbose_thread_ids);
match cfg.wraptree {
Ok(v) => match v.parse::<usize>() {
Ok(v) => {
layer = layer.with_wraparound(v);
}
if let Ok(v) = cfg.wraptree {
match v.parse::<usize>() {
Ok(v) => layer = layer.with_wraparound(v),
Err(_) => return Err(Error::InvalidWraptree(v)),
},
Err(_) => {} // no wraptree
}
}
let subscriber = build_subscriber().with(layer.with_filter(filter));

View File

@@ -808,7 +808,7 @@ impl WorkerThread {
latch: &L,
mut all_jobs_started: impl FnMut() -> bool,
mut is_job: impl FnMut(&JobRef) -> bool,
mut execute_job: impl FnMut(JobRef) -> (),
mut execute_job: impl FnMut(JobRef),
) {
let mut jobs = SmallVec::<[JobRef; 8]>::new();
let mut broadcast_jobs = SmallVec::<[JobRef; 8]>::new();

View File

@@ -168,7 +168,7 @@ fn the_final_countdown<'scope>(
let top_of_stack = 0;
let p = bottom_of_stack as *const i32 as usize;
let q = &top_of_stack as *const i32 as usize;
let diff = if p > q { p - q } else { q - p };
let diff = p.abs_diff(q);
let mut data = max.lock().unwrap();
*data = Ord::max(diff, *data);

View File

@@ -97,7 +97,7 @@ fn failed_thread_stack() {
// macOS and Windows weren't fazed, or at least didn't fail the way we want.
// They work with `isize::MAX`, but 32-bit platforms may feasibly allocate a
// 2GB stack, so it might not fail until the second thread.
let stack_size = ::std::isize::MAX as usize;
let stack_size = isize::MAX as usize;
let (start_count, start_handler) = count_handler();
let (exit_count, exit_handler) = count_handler();

View File

@@ -43,7 +43,7 @@ impl<T> WorkerLocal<T> {
unsafe {
let worker_thread = WorkerThread::current();
if worker_thread.is_null()
|| &*(*worker_thread).registry as *const _ != &*self.registry as *const _
|| !std::ptr::eq(&*(*worker_thread).registry, &*self.registry)
{
panic!("WorkerLocal can only be used on the thread pool it was created on")
}
@@ -55,7 +55,7 @@ impl<T> WorkerLocal<T> {
impl<T> WorkerLocal<Vec<T>> {
/// Joins the elements of all the worker locals into one Vec
pub fn join(self) -> Vec<T> {
self.into_inner().into_iter().flat_map(|v| v).collect()
self.into_inner().into_iter().flatten().collect()
}
}

View File

@@ -197,12 +197,12 @@ fn lift(mut ty: syn::Type) -> syn::Type {
impl VisitMut for ItoJ {
fn visit_type_path_mut(&mut self, i: &mut syn::TypePath) {
if i.qself.is_none() {
if let Some(first) = i.path.segments.first_mut() {
if first.ident == "I" {
if let Some(first) = i.path.segments.first_mut()
&& first.ident == "I"
{
*first = parse_quote! { J };
}
}
}
syn::visit_mut::visit_type_path_mut(self, i);
}
}