diff --git a/dedup/src/lib.rs b/dedup/src/lib.rs index 80518a88..831372d3 100644 --- a/dedup/src/lib.rs +++ b/dedup/src/lib.rs @@ -13,7 +13,7 @@ pub trait DeduplicateConstants: Sized { fn deduplicate_constants(self) -> Result; } -impl<'ast> DeduplicateConstants for Fir> { +impl DeduplicateConstants for Fir> { fn deduplicate_constants(self) -> Result { let mut ctx = ConstantDeduplicator(HashMap::new()); diff --git a/flatten/src/lib.rs b/flatten/src/lib.rs index aefc588b..d1d225c1 100644 --- a/flatten/src/lib.rs +++ b/flatten/src/lib.rs @@ -193,7 +193,7 @@ pub enum AstInfo<'ast> { Helper(Symbol, SpanTuple), } -impl<'ast> AstInfo<'ast> { +impl AstInfo<'_> { pub fn location(&self) -> &SpanTuple { match self { AstInfo::Node(Ast { location, .. }) diff --git a/name_resolve/src/declarator.rs b/name_resolve/src/declarator.rs index d954a0d3..416d4f08 100644 --- a/name_resolve/src/declarator.rs +++ b/name_resolve/src/declarator.rs @@ -12,7 +12,7 @@ enum DefinitionKind { pub(crate) struct Declarator<'ctx, 'enclosing>(pub(crate) &'ctx mut NameResolveCtx<'enclosing>); -impl<'ctx, 'enclosing> Declarator<'ctx, 'enclosing> { +impl Declarator<'_, '_> { fn define( &mut self, kind: DefinitionKind, @@ -41,9 +41,7 @@ impl<'ctx, 'enclosing> Declarator<'ctx, 'enclosing> { } } -impl<'ast, 'ctx, 'enclosing> Traversal, NameResolutionError> - for Declarator<'ctx, 'enclosing> -{ +impl<'ast> Traversal, NameResolutionError> for Declarator<'_, '_> { // TODO: Can we factor these three functions? fn traverse_function( diff --git a/name_resolve/src/lib.rs b/name_resolve/src/lib.rs index d13c8d47..596a84c2 100644 --- a/name_resolve/src/lib.rs +++ b/name_resolve/src/lib.rs @@ -109,7 +109,7 @@ impl<'scope, 'enclosing> LookupIterator<'scope, 'enclosing> for FlatScope<'enclo } } -impl<'scope, 'enclosing> Iterator for FlatIterator<'scope, 'enclosing> { +impl<'scope> Iterator for FlatIterator<'scope, '_> { type Item = &'scope Bindings; fn next(&mut self) -> Option { @@ -125,7 +125,7 @@ impl<'scope, 'enclosing> Iterator for FlatIterator<'scope, 'enclosing> { } } -impl<'enclosing> FlatScope<'enclosing> { +impl FlatScope<'_> { fn lookup(&self, name: &Symbol, starting_scope: Scope) -> Option<&OriginIdx> { self.lookup_iterator(starting_scope) .find_map(|bindings| bindings.get(name)) @@ -163,7 +163,7 @@ struct NameResolveCtx<'enclosing> { } impl<'enclosing> NameResolveCtx<'enclosing> { - fn new(enclosing_scope: EnclosingScope<'enclosing>) -> NameResolveCtx { + fn new(enclosing_scope: EnclosingScope<'enclosing>) -> NameResolveCtx<'enclosing> { let empty_scope_map: HashMap = enclosing_scope .0 .values() @@ -314,7 +314,7 @@ impl NameResolutionError { } } -impl<'enclosing> NameResolveCtx<'enclosing> { +impl NameResolveCtx<'_> { fn scope(fir: &Fir) -> HashMap { let root = fir.nodes.last_key_value().unwrap(); @@ -346,9 +346,7 @@ impl<'enclosing> NameResolveCtx<'enclosing> { } } -impl<'ast, 'enclosing> Pass, FlattenData<'ast>, Error> - for NameResolveCtx<'enclosing> -{ +impl<'ast> Pass, FlattenData<'ast>, Error> for NameResolveCtx<'_> { fn pre_condition(_fir: &Fir) {} fn post_condition(_fir: &Fir) {} diff --git a/name_resolve/src/resolver.rs b/name_resolve/src/resolver.rs index 863a7407..a6a29208 100644 --- a/name_resolve/src/resolver.rs +++ b/name_resolve/src/resolver.rs @@ -26,7 +26,7 @@ impl Display for ResolveKind { pub(crate) struct Resolver<'ctx, 'enclosing>(pub(crate) &'ctx mut NameResolveCtx<'enclosing>); -impl<'ctx, 'enclosing> Resolver<'ctx, 'enclosing> { +impl Resolver<'_, '_> { fn get_definition( &self, kind: ResolveKind, @@ -54,9 +54,7 @@ impl<'ctx, 'enclosing> Resolver<'ctx, 'enclosing> { } } -impl<'ast, 'ctx, 'enclosing> Mapper, FlattenData<'ast>, NameResolutionError> - for Resolver<'ctx, 'enclosing> -{ +impl<'ast> Mapper, FlattenData<'ast>, NameResolutionError> for Resolver<'_, '_> { fn map_call( &mut self, data: FlattenData<'ast>, diff --git a/src/context/scope_map.rs b/src/context/scope_map.rs index 8e3848e6..d7085326 100644 --- a/src/context/scope_map.rs +++ b/src/context/scope_map.rs @@ -87,7 +87,7 @@ impl ScopeMap { &'map self, key: &Q, map_extractor: impl Fn(&Scope) -> &HashMap, - ) -> Option<&U> + ) -> Option<&'map U> where K: Borrow + Hash + Eq + 'map, Q: Hash + Eq + ?Sized, diff --git a/src/ffi.rs b/src/ffi.rs index c273b98a..35ad4d58 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -248,7 +248,7 @@ mod tests { let call = call.downcast_ref::().unwrap(); assert_eq!( - execute(&dec, &call, &mut i), + execute(dec, call, &mut i), Ok(Some(JkInt::from(15).to_instance())) ); } @@ -264,12 +264,12 @@ mod tests { let call = constructs::expr(span!("print_something()")).unwrap().1; let call = call.downcast_ref::().unwrap(); - assert_eq!(execute(&dec, &call, &mut i), Ok(None)); + assert_eq!(execute(dec, call, &mut i), Ok(None)); } #[test] fn load_libs_stress() { - let ld_library_path = std::env::var("LD_LIBRARY_PATH").unwrap_or(String::new()); + let ld_library_path = std::env::var("LD_LIBRARY_PATH").unwrap_or_default(); let pwd = std::env::var("PWD").unwrap(); std::env::set_var( "LD_LIBRARY_PATH", diff --git a/src/instruction/binary_op.rs b/src/instruction/binary_op.rs index 2a1088fc..645c639e 100644 --- a/src/instruction/binary_op.rs +++ b/src/instruction/binary_op.rs @@ -268,7 +268,7 @@ mod tests { fn comparison_precedence() { assert_bool( "1 + 4 * 2 - 1 + 2 * (14 + (2 - 17) * 1) - 12 + 3 / 2 < 45", - 1 + 4 * 2 - 1 + 2 * (14 + (2 - 17) * 1) - 12 + 3 / 2 < 45, + 1 + 4 * 2 - 1 + 2 * (14 + (2 - 17)) - 12 + 3 / 2 < 45, ); } @@ -375,17 +375,17 @@ mod tests { #[test] fn binop_execute_valid_mul() { - binop_assert!(1 * 2); + binop_assert!(2); } #[test] fn binop_execute_valid_normal_priority() { - binop_assert!(1 * 2 + 3); + binop_assert!(2 + 3); } #[test] fn binop_execute_valid_back_priority() { - binop_assert!(3 + 1 * 2); + binop_assert!(3 + 2); } #[test] @@ -410,6 +410,6 @@ mod tests { #[test] fn binop_execute_valid_extremely_complex_expr() { - binop_assert!(1 + 4 * 2 - 1 + 2 * (14 + (2 - 17) * 1) - 12 + 3 / 2); + binop_assert!(1 + 4 * 2 - 1 + 2 * (14 + (2 - 17)) - 12 + 3 / 2); } } diff --git a/src/instruction/field_access.rs b/src/instruction/field_access.rs index d5393957..4e703ccb 100644 --- a/src/instruction/field_access.rs +++ b/src/instruction/field_access.rs @@ -134,13 +134,11 @@ mod tests { use crate::{jinko, jinko_fail, span}; fn setup() -> Context { - let ctx = jinko! { + jinko! { type Point(x: int, y:int); func basic() -> Point { Point ( x : 15, y : 14 )} b = basic(); - }; - - ctx + } } #[test] diff --git a/src/parser/constructs.rs b/src/parser/constructs.rs index 15cd10bb..13730b59 100644 --- a/src/parser/constructs.rs +++ b/src/parser/constructs.rs @@ -759,9 +759,9 @@ fn generic_func_or_type_inst_args( func_or_type_inst_args(next(input), id, generics, start_loc) } -/// -/// ARGS -/// +// +// ARGS +// /// args = expr ( ',' expr )* ')' /// | ')' diff --git a/typecheck/src/actual.rs b/typecheck/src/actual.rs index 9c533ba2..5a00a9c5 100644 --- a/typecheck/src/actual.rs +++ b/typecheck/src/actual.rs @@ -43,7 +43,7 @@ struct ChainEnd { final_type: Type, } -impl<'ctx> TypeLinkResolver<'ctx> { +impl TypeLinkResolver<'_> { /// Recursively try and resolve a type link within the type context. This will update the given node's type /// within the type context. fn resolve_link(&mut self, to_resolve: OriginIdx, fir: &Fir) -> OriginIdx { @@ -121,7 +121,7 @@ impl<'ctx> TypeLinkResolver<'ctx> { } } -impl<'ctx> Traversal, Error> for TypeLinkResolver<'ctx> { +impl Traversal, Error> for TypeLinkResolver<'_> { fn traverse_node( &mut self, fir: &Fir, diff --git a/typecheck/src/checker.rs b/typecheck/src/checker.rs index fb0b6f04..ef7174c7 100644 --- a/typecheck/src/checker.rs +++ b/typecheck/src/checker.rs @@ -20,7 +20,7 @@ use crate::{Type, TypeCtx}; // as it's used for conditions for multiple nodes pub(crate) struct Checker<'ctx>(pub(crate) &'ctx mut TypeCtx); -impl<'ctx> Checker<'ctx> { +impl Checker<'_> { fn get_type(&self, of: &RefIdx) -> &Type { // if at this point, the reference is unresolved, or if we haven't seen that node yet, it's // an interpreter error @@ -113,7 +113,7 @@ impl<'ctx> Checker<'ctx> { struct Fmt<'fir, 'ast>(&'fir Fir>); -impl<'fir, 'ast> Fmt<'fir, 'ast> { +impl Fmt<'_, '_> { pub fn number(value: usize) -> String { match value { 0 => format!("{}", "no".purple()), @@ -207,7 +207,7 @@ fn unexpected_arithmetic_type( .with_loc(loc.clone()) } -impl<'ctx> Traversal, Error> for Checker<'ctx> { +impl Traversal, Error> for Checker<'_> { fn traverse_function( &mut self, fir: &Fir, diff --git a/typecheck/src/typer.rs b/typecheck/src/typer.rs index eae3fe56..be0685c0 100644 --- a/typecheck/src/typer.rs +++ b/typecheck/src/typer.rs @@ -11,7 +11,7 @@ use crate::{TypeCtx, TypeLinkMap, TypeVariable}; /// in the documentation for [`Typer::ty`]. pub(crate) struct Typer<'ctx>(pub(crate) &'ctx mut TypeCtx); -impl<'ctx> Typer<'ctx> { +impl Typer<'_> { fn assign_type(&mut self, node: OriginIdx, ty: TypeVariable) { // Having non-unique ids in the Fir is an interpreter error // Or should we return an error here? @@ -58,7 +58,7 @@ impl<'ctx> Typer<'ctx> { } } -impl<'ast, 'ctx> Mapper, FlattenData<'ast>, Error> for Typer<'ctx> { +impl<'ast> Mapper, FlattenData<'ast>, Error> for Typer<'_> { fn map_constant( &mut self, data: FlattenData<'ast>, diff --git a/xparser/src/constructs.rs b/xparser/src/constructs.rs index 97ff4893..c6bcaa68 100644 --- a/xparser/src/constructs.rs +++ b/xparser/src/constructs.rs @@ -965,9 +965,9 @@ fn generic_func_or_type_inst_args( func_or_type_inst_args(next(input), id, generics, start_loc) } -/// -/// ARGS -/// +// +// ARGS +// /// args = expr ( ',' expr )* ')' /// | ')' diff --git a/xparser/src/lib.rs b/xparser/src/lib.rs index 819be3fb..950e740d 100644 --- a/xparser/src/lib.rs +++ b/xparser/src/lib.rs @@ -18,7 +18,7 @@ pub enum Error<'i> { Mult(Vec>), } -impl<'i> Error<'i> { +impl Error<'_> { pub fn emit(&self) { match self { Error::Msg(m) => eprintln!("parsing error: {m}"), @@ -86,7 +86,7 @@ impl<'i> From>> for Error<'i> { } impl<'i> nom::error::ParseError> for Error<'i> { - fn from_error_kind(span: ParseInput<'i>, k: nom::error::ErrorKind) -> Error { + fn from_error_kind(span: ParseInput<'i>, k: nom::error::ErrorKind) -> Error<'i> { // FIXME: Add better location here in order to print whole line and // display specific hint about parse error // Error::new(ErrKind::Parsing).with_loc(Some(SpanTuple::with_source_ref(