forked from M-Labs/nac3
1
0
Fork 0

fix warnings

This commit is contained in:
ychenfo 2022-03-26 18:52:08 +08:00
parent 1ad4b0227c
commit 26a4834254
7 changed files with 17 additions and 17 deletions

View File

@ -990,7 +990,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>(
.map(|x| {
generator
.gen_expr(ctx, x)
.map_or_else(|e| Err(e), |v| v.unwrap().to_basic_value_enum(ctx, generator))
.map_or_else(Err, |v| v.unwrap().to_basic_value_enum(ctx, generator))
})
.collect::<Result<Vec<_>, _>>()?;
let ty = if elements.is_empty() {
@ -1023,7 +1023,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>(
.map(|x| {
generator
.gen_expr(ctx, x)
.map_or_else(|e| Err(e), |v| v.unwrap().to_basic_value_enum(ctx, generator))
.map_or_else(Err, |v| v.unwrap().to_basic_value_enum(ctx, generator))
})
.collect::<Result<Vec<_>, _>>()?;
let element_ty = element_val.iter().map(BasicValueEnum::get_type).collect_vec();
@ -1051,7 +1051,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>(
v.into_pointer_value(),
&[zero, int32.const_int(index as u64, false)],
))) as Result<_, String>
}, |v| Ok(v))?,
}, Ok)?,
ValueEnum::Dynamic(v) => {
let index = ctx.get_attr_index(value.custom.unwrap(), *attr);
ValueEnum::Dynamic(ctx.build_gep_and_load(

View File

@ -71,7 +71,7 @@ impl SymbolResolver for Resolver {
unimplemented!()
}
fn get_exception_id(&self, tyid: usize) -> usize {
fn get_exception_id(&self, _tyid: usize) -> usize {
unimplemented!()
}
}

View File

@ -263,7 +263,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
instance_to_stmt: Default::default(),
resolver: None,
codegen_callback: Some(Arc::new(GenCall::new(Box::new(
|ctx, obj, _, _, generator| {
|_, _, _, _, _| {
unreachable!("handled in gen_expr")
},
)))),

View File

@ -91,7 +91,7 @@ impl TopLevelComposer {
assert!(name == *simple_name);
builtin_ty.insert(name, *signature);
builtin_id.insert(name, DefinitionId(id));
} else if let TopLevelDef::Class { name, constructor, object_id, type_vars, .. } = &*def
} else if let TopLevelDef::Class { name, constructor, object_id, .. } = &*def
{
assert!(id == object_id.0);
if let Some(constructor) = constructor {

View File

@ -65,14 +65,14 @@ impl SymbolResolver for Resolver {
}
fn get_identifier_def(&self, id: StrRef) -> Result<DefinitionId, String> {
self.0.id_to_def.lock().get(&id).cloned().ok_or("Unknown identifier".to_string())
self.0.id_to_def.lock().get(&id).cloned().ok_or_else(|| "Unknown identifier".to_string())
}
fn get_string_id(&self, _: &str) -> i32 {
unimplemented!()
}
fn get_exception_id(&self, tyid: usize) -> usize {
fn get_exception_id(&self, _tyid: usize) -> usize {
unimplemented!()
}
}

View File

@ -44,14 +44,14 @@ impl SymbolResolver for Resolver {
}
fn get_identifier_def(&self, id: StrRef) -> Result<DefinitionId, String> {
self.id_to_def.get(&id).cloned().ok_or("Unknown identifier".to_string())
self.id_to_def.get(&id).cloned().ok_or_else(|| "Unknown identifier".to_string())
}
fn get_string_id(&self, _: &str) -> i32 {
unimplemented!()
}
fn get_exception_id(&self, tyid: usize) -> usize {
fn get_exception_id(&self, _tyid: usize) -> usize {
unimplemented!()
}
}

View File

@ -121,7 +121,7 @@ mod tests {
#[test]
fn test_parse_lambda() {
let source = "lambda x, y: x * y"; // lambda(x, y): x * y";
let parse_ast = parse_program(&source, Default::default()).unwrap();
let parse_ast = parse_program(source, Default::default()).unwrap();
insta::assert_debug_snapshot!(parse_ast);
}
@ -129,7 +129,7 @@ mod tests {
fn test_parse_tuples() {
let source = "a, b = 4, 5";
insta::assert_debug_snapshot!(parse_program(&source, Default::default()).unwrap());
insta::assert_debug_snapshot!(parse_program(source, Default::default()).unwrap());
}
#[test]
@ -140,7 +140,7 @@ class Foo(A, B):
pass
def method_with_default(self, arg='default'):
pass";
insta::assert_debug_snapshot!(parse_program(&source, Default::default()).unwrap());
insta::assert_debug_snapshot!(parse_program(source, Default::default()).unwrap());
}
#[test]
@ -183,7 +183,7 @@ while i < 2: # nac3: 4
# nac3: if1
if 1: # nac3: if2
3";
insta::assert_debug_snapshot!(parse_program(&source, Default::default()).unwrap());
insta::assert_debug_snapshot!(parse_program(source, Default::default()).unwrap());
}
#[test]
@ -196,7 +196,7 @@ while test: # nac3: while3
# nac3: simple assign0
a = 3 # nac3: simple assign1
";
insta::assert_debug_snapshot!(parse_program(&source, Default::default()).unwrap());
insta::assert_debug_snapshot!(parse_program(source, Default::default()).unwrap());
}
#[test]
@ -215,7 +215,7 @@ if a: # nac3: small2
for i in a: # nac3: for1
pass
";
insta::assert_debug_snapshot!(parse_program(&source, Default::default()).unwrap());
insta::assert_debug_snapshot!(parse_program(source, Default::default()).unwrap());
}
#[test]
@ -224,6 +224,6 @@ for i in a: # nac3: for1
if a: # nac3: something
a = 3
";
assert!(parse_program(&source, Default::default()).is_err());
assert!(parse_program(source, Default::default()).is_err());
}
}