forked from M-Labs/nac3
[meta] Apply clippy suggestions
This commit is contained in:
parent
eaaa194a87
commit
8baf111734
@ -162,7 +162,7 @@ impl<'a> ArtiqCodeGenerator<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> CodeGenerator for ArtiqCodeGenerator<'b> {
|
impl CodeGenerator for ArtiqCodeGenerator<'_> {
|
||||||
fn get_name(&self) -> &str {
|
fn get_name(&self) -> &str {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
@ -1505,7 +1505,7 @@ pub fn call_rtio_log_impl<'ctx>(
|
|||||||
/// Generates a call to `core_log`.
|
/// Generates a call to `core_log`.
|
||||||
pub fn gen_core_log<'ctx>(
|
pub fn gen_core_log<'ctx>(
|
||||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||||
obj: &Option<(Type, ValueEnum<'ctx>)>,
|
obj: Option<&(Type, ValueEnum<'ctx>)>,
|
||||||
fun: (&FunSignature, DefinitionId),
|
fun: (&FunSignature, DefinitionId),
|
||||||
args: &[(Option<StrRef>, ValueEnum<'ctx>)],
|
args: &[(Option<StrRef>, ValueEnum<'ctx>)],
|
||||||
generator: &mut dyn CodeGenerator,
|
generator: &mut dyn CodeGenerator,
|
||||||
@ -1522,7 +1522,7 @@ pub fn gen_core_log<'ctx>(
|
|||||||
/// Generates a call to `rtio_log`.
|
/// Generates a call to `rtio_log`.
|
||||||
pub fn gen_rtio_log<'ctx>(
|
pub fn gen_rtio_log<'ctx>(
|
||||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||||
obj: &Option<(Type, ValueEnum<'ctx>)>,
|
obj: Option<&(Type, ValueEnum<'ctx>)>,
|
||||||
fun: (&FunSignature, DefinitionId),
|
fun: (&FunSignature, DefinitionId),
|
||||||
args: &[(Option<StrRef>, ValueEnum<'ctx>)],
|
args: &[(Option<StrRef>, ValueEnum<'ctx>)],
|
||||||
generator: &mut dyn CodeGenerator,
|
generator: &mut dyn CodeGenerator,
|
||||||
|
@ -330,7 +330,7 @@ impl Nac3 {
|
|||||||
vars: into_var_map([arg_ty]),
|
vars: into_var_map([arg_ty]),
|
||||||
},
|
},
|
||||||
Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| {
|
Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| {
|
||||||
gen_core_log(ctx, &obj, fun, &args, generator)?;
|
gen_core_log(ctx, obj.as_ref(), fun, &args, generator)?;
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}))),
|
}))),
|
||||||
@ -360,7 +360,7 @@ impl Nac3 {
|
|||||||
vars: into_var_map([arg_ty]),
|
vars: into_var_map([arg_ty]),
|
||||||
},
|
},
|
||||||
Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| {
|
Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| {
|
||||||
gen_rtio_log(ctx, &obj, fun, &args, generator)?;
|
gen_rtio_log(ctx, obj.as_ref(), fun, &args, generator)?;
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}))),
|
}))),
|
||||||
|
@ -931,9 +931,9 @@ impl InnerResolver {
|
|||||||
|_| Ok(Ok(extracted_ty)),
|
|_| Ok(Ok(extracted_ty)),
|
||||||
)
|
)
|
||||||
} else if unifier.unioned(extracted_ty, primitives.bool) {
|
} else if unifier.unioned(extracted_ty, primitives.bool) {
|
||||||
if let Ok(_) = obj.extract::<bool>() {
|
if obj.extract::<bool>().is_ok()
|
||||||
Ok(Ok(extracted_ty))
|
|| obj.call_method("__bool__", (), None)?.extract::<bool>().is_ok()
|
||||||
} else if let Ok(_) = obj.call_method("__bool__", (), None)?.extract::<bool>() {
|
{
|
||||||
Ok(Ok(extracted_ty))
|
Ok(Ok(extracted_ty))
|
||||||
} else {
|
} else {
|
||||||
Ok(Err(format!("{obj} is not in the range of bool")))
|
Ok(Err(format!("{obj} is not in the range of bool")))
|
||||||
|
@ -79,7 +79,7 @@ pub fn get_subst_key(
|
|||||||
.join(", ")
|
.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, 'a> CodeGenContext<'ctx, 'a> {
|
impl<'ctx> CodeGenContext<'ctx, '_> {
|
||||||
/// Builds a sequence of `getelementptr` and `load` instructions which stores the value of a
|
/// Builds a sequence of `getelementptr` and `load` instructions which stores the value of a
|
||||||
/// struct field into an LLVM value.
|
/// struct field into an LLVM value.
|
||||||
pub fn build_gep_and_load(
|
pub fn build_gep_and_load(
|
||||||
|
@ -228,7 +228,7 @@ pub struct CodeGenContext<'ctx, 'a> {
|
|||||||
pub current_loc: Location,
|
pub current_loc: Location,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, 'a> CodeGenContext<'ctx, 'a> {
|
impl CodeGenContext<'_, '_> {
|
||||||
/// Whether the [current basic block][Builder::get_insert_block] referenced by `builder`
|
/// Whether the [current basic block][Builder::get_insert_block] referenced by `builder`
|
||||||
/// contains a [terminator statement][BasicBlock::get_terminator].
|
/// contains a [terminator statement][BasicBlock::get_terminator].
|
||||||
pub fn is_terminated(&self) -> bool {
|
pub fn is_terminated(&self) -> bool {
|
||||||
|
@ -807,7 +807,7 @@ struct TypeToStringFolder<'a> {
|
|||||||
unifier: &'a mut Unifier,
|
unifier: &'a mut Unifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Fold<Option<Type>> for TypeToStringFolder<'a> {
|
impl Fold<Option<Type>> for TypeToStringFolder<'_> {
|
||||||
type TargetU = String;
|
type TargetU = String;
|
||||||
type Error = String;
|
type Error = String;
|
||||||
fn map_user(&mut self, user: Option<Type>) -> Result<Self::TargetU, Self::Error> {
|
fn map_user(&mut self, user: Option<Type>) -> Result<Self::TargetU, Self::Error> {
|
||||||
|
@ -15,7 +15,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::toplevel::helper::PrimDef;
|
use crate::toplevel::helper::PrimDef;
|
||||||
|
|
||||||
impl<'a> Inferencer<'a> {
|
impl Inferencer<'_> {
|
||||||
fn should_have_value(&mut self, expr: &Expr<Option<Type>>) -> Result<(), HashSet<String>> {
|
fn should_have_value(&mut self, expr: &Expr<Option<Type>>) -> Result<(), HashSet<String>> {
|
||||||
if matches!(expr.custom, Some(ty) if self.unifier.unioned(ty, self.primitives.none)) {
|
if matches!(expr.custom, Some(ty) if self.unifier.unioned(ty, self.primitives.none)) {
|
||||||
Err(HashSet::from([format!("Error at {}: cannot have value none", expr.location)]))
|
Err(HashSet::from([format!("Error at {}: cannot have value none", expr.location)]))
|
||||||
@ -94,7 +94,7 @@ impl<'a> Inferencer<'a> {
|
|||||||
// there are some cases where the custom field is None
|
// there are some cases where the custom field is None
|
||||||
if let Some(ty) = &expr.custom {
|
if let Some(ty) = &expr.custom {
|
||||||
if !matches!(&expr.node, ExprKind::Constant { value: Constant::Ellipsis, .. })
|
if !matches!(&expr.node, ExprKind::Constant { value: Constant::Ellipsis, .. })
|
||||||
&& !ty.obj_id(self.unifier).is_some_and(|id| id == PrimDef::List.id())
|
&& ty.obj_id(self.unifier).is_none_or(|id| id != PrimDef::List.id())
|
||||||
&& !self.unifier.is_concrete(*ty, &self.function_data.bound_variables)
|
&& !self.unifier.is_concrete(*ty, &self.function_data.bound_variables)
|
||||||
{
|
{
|
||||||
return Err(HashSet::from([format!(
|
return Err(HashSet::from([format!(
|
||||||
|
@ -94,7 +94,7 @@ fn loc_to_str(loc: Option<Location>) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Display for DisplayTypeError<'a> {
|
impl Display for DisplayTypeError<'_> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
use TypeErrorKind::*;
|
use TypeErrorKind::*;
|
||||||
let mut notes = Some(HashMap::new());
|
let mut notes = Some(HashMap::new());
|
||||||
|
@ -187,7 +187,7 @@ fn fix_assignment_target_context(node: &mut ast::Located<ExprKind>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Fold<()> for Inferencer<'a> {
|
impl Fold<()> for Inferencer<'_> {
|
||||||
type TargetU = Option<Type>;
|
type TargetU = Option<Type>;
|
||||||
type Error = InferenceError;
|
type Error = InferenceError;
|
||||||
|
|
||||||
@ -657,7 +657,7 @@ impl<'a> Fold<()> for Inferencer<'a> {
|
|||||||
|
|
||||||
type InferenceResult = Result<Type, InferenceError>;
|
type InferenceResult = Result<Type, InferenceError>;
|
||||||
|
|
||||||
impl<'a> Inferencer<'a> {
|
impl Inferencer<'_> {
|
||||||
/// Constrain a <: b
|
/// Constrain a <: b
|
||||||
/// Currently implemented as unification
|
/// Currently implemented as unification
|
||||||
fn constrain(&mut self, a: Type, b: Type, location: &Location) -> Result<(), InferenceError> {
|
fn constrain(&mut self, a: Type, b: Type, location: &Location) -> Result<(), InferenceError> {
|
||||||
|
@ -30,7 +30,7 @@ pub struct DwarfReader<'a> {
|
|||||||
pub virt_addr: u32,
|
pub virt_addr: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DwarfReader<'a> {
|
impl DwarfReader<'_> {
|
||||||
pub fn new(slice: &[u8], virt_addr: u32) -> DwarfReader {
|
pub fn new(slice: &[u8], virt_addr: u32) -> DwarfReader {
|
||||||
DwarfReader { slice, virt_addr }
|
DwarfReader { slice, virt_addr }
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ pub struct DwarfWriter<'a> {
|
|||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DwarfWriter<'a> {
|
impl DwarfWriter<'_> {
|
||||||
pub fn new(slice: &mut [u8]) -> DwarfWriter {
|
pub fn new(slice: &mut [u8]) -> DwarfWriter {
|
||||||
DwarfWriter { slice, offset: 0 }
|
DwarfWriter { slice, offset: 0 }
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ pub struct FDE_Records<'a> {
|
|||||||
available: usize,
|
available: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for FDE_Records<'a> {
|
impl Iterator for FDE_Records<'_> {
|
||||||
type Item = (u32, u32);
|
type Item = (u32, u32);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@ -423,7 +423,7 @@ pub struct EH_Frame_Hdr<'a> {
|
|||||||
fdes: Vec<(u32, u32)>,
|
fdes: Vec<(u32, u32)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EH_Frame_Hdr<'a> {
|
impl EH_Frame_Hdr<'_> {
|
||||||
/// Create a [EH_Frame_Hdr] object, and write out the fixed fields of `.eh_frame_hdr` to memory.
|
/// Create a [EH_Frame_Hdr] object, and write out the fixed fields of `.eh_frame_hdr` to memory.
|
||||||
///
|
///
|
||||||
/// Load address is not known at this point.
|
/// Load address is not known at this point.
|
||||||
|
@ -159,7 +159,7 @@ struct SymbolTableReader<'a> {
|
|||||||
strtab: &'a [u8],
|
strtab: &'a [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SymbolTableReader<'a> {
|
impl SymbolTableReader<'_> {
|
||||||
pub fn find_index_by_name(&self, sym_name: &[u8]) -> Option<usize> {
|
pub fn find_index_by_name(&self, sym_name: &[u8]) -> Option<usize> {
|
||||||
self.symtab.iter().position(|sym| {
|
self.symtab.iter().position(|sym| {
|
||||||
if let Ok(dynsym_name) = name_starting_at_slice(self.strtab, sym.st_name as usize) {
|
if let Ok(dynsym_name) = name_starting_at_slice(self.strtab, sym.st_name as usize) {
|
||||||
|
Loading…
Reference in New Issue
Block a user