From 06e9d90d575b34fe74e1c73fe317ed068d2e0e1e Mon Sep 17 00:00:00 2001 From: lyken Date: Fri, 21 Jun 2024 14:14:01 +0800 Subject: [PATCH] apply clippy changes --- nac3artiq/src/codegen.rs | 2 +- nac3core/src/codegen/expr.rs | 2 +- nac3core/src/codegen/mod.rs | 19 +++++++++---------- nac3core/src/symbol_resolver.rs | 4 ++-- nac3core/src/toplevel/mod.rs | 2 +- .../src/typecheck/type_inferencer/test.rs | 4 ++-- nac3core/src/typecheck/typedef/mod.rs | 2 +- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 7e64dc1d..7dcecff8 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -65,7 +65,7 @@ pub struct ArtiqCodeGenerator<'a> { end: Option>>, timeline: &'a (dyn TimeFns + Sync), - /// The [ParallelMode] of the current parallel context. + /// The [`ParallelMode`] of the current parallel context. /// /// The current parallel context refers to the nearest `with parallel` or `with legacy_parallel` /// statement, which is used to determine when and how the timeline should be updated. diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 3c5d0a3d..a8430e29 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -764,7 +764,7 @@ pub fn gen_call<'ctx, G: CodeGenerator>( } // default value handling for k in keys { - if mapping.get(&k.name).is_some() { + if mapping.contains_key(&k.name) { continue; } mapping.insert( diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index 517c5c9c..1103039d 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -135,24 +135,23 @@ pub struct CodeGenContext<'ctx, 'a> { /// The [Builder] instance for creating LLVM IR statements. pub builder: Builder<'ctx>, - /// The [DebugInfoBuilder], [compilation unit information][DICompileUnit], and + /// The [`DebugInfoBuilder`], [compilation unit information][DICompileUnit], and /// [scope information][DIScope] of this context. pub debug_info: (DebugInfoBuilder<'ctx>, DICompileUnit<'ctx>, DIScope<'ctx>), /// The module for which [this context][CodeGenContext] is generating into. pub module: Module<'ctx>, - /// The [TopLevelContext] associated with [this context][CodeGenContext]. + /// The [`TopLevelContext`] associated with [this context][CodeGenContext]. pub top_level: &'a TopLevelContext, pub unifier: Unifier, pub resolver: Arc, pub static_value_store: Arc>, - /// A [HashMap] containing the mapping between the names of variables currently in-scope and + /// A [`HashMap`] containing the mapping between the names of variables currently in-scope and /// its value information. pub var_assignment: HashMap>, - /// pub type_cache: HashMap>, pub primitives: PrimitiveStore, pub calls: Arc>, @@ -161,24 +160,24 @@ pub struct CodeGenContext<'ctx, 'a> { /// Cache for constant strings. pub const_strings: HashMap>, - /// [BasicBlock] containing all `alloca` statements for the current function. + /// [`BasicBlock`] containing all `alloca` statements for the current function. pub init_bb: BasicBlock<'ctx>, pub exception_val: Option>, /// The header and exit basic blocks of a loop in this context. See - /// https://llvm.org/docs/LoopTerminology.html for explanation of these terminology. + /// for explanation of these terminology. pub loop_target: Option<(BasicBlock<'ctx>, BasicBlock<'ctx>)>, - /// The target [BasicBlock] to jump to when performing stack unwind. + /// The target [`BasicBlock`] to jump to when performing stack unwind. pub unwind_target: Option>, - /// The target [BasicBlock] to jump to before returning from the function. + /// The target [`BasicBlock`] to jump to before returning from the function. /// /// If this field is [None] when generating a return from a function, `ret` with no argument can /// be emitted. pub return_target: Option>, - /// The [PointerValue] containing the return value of the function. + /// The [`PointerValue`] containing the return value of the function. pub return_buffer: Option>, // outer catch clauses @@ -187,7 +186,7 @@ pub struct CodeGenContext<'ctx, 'a> { /// Whether `sret` is needed for the first parameter of the function. /// - /// See [need_sret]. + /// See [`need_sret`]. pub need_sret: bool, /// The current source location. diff --git a/nac3core/src/symbol_resolver.rs b/nac3core/src/symbol_resolver.rs index 9e42a8ce..753cc076 100644 --- a/nac3core/src/symbol_resolver.rs +++ b/nac3core/src/symbol_resolver.rs @@ -296,10 +296,10 @@ pub trait StaticValue { #[derive(Clone)] pub enum ValueEnum<'ctx> { - /// [ValueEnum] representing a static value. + /// [`ValueEnum`] representing a static value. Static(Arc), - /// [ValueEnum] representing a dynamic value. + /// [`ValueEnum`] representing a dynamic value. Dynamic(BasicValueEnum<'ctx>), } diff --git a/nac3core/src/toplevel/mod.rs b/nac3core/src/toplevel/mod.rs index c08f287f..d3fc45cf 100644 --- a/nac3core/src/toplevel/mod.rs +++ b/nac3core/src/toplevel/mod.rs @@ -95,7 +95,7 @@ pub enum TopLevelDef { Class { /// Name for error messages and symbols. name: StrRef, - /// Object ID used for [TypeEnum]. + /// Object ID used for [`TypeEnum`]. object_id: DefinitionId, /// type variables bounded to the class. type_vars: Vec, diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs index 700ce509..a6150b48 100644 --- a/nac3core/src/typecheck/type_inferencer/test.rs +++ b/nac3core/src/typecheck/type_inferencer/test.rs @@ -549,7 +549,7 @@ fn test_basic(source: &str, mapping: &HashMap<&str, &str>, virtuals: &[(&str, &s let mut defined_identifiers: HashSet<_> = env.identifier_mapping.keys().copied().collect(); defined_identifiers.insert("virtual".into()); let mut inferencer = env.get_inferencer(); - inferencer.defined_identifiers = defined_identifiers.clone(); + inferencer.defined_identifiers.clone_from(&defined_identifiers); let statements = parse_program(source, FileName::default()).unwrap(); let statements = statements .into_iter() @@ -695,7 +695,7 @@ fn test_primitive_magic_methods(source: &str, mapping: &HashMap<&str, &str>) { let mut defined_identifiers: HashSet<_> = env.identifier_mapping.keys().copied().collect(); defined_identifiers.insert("virtual".into()); let mut inferencer = env.get_inferencer(); - inferencer.defined_identifiers = defined_identifiers.clone(); + inferencer.defined_identifiers.clone_from(&defined_identifiers); let statements = parse_program(source, FileName::default()).unwrap(); let statements = statements .into_iter() diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index 31a6859f..ae31168f 100644 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -208,7 +208,7 @@ pub enum TypeEnum { /// An object type. TObj { - /// The [DefintionId] of this object type. + /// The [`DefinitionId`] of this object type. obj_id: DefinitionId, /// The fields present in this object type.