Skip to content

Commit

Permalink
(src) made Clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxXSoft committed Nov 30, 2024
1 parent cfb7628 commit 2b01c86
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/front/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl Span {
const TAB_WIDTH: usize = 2;

thread_local! {
#[allow(clippy::thread_local_initializer_can_be_made_const)]
static STATE: RefCell<GlobalState> = RefCell::new(GlobalState {
file: FileType::Buffer,
err_num: 0,
Expand Down
6 changes: 5 additions & 1 deletion src/ir/idman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(in crate::ir) type ValueId = NonZeroU32;
/// memory layout optimization.
const GLOBAL_VALUE_ID_STARTS_FROM: ValueId = unsafe { NonZeroU32::new_unchecked(1) };

/// The value of `ValueId` (local value) should start from 1,
/// The value of `ValueId` (local value) should start from 0x40000000,
/// because we want to use `NonZeroU32` to enable some
/// memory layout optimization.
const LOCAL_VALUE_ID_STARTS_FROM: ValueId = unsafe { NonZeroU32::new_unchecked(0x40000000) };
Expand All @@ -42,12 +42,16 @@ const FUNC_ID_STARTS_FROM: FunctionId = unsafe { NonZeroU32::new_unchecked(1) };

thread_local! {
/// The next global value ID.
#[allow(clippy::thread_local_initializer_can_be_made_const)]
static NEXT_GLOBAL_VALUE_ID: Cell<ValueId> = Cell::new(GLOBAL_VALUE_ID_STARTS_FROM);
/// The next local value ID.
#[allow(clippy::thread_local_initializer_can_be_made_const)]
static NEXT_LOCAL_VALUE_ID: Cell<ValueId> = Cell::new(LOCAL_VALUE_ID_STARTS_FROM);
/// The next basic block ID.
#[allow(clippy::thread_local_initializer_can_be_made_const)]
static NEXT_BB_ID: Cell<BasicBlockId> = Cell::new(BB_ID_STARTS_FROM);
/// The next function ID.
#[allow(clippy::thread_local_initializer_can_be_made_const)]
static NEXT_FUNC_ID: Cell<FunctionId> = Cell::new(FUNC_ID_STARTS_FROM);
}

Expand Down
24 changes: 12 additions & 12 deletions src/ir/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ impl Map<BasicBlock, BasicBlockNode> for BasicBlockMap {
self.map.clear()
}

fn get<Q: ?Sized>(&self, k: &Q) -> Option<&BasicBlockNode>
fn get<Q>(&self, k: &Q) -> Option<&BasicBlockNode>
where
BasicBlock: Borrow<Q>,
Q: Hash + Eq,
Q: ?Sized + Hash + Eq,
{
self.map.get(k)
}

fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut BasicBlockNode>
fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut BasicBlockNode>
where
BasicBlock: Borrow<Q>,
Q: Hash + Eq,
Q: ?Sized + Hash + Eq,
{
self.map.get_mut(k)
}
Expand All @@ -135,10 +135,10 @@ impl Map<BasicBlock, BasicBlockNode> for BasicBlockMap {
}
}

fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(BasicBlock, BasicBlockNode)>
fn remove_entry<Q>(&mut self, k: &Q) -> Option<(BasicBlock, BasicBlockNode)>
where
BasicBlock: Borrow<Q>,
Q: Hash + Eq,
Q: ?Sized + Hash + Eq,
{
self.map.remove_entry(k)
}
Expand Down Expand Up @@ -225,18 +225,18 @@ impl Map<Value, InstNode> for InstMap {
self.map.clear()
}

fn get<Q: ?Sized>(&self, k: &Q) -> Option<&InstNode>
fn get<Q>(&self, k: &Q) -> Option<&InstNode>
where
Value: Borrow<Q>,
Q: Hash + Eq,
Q: ?Sized + Hash + Eq,
{
self.map.get(k)
}

fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut InstNode>
fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut InstNode>
where
Value: Borrow<Q>,
Q: Hash + Eq,
Q: ?Sized + Hash + Eq,
{
self.map.get_mut(k)
}
Expand All @@ -260,10 +260,10 @@ impl Map<Value, InstNode> for InstMap {
}
}

fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(Value, InstNode)>
fn remove_entry<Q>(&mut self, k: &Q) -> Option<(Value, InstNode)>
where
Value: Borrow<Q>,
Q: Hash + Eq,
Q: ?Sized + Hash + Eq,
{
let kv = self.map.remove_entry(k);
if kv.is_some() {
Expand Down
1 change: 1 addition & 0 deletions src/ir/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Type {
static POOL: RefCell<HashMap<TypeKind, Type>> = RefCell::new(HashMap::new());

/// Size of pointers.
#[allow(clippy::thread_local_initializer_can_be_made_const)]
static PTR_SIZE: Cell<usize> = Cell::new(mem::size_of::<*const ()>());
}

Expand Down

0 comments on commit 2b01c86

Please sign in to comment.