Skip to content

Commit 486fe3d

Browse files
committed
Fix clippy
1 parent 3202a32 commit 486fe3d

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
clippy:
2-
@cargo clippy
2+
@cargo clippy -- -D warnings
33

44
check:
55
@cargo check
66

77
release:
88
@cargo build --release
9-
9+
1010
fmt:
1111
@cargo +nightly fmt
1212

@@ -29,7 +29,7 @@ cover:
2929

3030
tst:
3131
@cargo test test_codegen_variable_let_and_print -- --nocapture
32-
32+
3333
x: release
3434
@target/release/i-lang tst.i
35-
@ls -la build
35+
@ls -la build

src/codegen/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub enum CodegenError {
3737
}
3838

3939
/// Codegen structure
40+
#[allow(dead_code)]
4041
#[derive(Debug, Clone)]
4142
pub struct Codegen<'a> {
4243
ctx: Context,
@@ -48,6 +49,7 @@ pub struct Codegen<'a> {
4849
ast: &'a Main<'a>,
4950
}
5051

52+
#[allow(dead_code)]
5153
#[derive(Debug, Clone)]
5254
pub struct FunctionDeclaration {
5355
name: String,
@@ -587,6 +589,7 @@ impl<'a> Codegen<'a> {
587589
pub fn fn_main(ast: &'a Main) -> Result {
588590
#[cfg(feature = "fn_main")]
589591
println!("\t#[call] fn_main");
592+
590593
let mut codegen = Self::new(ast);
591594
let module = codegen.fn_module()?;
592595
let global_let = codegen.fn_global_let()?;

src/compiler/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn ar_builder(app_name: String, build_dir: &str) -> Result<(), String> {
7979
let a_file_name = format!("{}/lib{}.a", build_dir, app_name);
8080

8181
Command::new("ar")
82-
.args(&["crs", &a_file_name, &obj_file_name])
82+
.args(["crs", &a_file_name, &obj_file_name])
8383
.spawn()
8484
.map_err(|_| "Failed to run `ar` command".to_string())?
8585
.wait()
@@ -95,7 +95,7 @@ pub fn ld_builder(app_name: String, build_dir: &str) -> Result<(), String> {
9595
let obj_file = Path::new(&obj_file_name);
9696

9797
Command::new("ld")
98-
.args(&[
98+
.args([
9999
"-o",
100100
&app_file_name,
101101
"-dynamic-linker",
@@ -121,7 +121,7 @@ pub fn gcc_builder(app_name: String, build_dir: &str) -> Result<(), String> {
121121
let obj_file = Path::new(&obj_file_name);
122122

123123
Command::new("gcc")
124-
.args(&["-o", &app_file_name, &a_file_name])
124+
.args(["-o", &app_file_name, &a_file_name])
125125
.spawn()
126126
.map_err(|_| "Failed to run `gcc` command".to_string())?
127127
.wait()

src/llvm/macros.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#[macro_export]
1313
macro_rules! alloca {
1414
($ty:ident $res:expr) => {
15-
crate::llvm::instructions::memory_access_addressing_operations::Alloca {
15+
$crate::llvm::instructions::memory_access_addressing_operations::Alloca {
1616
result: $res.to_string(),
1717
alloc_ty: $ty,
1818
elements: None,
@@ -22,7 +22,7 @@ macro_rules! alloca {
2222
}
2323
};
2424
($ty:ident $res:expr, $align:expr) => {
25-
crate::llvm::instructions::memory_access_addressing_operations::Alloca {
25+
$crate::llvm::instructions::memory_access_addressing_operations::Alloca {
2626
result: $res.to_string(),
2727
alloc_ty: $ty,
2828
elements: None,
@@ -50,13 +50,13 @@ macro_rules! alloca {
5050
macro_rules! arg {
5151
($($ty:ident $val:expr)? $(,$ty1:ident $val1:expr)*) => {{
5252
let mut v = vec![];
53-
$( v.push(crate::llvm::functions::ArgumentList {
53+
$( v.push($crate::llvm::functions::ArgumentList {
5454
parameter_type: Some($ty),
5555
attributes: None,
5656
name: Some(format!("%{}", $val)),
5757
variable_argument: false,
5858
});)?
59-
$( v.push(crate::llvm::functions::ArgumentList {
59+
$( v.push($crate::llvm::functions::ArgumentList {
6060
parameter_type: Some($ty1),
6161
attributes: None,
6262
name: Some(format!("%{}", $val1)),
@@ -66,19 +66,19 @@ macro_rules! arg {
6666
}};
6767
($($ty:ident $val:expr)? $(,$ty1:ident $val1:expr)*, ...) => {{
6868
let mut v = vec![];
69-
$( v.push(crate::llvm::functions::ArgumentList {
69+
$( v.push($crate::llvm::functions::ArgumentList {
7070
parameter_type: Some($ty),
7171
attributes: None,
7272
name: Some(format!("%{}", $val)),
7373
variable_argument: false,
7474
});)?
75-
$( v.push(crate::llvm::functions::ArgumentList {
75+
$( v.push($crate::llvm::functions::ArgumentList {
7676
parameter_type: Some($ty1),
7777
attributes: None,
7878
name: Some(format!("%{}", $val1)),
7979
variable_argument: false,
8080
});)*
81-
v.push(crate::llvm::functions::ArgumentList {
81+
v.push($crate::llvm::functions::ArgumentList {
8282
parameter_type: None,
8383
attributes: None,
8484
name: None,
@@ -88,13 +88,13 @@ macro_rules! arg {
8888
}};
8989
($($ty:ident)? $(,$ty1:ident)*) => {{
9090
let mut v = vec![];
91-
$( v.push(crate::llvm::functions::ArgumentList {
91+
$( v.push($crate::llvm::functions::ArgumentList {
9292
parameter_type: Some($ty),
9393
attributes: None,
9494
name: None,
9595
variable_argument: false,
9696
});)?
97-
$( v.push(crate::llvm::functions::ArgumentList {
97+
$( v.push($crate::llvm::functions::ArgumentList {
9898
parameter_type: Some($ty1),
9999
attributes: None,
100100
name: None,
@@ -104,19 +104,19 @@ macro_rules! arg {
104104
}};
105105
($($ty:ident)? $(,$ty1:ident)*, ...) => {{
106106
let mut v = vec![];
107-
$( v.push(crate::llvm::functions::ArgumentList {
107+
$( v.push($crate::llvm::functions::ArgumentList {
108108
parameter_type: Some($ty),
109109
attributes: None,
110110
name: None,
111111
variable_argument: false,
112112
});)?
113-
$( v.push(crate::llvm::functions::ArgumentList {
113+
$( v.push($crate::llvm::functions::ArgumentList {
114114
parameter_type: Some($ty1),
115115
attributes: None,
116116
name: None,
117117
variable_argument: false,
118118
});)*
119-
v.push(crate::llvm::functions::ArgumentList {
119+
v.push($crate::llvm::functions::ArgumentList {
120120
parameter_type: None,
121121
attributes: None,
122122
name: None,
@@ -146,15 +146,15 @@ macro_rules! def {
146146
$fnval.$attr = Some($val);
147147
}};
148148
($ty:ident $name:ident) => {{
149-
crate::llvm::functions::Function {
150-
definition_type: crate::llvm::functions::FunctionDefinitionType::Define,
149+
$crate::llvm::functions::Function {
150+
definition_type: $crate::llvm::functions::FunctionDefinitionType::Define,
151151
linkage: None,
152152
preemption_specifier: None,
153153
visibility: None,
154154
dll_storage_class: None,
155155
cconv: None,
156156
ret_attrs: None,
157-
result_type: crate::llvm::types::Type::$ty,
157+
result_type: $crate::llvm::types::Type::$ty,
158158
function_name: $name.to_string(),
159159
argument_list: vec![],
160160
unnamed_addr: None,
@@ -194,7 +194,7 @@ macro_rules! decl {
194194
}};
195195
($ty:ident $name:ident) => {{
196196
let mut f_decl = def!($ty $name);
197-
let d = crate::llvm::functions::FunctionDefinitionType::Declare;
197+
let d = $crate::llvm::functions::FunctionDefinitionType::Declare;
198198
def!(f_decl.definition_type d);
199199
f_decl
200200
}};
@@ -209,7 +209,7 @@ macro_rules! decl {
209209
#[macro_export]
210210
macro_rules! source_file {
211211
($name:expr) => {
212-
crate::llvm::source_filename::SourceFileName($name.to_string());
212+
$crate::llvm::source_filename::SourceFileName($name.to_string())
213213
};
214214
}
215215

@@ -222,7 +222,7 @@ macro_rules! source_file {
222222
#[macro_export]
223223
macro_rules! target_triple {
224224
($name:ident) => {
225-
crate::llvm::target_triple::TargetTriple(crate::llvm::target_triple::$name.to_string());
225+
$crate::llvm::target_triple::TargetTriple($crate::llvm::target_triple::$name.to_string())
226226
};
227227
}
228228

@@ -249,7 +249,7 @@ macro_rules! global {
249249
$var.$attr = Some($val);
250250
}};
251251
($kind:ident $ty:ident $name:expr) => {
252-
crate::llvm::global_variables::GlobalVariable {
252+
$crate::llvm::global_variables::GlobalVariable {
253253
name: $name.to_string(),
254254
linkage: None,
255255
preemption_specifier: None,
@@ -258,7 +258,7 @@ macro_rules! global {
258258
thread_local: None,
259259
unnamed_addr: None,
260260
addrspace: None,
261-
global_variable_kind: crate::llvm::global_variables::GlobalVariableKind::$kind,
261+
global_variable_kind: $crate::llvm::global_variables::GlobalVariableKind::$kind,
262262
value_type: $ty,
263263
initializer_constant: None,
264264
section: None,
@@ -286,7 +286,7 @@ macro_rules! store {
286286
$var.$attr = Some($val);
287287
}};
288288
($ty:ident $val:expr, $ptrval:expr) => {{
289-
crate::llvm::instructions::memory_access_addressing_operations::Store {
289+
$crate::llvm::instructions::memory_access_addressing_operations::Store {
290290
volatile: None,
291291
ty: $ty,
292292
value: $val.to_string(),
@@ -312,7 +312,7 @@ macro_rules! load {
312312
$var.$attr = Some($val);
313313
}};
314314
($ty:ident $res:expr, $ptrval:expr) => {{
315-
crate::llvm::instructions::memory_access_addressing_operations::Load {
315+
$crate::llvm::instructions::memory_access_addressing_operations::Load {
316316
result: $res.to_string(),
317317
volatile: None,
318318
ty: $ty,
@@ -336,10 +336,10 @@ macro_rules! load {
336336
#[macro_export]
337337
macro_rules! ret {
338338
($ty:ident @ $val:expr) => {{
339-
crate::llvm::instructions::terminator::Ret(Some(($ty, $val.to_string())))
339+
$crate::llvm::instructions::terminator::Ret(Some(($ty, $val.to_string())))
340340
}};
341341
() => {{
342-
crate::llvm::instructions::terminator::Ret(None)
342+
$crate::llvm::instructions::terminator::Ret(None)
343343
}};
344344
}
345345

@@ -436,12 +436,12 @@ macro_rules! call {
436436
)?
437437

438438
#[allow(unused_mut)]
439-
let mut args: Vec< crate::llvm::instructions::terminator::FunctionArg> = vec![];
439+
let mut args: Vec< $crate::llvm::instructions::terminator::FunctionArg> = vec![];
440440
$(
441-
args.push(crate::llvm::instructions::terminator::FunctionArg($argty1, $argval1));
441+
args.push($crate::llvm::instructions::terminator::FunctionArg($argty1, $argval1));
442442
)?
443443
$(
444-
args.push(crate::llvm::instructions::terminator::FunctionArg($argty2, $argval2));
444+
args.push($crate::llvm::instructions::terminator::FunctionArg($argty2, $argval2));
445445
)*
446446

447447
Call {

src/parser/ast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::derive_partial_eq_without_eq)]
12
//! Full AST representation
23
//!
34
//! Based on *EBNF* grammar

0 commit comments

Comments
 (0)