From 5182453bd988674c5e546c43c2b779b22c18e53c Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 26 Oct 2023 13:52:40 +0800 Subject: [PATCH] meta: Remove redundant path prefixes --- nac3artiq/src/codegen.rs | 2 +- nac3artiq/src/lib.rs | 22 ++++---- nac3core/build.rs | 2 +- nac3core/src/codegen/expr.rs | 4 +- nac3core/src/codegen/irrt/mod.rs | 4 +- nac3core/src/codegen/mod.rs | 4 +- nac3core/src/symbol_resolver.rs | 2 +- nac3core/src/toplevel/builtins.rs | 2 +- nac3core/src/toplevel/composer.rs | 6 +-- nac3core/src/toplevel/helper.rs | 2 +- nac3core/src/toplevel/test.rs | 2 +- nac3core/src/typecheck/function_check.rs | 2 +- nac3core/src/typecheck/magic_methods.rs | 32 ++++++------ nac3core/src/typecheck/type_inferencer/mod.rs | 52 +++++++++---------- .../src/typecheck/type_inferencer/test.rs | 4 +- nac3core/src/typecheck/typedef/mod.rs | 8 +-- nac3core/src/typecheck/typedef/test.rs | 4 +- nac3ld/src/lib.rs | 4 +- nac3parser/src/lexer.rs | 4 +- 19 files changed, 81 insertions(+), 81 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index aad058849..94860e472 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -413,7 +413,7 @@ fn rpc_codegen_callback_fn<'ctx, 'a>( args: Vec<(Option, ValueEnum<'ctx>)>, generator: &mut dyn CodeGenerator, ) -> Result>, String> { - let ptr_type = ctx.ctx.i8_type().ptr_type(inkwell::AddressSpace::default()); + let ptr_type = ctx.ctx.i8_type().ptr_type(AddressSpace::default()); let size_type = generator.get_size_type(ctx.ctx); let int8 = ctx.ctx.i8_type(); let int32 = ctx.ctx.i32_type(); diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 29b65ed94..d688cdcc7 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -17,8 +17,8 @@ use nac3core::codegen::{CodeGenLLVMOptions, CodeGenTargetMachineOptions, gen_fun use nac3core::toplevel::builtins::get_exn_constructor; use nac3core::typecheck::typedef::{TypeEnum, Unifier}; use nac3parser::{ - ast::{self, ExprKind, Stmt, StmtKind, StrRef}, - parser::{self, parse_program}, + ast::{ExprKind, Stmt, StmtKind, StrRef}, + parser::parse_program, }; use pyo3::prelude::*; use pyo3::{exceptions, types::PyBytes, types::PyDict, types::PySet}; @@ -120,16 +120,16 @@ impl Nac3 { let source = fs::read_to_string(&source_file).map_err(|e| { exceptions::PyIOError::new_err(format!("failed to read input file: {}", e)) })?; - let parser_result = parser::parse_program(&source, source_file.into()) + let parser_result = parse_program(&source, source_file.into()) .map_err(|e| exceptions::PySyntaxError::new_err(format!("parse error: {}", e)))?; for mut stmt in parser_result.into_iter() { let include = match stmt.node { - ast::StmtKind::ClassDef { + StmtKind::ClassDef { ref decorator_list, ref mut body, ref mut bases, .. } => { let nac3_class = decorator_list.iter().any(|decorator| { - if let ast::ExprKind::Name { id, .. } = decorator.node { + if let ExprKind::Name { id, .. } = decorator.node { id.to_string() == "nac3" } else { false @@ -143,7 +143,7 @@ impl Nac3 { Python::with_gil(|py| -> PyResult { let id_fn = PyModule::import(py, "builtins")?.getattr("id")?; match &base.node { - ast::ExprKind::Name { id, .. } => { + ExprKind::Name { id, .. } => { if *id == "Exception".into() { Ok(true) } else { @@ -158,9 +158,9 @@ impl Nac3 { .unwrap() }); body.retain(|stmt| { - if let ast::StmtKind::FunctionDef { ref decorator_list, .. } = stmt.node { + if let StmtKind::FunctionDef { ref decorator_list, .. } = stmt.node { decorator_list.iter().any(|decorator| { - if let ast::ExprKind::Name { id, .. } = decorator.node { + if let ExprKind::Name { id, .. } = decorator.node { id.to_string() == "kernel" || id.to_string() == "portable" || id.to_string() == "rpc" @@ -174,9 +174,9 @@ impl Nac3 { }); true } - ast::StmtKind::FunctionDef { ref decorator_list, .. } => { + StmtKind::FunctionDef { ref decorator_list, .. } => { decorator_list.iter().any(|decorator| { - if let ast::ExprKind::Name { id, .. } = decorator.node { + if let ExprKind::Name { id, .. } = decorator.node { let id = id.to_string(); id == "extern" || id == "portable" || id == "kernel" || id == "rpc" } else { @@ -639,7 +639,7 @@ impl Nac3 { let mut function_iter = main.get_first_function(); while let Some(func) = function_iter { if func.count_basic_blocks() > 0 && func.get_name().to_str().unwrap() != "__modinit__" { - func.set_linkage(inkwell::module::Linkage::Private); + func.set_linkage(Linkage::Private); } function_iter = func.get_next_function(); } diff --git a/nac3core/build.rs b/nac3core/build.rs index fb9f473fb..c747274bd 100644 --- a/nac3core/build.rs +++ b/nac3core/build.rs @@ -42,7 +42,7 @@ fn main() { let output = std::str::from_utf8(&output.stdout).unwrap().replace("\r\n", "\n"); let mut filtered_output = String::with_capacity(output.len()); - let regex_filter = regex::Regex::new(r"(?ms:^define.*?\}$)|(?m:^declare.*?$)").unwrap(); + let regex_filter = Regex::new(r"(?ms:^define.*?\}$)|(?m:^declare.*?$)").unwrap(); for f in regex_filter.captures_iter(&output) { assert!(f.len() == 1); filtered_output.push_str(&f[0]); diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index ec6e560a1..431851416 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -499,7 +499,7 @@ impl<'ctx, 'a> CodeGenContext<'ctx, 'a> { generator: &mut dyn CodeGenerator, s: S, ) -> BasicValueEnum<'ctx> { - self.gen_const(generator, &nac3parser::ast::Constant::Str(s.into()), self.primitives.str).unwrap() + self.gen_const(generator, &Constant::Str(s.into()), self.primitives.str).unwrap() } pub fn raise_exn( @@ -1860,7 +1860,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( } } else if let TypeEnum::TTuple { .. } = &*ctx.unifier.get_ty(value.custom.unwrap()) { let index: u32 = - if let ExprKind::Constant { value: ast::Constant::Int(v), .. } = &slice.node { + if let ExprKind::Constant { value: Constant::Int(v), .. } = &slice.node { (*v).try_into().unwrap() } else { unreachable!("tuple subscript must be const int after type check"); diff --git a/nac3core/src/codegen/irrt/mod.rs b/nac3core/src/codegen/irrt/mod.rs index 6251ea934..074c1698f 100644 --- a/nac3core/src/codegen/irrt/mod.rs +++ b/nac3core/src/codegen/irrt/mod.rs @@ -348,7 +348,7 @@ pub fn list_slice_assignment<'ctx, 'a>( let src_end = ctx.builder .build_select( ctx.builder.build_int_compare( - inkwell::IntPredicate::SLT, + IntPredicate::SLT, src_idx.2, zero, "is_neg", @@ -361,7 +361,7 @@ pub fn list_slice_assignment<'ctx, 'a>( let dest_end = ctx.builder .build_select( ctx.builder.build_int_compare( - inkwell::IntPredicate::SLT, + IntPredicate::SLT, dest_idx.2, zero, "is_neg", diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index ae12b3472..f11cce986 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -383,8 +383,8 @@ fn get_llvm_type<'ctx>( match (unifier.get_ty(ty).as_ref(), unifier.get_ty(primitives.option).as_ref()) { ( - TypeEnum::TObj { obj_id, params, .. }, - TypeEnum::TObj { obj_id: opt_id, .. }, + TObj { obj_id, params, .. }, + TObj { obj_id: opt_id, .. }, ) if *obj_id == *opt_id => { return get_llvm_type( ctx, diff --git a/nac3core/src/symbol_resolver.rs b/nac3core/src/symbol_resolver.rs index dff3271f9..b89c50aba 100644 --- a/nac3core/src/symbol_resolver.rs +++ b/nac3core/src/symbol_resolver.rs @@ -298,7 +298,7 @@ pub trait SymbolResolver { ctx: &mut CodeGenContext<'ctx, 'a>, ) -> Option>; - fn get_default_param_value(&self, expr: &nac3parser::ast::Expr) -> Option; + fn get_default_param_value(&self, expr: &Expr) -> Option; fn get_string_id(&self, s: &str) -> i32; fn get_exception_id(&self, tyid: usize) -> usize; diff --git a/nac3core/src/toplevel/builtins.rs b/nac3core/src/toplevel/builtins.rs index 24bdc05be..b0648eebc 100644 --- a/nac3core/src/toplevel/builtins.rs +++ b/nac3core/src/toplevel/builtins.rs @@ -1904,7 +1904,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo { })), ]; - let ast_list: Vec>> = + let ast_list: Vec>> = (0..top_level_def_list.len()).map(|_| None).collect(); izip!(top_level_def_list, ast_list).collect_vec() diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 683d9119f..e9e032eb8 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -20,7 +20,7 @@ impl Default for ComposerConfig { } } -type DefAst = (Arc>, Option>); +type DefAst = (Arc>, Option>); pub struct TopLevelComposer { // list of top level definitions, same as top level context pub definition_ast_list: Vec, @@ -175,7 +175,7 @@ impl TopLevelComposer { /// and check duplicate class/method/function definition pub fn register_top_level( &mut self, - ast: ast::Stmt<()>, + ast: Stmt<()>, resolver: Option>, mod_path: String, allow_no_constructor: bool, @@ -230,7 +230,7 @@ impl TopLevelComposer { Arc>, DefinitionId, Type, - ast::Stmt<()>, + Stmt<()>, ); let mut class_method_name_def_ids: Vec = Vec::new(); // we do not push anything to the def list, so we keep track of the index diff --git a/nac3core/src/toplevel/helper.rs b/nac3core/src/toplevel/helper.rs index 014996a62..b7f60802e 100644 --- a/nac3core/src/toplevel/helper.rs +++ b/nac3core/src/toplevel/helper.rs @@ -334,7 +334,7 @@ impl TopLevelComposer { ) } - pub fn get_all_assigned_field(stmts: &[ast::Stmt<()>]) -> Result, String> { + pub fn get_all_assigned_field(stmts: &[Stmt<()>]) -> Result, String> { let mut result = HashSet::new(); for s in stmts { match &s.node { diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs index 55507d925..2b8b03ad2 100644 --- a/nac3core/src/toplevel/test.rs +++ b/nac3core/src/toplevel/test.rs @@ -36,7 +36,7 @@ struct Resolver(Arc); impl SymbolResolver for Resolver { fn get_default_param_value( &self, - _: &nac3parser::ast::Expr, + _: &ast::Expr, ) -> Option { unimplemented!() } diff --git a/nac3core/src/typecheck/function_check.rs b/nac3core/src/typecheck/function_check.rs index 6d8e1b2a7..b7e0e5b83 100644 --- a/nac3core/src/typecheck/function_check.rs +++ b/nac3core/src/typecheck/function_check.rs @@ -20,7 +20,7 @@ impl<'a> Inferencer<'a> { defined_identifiers: &mut HashSet, ) -> Result<(), String> { match &pattern.node { - ast::ExprKind::Name { id, .. } if id == &"none".into() => + ExprKind::Name { id, .. } if id == &"none".into() => Err(format!("cannot assign to a `none` (at {})", pattern.location)), ExprKind::Name { id, .. } => { if !defined_identifiers.contains(id) { diff --git a/nac3core/src/typecheck/magic_methods.rs b/nac3core/src/typecheck/magic_methods.rs index f8e1fcb63..0593cf6d5 100644 --- a/nac3core/src/typecheck/magic_methods.rs +++ b/nac3core/src/typecheck/magic_methods.rs @@ -2,7 +2,7 @@ use crate::typecheck::{ type_inferencer::*, typedef::{FunSignature, FuncArg, Type, TypeEnum, Unifier}, }; -use nac3parser::ast::{self, StrRef}; +use nac3parser::ast::StrRef; use nac3parser::ast::{Cmpop, Operator, Unaryop}; use std::collections::HashMap; use std::rc::Rc; @@ -87,7 +87,7 @@ pub fn impl_binop( ty: Type, other_ty: &[Type], ret_ty: Type, - ops: &[ast::Operator], + ops: &[Operator], ) { with_fields(unifier, ty, |unifier, fields| { let (other_ty, other_var_id) = if other_ty.len() == 1 { @@ -137,7 +137,7 @@ pub fn impl_binop( }); } -pub fn impl_unaryop(unifier: &mut Unifier, ty: Type, ret_ty: Type, ops: &[ast::Unaryop]) { +pub fn impl_unaryop(unifier: &mut Unifier, ty: Type, ret_ty: Type, ops: &[Unaryop]) { with_fields(unifier, ty, |unifier, fields| { for op in ops { fields.insert( @@ -160,7 +160,7 @@ pub fn impl_cmpop( store: &PrimitiveStore, ty: Type, other_ty: Type, - ops: &[ast::Cmpop], + ops: &[Cmpop], ) { with_fields(unifier, ty, |unifier, fields| { for op in ops { @@ -197,7 +197,7 @@ pub fn impl_basic_arithmetic( ty, other_ty, ret_ty, - &[ast::Operator::Add, ast::Operator::Sub, ast::Operator::Mult], + &[Operator::Add, Operator::Sub, Operator::Mult], ) } @@ -209,7 +209,7 @@ pub fn impl_pow( other_ty: &[Type], ret_ty: Type, ) { - impl_binop(unifier, store, ty, other_ty, ret_ty, &[ast::Operator::Pow]) + impl_binop(unifier, store, ty, other_ty, ret_ty, &[Operator::Pow]) } /// BitOr, BitXor, BitAnd @@ -220,18 +220,18 @@ pub fn impl_bitwise_arithmetic(unifier: &mut Unifier, store: &PrimitiveStore, ty ty, &[ty], ty, - &[ast::Operator::BitAnd, ast::Operator::BitOr, ast::Operator::BitXor], + &[Operator::BitAnd, Operator::BitOr, Operator::BitXor], ) } /// LShift, RShift pub fn impl_bitwise_shift(unifier: &mut Unifier, store: &PrimitiveStore, ty: Type) { - impl_binop(unifier, store, ty, &[store.int32, store.uint32], ty, &[ast::Operator::LShift, ast::Operator::RShift]); + impl_binop(unifier, store, ty, &[store.int32, store.uint32], ty, &[Operator::LShift, Operator::RShift]); } /// Div pub fn impl_div(unifier: &mut Unifier, store: &PrimitiveStore, ty: Type, other_ty: &[Type]) { - impl_binop(unifier, store, ty, other_ty, store.float, &[ast::Operator::Div]) + impl_binop(unifier, store, ty, other_ty, store.float, &[Operator::Div]) } /// FloorDiv @@ -242,7 +242,7 @@ pub fn impl_floordiv( other_ty: &[Type], ret_ty: Type, ) { - impl_binop(unifier, store, ty, other_ty, ret_ty, &[ast::Operator::FloorDiv]) + impl_binop(unifier, store, ty, other_ty, ret_ty, &[Operator::FloorDiv]) } /// Mod @@ -253,22 +253,22 @@ pub fn impl_mod( other_ty: &[Type], ret_ty: Type, ) { - impl_binop(unifier, store, ty, other_ty, ret_ty, &[ast::Operator::Mod]) + impl_binop(unifier, store, ty, other_ty, ret_ty, &[Operator::Mod]) } /// UAdd, USub pub fn impl_sign(unifier: &mut Unifier, _store: &PrimitiveStore, ty: Type) { - impl_unaryop(unifier, ty, ty, &[ast::Unaryop::UAdd, ast::Unaryop::USub]) + impl_unaryop(unifier, ty, ty, &[Unaryop::UAdd, Unaryop::USub]) } /// Invert pub fn impl_invert(unifier: &mut Unifier, _store: &PrimitiveStore, ty: Type) { - impl_unaryop(unifier, ty, ty, &[ast::Unaryop::Invert]) + impl_unaryop(unifier, ty, ty, &[Unaryop::Invert]) } /// Not pub fn impl_not(unifier: &mut Unifier, store: &PrimitiveStore, ty: Type) { - impl_unaryop(unifier, ty, store.bool, &[ast::Unaryop::Not]) + impl_unaryop(unifier, ty, store.bool, &[Unaryop::Not]) } /// Lt, LtE, Gt, GtE @@ -278,13 +278,13 @@ pub fn impl_comparison(unifier: &mut Unifier, store: &PrimitiveStore, ty: Type, store, ty, other_ty, - &[ast::Cmpop::Lt, ast::Cmpop::Gt, ast::Cmpop::LtE, ast::Cmpop::GtE], + &[Cmpop::Lt, Cmpop::Gt, Cmpop::LtE, Cmpop::GtE], ) } /// Eq, NotEq pub fn impl_eq(unifier: &mut Unifier, store: &PrimitiveStore, ty: Type) { - impl_cmpop(unifier, store, ty, ty, &[ast::Cmpop::Eq, ast::Cmpop::NotEq]) + impl_cmpop(unifier, store, ty, ty, &[Cmpop::Eq, Cmpop::NotEq]) } pub fn set_primitives_magic_methods(store: &PrimitiveStore, unifier: &mut Unifier) { diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index 60dea072b..322361114 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -62,7 +62,7 @@ pub struct Inferencer<'a> { } struct NaiveFolder(); -impl fold::Fold<()> for NaiveFolder { +impl Fold<()> for NaiveFolder { type TargetU = Option; type Error = String; fn map_user(&mut self, _: ()) -> Result { @@ -74,7 +74,7 @@ fn report_error(msg: &str, location: Location) -> Result { Err(format!("{} at {}", msg, location)) } -impl<'a> fold::Fold<()> for Inferencer<'a> { +impl<'a> Fold<()> for Inferencer<'a> { type TargetU = Option; type Error = String; @@ -231,14 +231,14 @@ impl<'a> fold::Fold<()> for Inferencer<'a> { *ctx = ExprContext::Store; } } - if targets.iter().all(|t| matches!(t.node, ast::ExprKind::Name { .. })) { + if targets.iter().all(|t| matches!(t.node, ExprKind::Name { .. })) { if let ast::StmtKind::Assign { targets, value, .. } = node.node { let value = self.fold_expr(*value)?; let value_ty = value.custom.unwrap(); let targets: Result, _> = targets .into_iter() .map(|target| { - if let ast::ExprKind::Name { id, ctx } = target.node { + if let ExprKind::Name { id, ctx } = target.node { self.defined_identifiers.insert(id); let target_ty = if let Some(ty) = self.variable_mapping.get(&id) { @@ -261,7 +261,7 @@ impl<'a> fold::Fold<()> for Inferencer<'a> { let location = target.location; self.unifier.unify(value_ty, target_ty).map(|_| Located { location, - node: ast::ExprKind::Name { id, ctx }, + node: ExprKind::Name { id, ctx }, custom: Some(target_ty), }) } else { @@ -440,22 +440,22 @@ impl<'a> fold::Fold<()> for Inferencer<'a> { fn fold_expr(&mut self, node: ast::Expr<()>) -> Result, Self::Error> { let expr = match node.node { - ast::ExprKind::Call { func, args, keywords } => { + ExprKind::Call { func, args, keywords } => { return self.fold_call(node.location, *func, args, keywords); } - ast::ExprKind::Lambda { args, body } => { + ExprKind::Lambda { args, body } => { return self.fold_lambda(node.location, *args, *body); } - ast::ExprKind::ListComp { elt, generators } => { + ExprKind::ListComp { elt, generators } => { return self.fold_listcomp(node.location, *elt, generators); } _ => fold::fold_expr(self, node)?, }; let custom = match &expr.node { - ast::ExprKind::Constant { value, .. } => { + ExprKind::Constant { value, .. } => { Some(self.infer_constant(value, &expr.location)?) } - ast::ExprKind::Name { id, .. } => { + ExprKind::Name { id, .. } => { // the name `none` is special since it may have different types if id == &"none".into() { if let TypeEnum::TObj { params, .. } = @@ -498,29 +498,29 @@ impl<'a> fold::Fold<()> for Inferencer<'a> { Some(self.infer_identifier(*id)?) } } - ast::ExprKind::List { elts, .. } => Some(self.infer_list(elts)?), - ast::ExprKind::Tuple { elts, .. } => Some(self.infer_tuple(elts)?), - ast::ExprKind::Attribute { value, attr, ctx } => { + ExprKind::List { elts, .. } => Some(self.infer_list(elts)?), + ExprKind::Tuple { elts, .. } => Some(self.infer_tuple(elts)?), + ExprKind::Attribute { value, attr, ctx } => { Some(self.infer_attribute(value, *attr, ctx)?) } - ast::ExprKind::BoolOp { values, .. } => Some(self.infer_bool_ops(values)?), - ast::ExprKind::BinOp { left, op, right } => { + ExprKind::BoolOp { values, .. } => Some(self.infer_bool_ops(values)?), + ExprKind::BinOp { left, op, right } => { Some(self.infer_bin_ops(expr.location, left, op, right, false)?) } - ast::ExprKind::UnaryOp { op, operand } => Some(self.infer_unary_ops(op, operand)?), - ast::ExprKind::Compare { left, ops, comparators } => { + ExprKind::UnaryOp { op, operand } => Some(self.infer_unary_ops(op, operand)?), + ExprKind::Compare { left, ops, comparators } => { Some(self.infer_compare(left, ops, comparators)?) } - ast::ExprKind::Subscript { value, slice, ctx, .. } => { + ExprKind::Subscript { value, slice, ctx, .. } => { Some(self.infer_subscript(value.as_ref(), slice.as_ref(), ctx)?) } - ast::ExprKind::IfExp { test, body, orelse } => { + ExprKind::IfExp { test, body, orelse } => { Some(self.infer_if_expr(test, body.as_ref(), orelse.as_ref())?) } - ast::ExprKind::ListComp { .. } - | ast::ExprKind::Lambda { .. } - | ast::ExprKind::Call { .. } => expr.custom, // already computed - ast::ExprKind::Slice { .. } => None, // we don't need it for slice + ExprKind::ListComp { .. } + | ExprKind::Lambda { .. } + | ExprKind::Call { .. } => expr.custom, // already computed + ExprKind::Slice { .. } => None, // we don't need it for slice _ => return report_error("not supported", expr.location), }; Ok(ast::Expr { custom, location: expr.location, node: expr.node }) @@ -748,7 +748,7 @@ impl<'a> Inferencer<'a> { custom: Some(new_context.unifier.add_ty(TypeEnum::TList { ty: elt.custom.unwrap() })), node: ExprKind::ListComp { elt: Box::new(elt), - generators: vec![ast::Comprehension { + generators: vec![Comprehension { target: Box::new(target), iter: Box::new(iter), ifs, @@ -1094,7 +1094,7 @@ impl<'a> Inferencer<'a> { ) -> InferenceResult { let ty = self.unifier.get_dummy_var().0; match &slice.node { - ast::ExprKind::Slice { lower, upper, step } => { + ExprKind::Slice { lower, upper, step } => { for v in [lower.as_ref(), upper.as_ref(), step.as_ref()].iter().flatten() { self.constrain(v.custom.unwrap(), self.primitives.int32, &v.location)?; } @@ -1102,7 +1102,7 @@ impl<'a> Inferencer<'a> { self.constrain(value.custom.unwrap(), list, &value.location)?; Ok(list) } - ast::ExprKind::Constant { value: ast::Constant::Int(val), .. } => { + ExprKind::Constant { value: ast::Constant::Int(val), .. } => { // the index is a constant, so value can be a sequence. let ind: Option = (*val).try_into().ok(); let ind = ind.ok_or_else(|| "Index must be int32".to_string())?; diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs index bdd61d4ec..cc18715c7 100644 --- a/nac3core/src/typecheck/type_inferencer/test.rs +++ b/nac3core/src/typecheck/type_inferencer/test.rs @@ -20,7 +20,7 @@ struct Resolver { impl SymbolResolver for Resolver { fn get_default_param_value( &self, - _: &nac3parser::ast::Expr, + _: &ast::Expr, ) -> Option { unimplemented!() } @@ -62,7 +62,7 @@ struct TestEnvironment { pub primitives: PrimitiveStore, pub id_to_name: HashMap, pub identifier_mapping: HashMap, - pub virtual_checks: Vec<(Type, Type, nac3parser::ast::Location)>, + pub virtual_checks: Vec<(Type, Type, Location)>, pub calls: HashMap, pub top_level: TopLevelContext, } diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index 264bb175f..a5037413a 100644 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -641,7 +641,7 @@ impl Unifier { .get_intersection(a, b) .map_err(|_| TypeError::new(TypeErrorKind::IncompatibleTypes(a, b), None))? .unwrap(); - let range = if let TypeEnum::TVar { range, .. } = &*self.get_ty(intersection) { + let range = if let TVar { range, .. } = &*self.get_ty(intersection) { range.clone() } else { unreachable!() @@ -649,7 +649,7 @@ impl Unifier { self.unification_table.unify(a, b); self.unification_table.set_value( a, - Rc::new(TypeEnum::TVar { + Rc::new(TVar { id: name1.map_or(*id2, |_| *id), fields: new_fields, range, @@ -1217,7 +1217,7 @@ impl Unifier { cache: &mut HashMap>, ) -> Option> where - K: std::hash::Hash + std::cmp::Eq + std::clone::Clone, + K: std::hash::Hash + Eq + Clone, { let mut map2 = None; for (k, v) in map.iter() { @@ -1238,7 +1238,7 @@ impl Unifier { cache: &mut HashMap>, ) -> Option> where - K: std::hash::Hash + std::cmp::Eq + std::clone::Clone, + K: std::hash::Hash + Eq + Clone, { let mut map2 = None; for (k, (v, mutability)) in map.iter() { diff --git a/nac3core/src/typecheck/typedef/test.rs b/nac3core/src/typecheck/typedef/test.rs index 52e420a7d..cd3a22d8f 100644 --- a/nac3core/src/typecheck/typedef/test.rs +++ b/nac3core/src/typecheck/typedef/test.rs @@ -47,7 +47,7 @@ impl Unifier { fn map_eq(&mut self, map1: &Mapping, map2: &Mapping) -> bool where - K: std::hash::Hash + std::cmp::Eq + std::clone::Clone, + K: std::hash::Hash + Eq + Clone, { if map1.len() != map2.len() { return false; @@ -62,7 +62,7 @@ impl Unifier { fn map_eq2(&mut self, map1: &Mapping, map2: &Mapping) -> bool where - K: std::hash::Hash + std::cmp::Eq + std::clone::Clone, + K: std::hash::Hash + Eq + Clone, { if map1.len() != map2.len() { return false; diff --git a/nac3ld/src/lib.rs b/nac3ld/src/lib.rs index f19e03644..53323fb95 100644 --- a/nac3ld/src/lib.rs +++ b/nac3ld/src/lib.rs @@ -1,7 +1,7 @@ use dwarf::*; use elf::*; use std::collections::HashMap; -use std::{convert, mem, ptr, slice, str}; +use std::{mem, ptr, slice, str}; extern crate byteorder; use byteorder::{ByteOrder, LittleEndian}; @@ -21,7 +21,7 @@ pub enum Error { Lookup(&'static str), } -impl convert::From<&'static str> for Error { +impl From<&'static str> for Error { fn from(desc: &'static str) -> Error { Error::Parsing(desc) } diff --git a/nac3parser/src/lexer.rs b/nac3parser/src/lexer.rs index 6804df05b..ae26c5bc9 100644 --- a/nac3parser/src/lexer.rs +++ b/nac3parser/src/lexer.rs @@ -486,8 +486,8 @@ where } } match p { - 0xD800..=0xDFFF => Ok(std::char::REPLACEMENT_CHARACTER), - _ => std::char::from_u32(p).ok_or(unicode_error), + 0xD800..=0xDFFF => Ok(char::REPLACEMENT_CHARACTER), + _ => char::from_u32(p).ok_or(unicode_error), } }