core: Apply clippy suggestions

This commit is contained in:
David Mak 2024-03-11 14:25:37 +08:00
parent c8866b1534
commit fd44ee6887
4 changed files with 6 additions and 4 deletions
nac3core
build.rs
src/typecheck/typedef
nac3standalone/src

View File

@ -21,7 +21,7 @@ fn main() {
match env::var("PROFILE").as_deref() { match env::var("PROFILE").as_deref() {
Ok("debug") => "-O0", Ok("debug") => "-O0",
Ok("release") => "-O3", Ok("release") => "-O3",
flavor => panic!("Unknown or missing build flavor {:?}", flavor), flavor => panic!("Unknown or missing build flavor {flavor:?}"),
}, },
"-emit-llvm", "-emit-llvm",
"-S", "-S",

View File

@ -699,7 +699,7 @@ impl Unifier {
self.set_a_to_b(a, x); self.set_a_to_b(a, x);
} }
(TVar { fields: Some(fields), range, is_const_generic: false, .. }, TTuple { ty }) => { (TVar { fields: Some(fields), range, is_const_generic: false, .. }, TTuple { ty }) => {
let len = ty.len() as i32; let len = i32::try_from(ty.len()).unwrap();
for (k, v) in fields { for (k, v) in fields {
match *k { match *k {
RecordKey::Int(i) => { RecordKey::Int(i) => {

View File

@ -74,7 +74,8 @@ impl SymbolResolver for Resolver {
if let Some(id) = str_store.get(s) { if let Some(id) = str_store.get(s) {
*id *id
} else { } else {
let id = str_store.len() as i32; let id = i32::try_from(str_store.len())
.expect("Symbol resolver string store size exceeds max capacity (i32::MAX)");
str_store.insert(s.to_string(), id); str_store.insert(s.to_string(), id);
id id
} }

View File

@ -247,6 +247,8 @@ fn handle_assignment_pattern(
} }
fn main() { fn main() {
const SIZE_T: u32 = usize::BITS;
let cli = CommandLineArgs::parse(); let cli = CommandLineArgs::parse();
let CommandLineArgs { let CommandLineArgs {
file_name, file_name,
@ -287,7 +289,6 @@ fn main() {
// The default behavior for -O<n> where n>3 defaults to O3 for both Clang and GCC // The default behavior for -O<n> where n>3 defaults to O3 for both Clang and GCC
_ => OptimizationLevel::Aggressive, _ => OptimizationLevel::Aggressive,
}; };
const SIZE_T: u32 = 64;
let program = match fs::read_to_string(file_name.clone()) { let program = match fs::read_to_string(file_name.clone()) {
Ok(program) => program, Ok(program) => program,