treewide: enforce strict clippy check
This commit is contained in:
+32
-13
@@ -1,5 +1,5 @@
|
||||
use fix_bytecode::{Const, Continuation, InstructionPtr, Op, OperandType};
|
||||
use fix_lang::{BUILTINS, StringId};
|
||||
use fix_bytecode::{Const, InstructionPtr, Op, OperandType};
|
||||
use fix_lang::StringId;
|
||||
use hashbrown::HashMap;
|
||||
use rnix::TextRange;
|
||||
use string_interner::Symbol as _;
|
||||
@@ -54,7 +54,6 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn inline_maybe_thunk(&self, val: &MaybeThunk) -> InlineOperand {
|
||||
use MaybeThunk::*;
|
||||
match *val {
|
||||
@@ -75,14 +74,7 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
InlineOperand::Local { layer, local }
|
||||
}
|
||||
Arg { layer } => InlineOperand::Local { layer, local: 0 },
|
||||
Builtin(id) => {
|
||||
let (_, arity) = BUILTINS[id as usize];
|
||||
InlineOperand::Const(Const::PrimOp {
|
||||
id,
|
||||
arity,
|
||||
dispatch_ip: Continuation::entry_for_builtin(id).ip(),
|
||||
})
|
||||
}
|
||||
Builtin(id) => InlineOperand::Const(Const::PrimOp(id)),
|
||||
BuiltinConst(id) => InlineOperand::BuiltinConst(id),
|
||||
Builtins => InlineOperand::Builtins,
|
||||
ReplBinding(id) => InlineOperand::ReplBinding(id),
|
||||
@@ -186,6 +178,10 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
offset
|
||||
}
|
||||
#[inline]
|
||||
#[expect(
|
||||
clippy::indexing_slicing,
|
||||
reason = "offset addresses a 4-byte i32 placeholder this compiler previously emitted, so it is in bounds"
|
||||
)]
|
||||
fn patch_i32(&mut self, offset: usize, val: i32) {
|
||||
self.ctx.get_code_mut()[offset..offset + 4].copy_from_slice(&val.to_le_bytes());
|
||||
}
|
||||
@@ -214,6 +210,10 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
self.scope_stack.last().map_or(0, |s| s.depth)
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::panic,
|
||||
reason = "a ThunkId must resolve in some enclosing scope; failure indicates a compiler bug"
|
||||
)]
|
||||
fn resolve_thunk(&self, id: ThunkId) -> (u8, u32) {
|
||||
for scope in self.scope_stack.iter().rev() {
|
||||
if let Some(&local_idx) = scope.thunk_map.get(&id) {
|
||||
@@ -520,6 +520,10 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::unreachable,
|
||||
reason = "the outer match only reaches this arm for the binary operator kinds enumerated above"
|
||||
)]
|
||||
fn emit_binop(&mut self, lhs: RawIrRef<'_>, rhs: RawIrRef<'_>, kind: BinOpKind) {
|
||||
use BinOpKind::*;
|
||||
match kind {
|
||||
@@ -712,14 +716,25 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
}
|
||||
|
||||
if let Some(default) = default {
|
||||
let before: i32 = self.ctx.get_code().len().try_into().unwrap();
|
||||
// FIXME: i32???
|
||||
let before: i32 = self
|
||||
.ctx
|
||||
.get_code()
|
||||
.len()
|
||||
.try_into()
|
||||
.expect("emitted code length fits in i32");
|
||||
for patch in dynamic_patches {
|
||||
self.patch_jump_target(patch);
|
||||
}
|
||||
self.emit_op(Op::JumpIfSelectSucceeded);
|
||||
let placeholder = self.emit_i32_placeholder();
|
||||
self.emit_expr(default);
|
||||
let after: i32 = self.ctx.get_code().len().try_into().unwrap();
|
||||
let after: i32 = self
|
||||
.ctx
|
||||
.get_code()
|
||||
.len()
|
||||
.try_into()
|
||||
.expect("emitted code length fits in i32");
|
||||
// Offset is relative to after the placeholder, so subtract the
|
||||
// size of JumpIfSelectSucceeded (1) + placeholder (4).
|
||||
self.patch_i32(placeholder, after - before - 5);
|
||||
@@ -730,6 +745,10 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::panic,
|
||||
reason = "a hasAttr attrpath always has at least one attr by construction of the AST"
|
||||
)]
|
||||
fn emit_has_attr(&mut self, lhs: RawIrRef<'_>, rhs: &[Attr<RawIrRef<'_>>]) {
|
||||
self.emit_expr(lhs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user