diff --git a/vhdl_lang/src/analysis/association.rs b/vhdl_lang/src/analysis/association.rs index 5bda6286..599a587e 100644 --- a/vhdl_lang/src/analysis/association.rs +++ b/vhdl_lang/src/analysis/association.rs @@ -392,7 +392,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { let mut is_error = false; let mut result = Vec::default(); - let mut associated: FnvHashMap = Default::default(); + let mut associated: FnvHashMap)> = Default::default(); for (actual_pos, resolved_formal) in resolved_pairs.iter() { match resolved_formal { Some(resolved_formal) => { @@ -606,7 +606,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { scope: &Scope<'a>, span: TokenSpan, diagnostics: &mut dyn DiagnosticHandler, - ) -> EvalResult { + ) -> EvalResult> { match expr { Expression::Name(name) => { let resolved = self.name_resolve(scope, span, name, diagnostics)?; @@ -649,8 +649,8 @@ impl Diagnostic { pub fn invalid_type_conversion( pos: impl AsRef, - from: BaseType, - to: TypeEnt, + from: BaseType<'_>, + to: TypeEnt<'_>, ) -> Diagnostic { Diagnostic::new( pos, diff --git a/vhdl_lang/src/analysis/declarative.rs b/vhdl_lang/src/analysis/declarative.rs index 6fc93ded..0916d67e 100644 --- a/vhdl_lang/src/analysis/declarative.rs +++ b/vhdl_lang/src/analysis/declarative.rs @@ -41,7 +41,7 @@ impl Declaration { /// ``` /// /// The context is given by the parent element of the declaration. - pub fn is_allowed_in_context(&self, parent: &AnyEntKind) -> bool { + pub fn is_allowed_in_context(&self, parent: &AnyEntKind<'_>) -> bool { use Declaration::*; use ObjectClass::*; match parent { @@ -758,54 +758,55 @@ impl<'a, 't> AnalyzeContext<'a, 't> { signature, }) = entity_name { - let ent: EntRef = match scope.lookup(self.ctx, designator.token, &designator.item.item) - { - Ok(NamedEntities::Single(ent)) => { - designator.set_unique_reference(ent); + let ent: EntRef<'_> = + match scope.lookup(self.ctx, designator.token, &designator.item.item) { + Ok(NamedEntities::Single(ent)) => { + designator.set_unique_reference(ent); - if let Some(signature) = signature { - diagnostics.push(Diagnostic::should_not_have_signature( - "Attribute specification", - signature.pos(self.ctx), - )); + if let Some(signature) = signature { + diagnostics.push(Diagnostic::should_not_have_signature( + "Attribute specification", + signature.pos(self.ctx), + )); + } + ent } - ent - } - Ok(NamedEntities::Overloaded(overloaded)) => { - if let Some(signature) = signature { - match as_fatal(self.resolve_signature(scope, signature, diagnostics))? { - Some(signature_key) => { - if let Some(ent) = - overloaded.get(&SubprogramKey::Normal(signature_key)) - { - designator.set_unique_reference(&ent); - ent.into() - } else { - diagnostics.push(Diagnostic::no_overloaded_with_signature( - designator.pos(self.ctx), - &designator.item.item, - &overloaded, - )); + Ok(NamedEntities::Overloaded(overloaded)) => { + if let Some(signature) = signature { + match as_fatal(self.resolve_signature(scope, signature, diagnostics))? { + Some(signature_key) => { + if let Some(ent) = + overloaded.get(&SubprogramKey::Normal(signature_key)) + { + designator.set_unique_reference(&ent); + ent.into() + } else { + diagnostics.push(Diagnostic::no_overloaded_with_signature( + designator.pos(self.ctx), + &designator.item.item, + &overloaded, + )); + return Ok(()); + } + } + None => { return Ok(()); } } - None => { - return Ok(()); - } + } else if let Some(ent) = overloaded.as_unique() { + designator.set_unique_reference(ent); + ent + } else { + diagnostics + .push(Diagnostic::signature_required(designator.pos(self.ctx))); + return Ok(()); } - } else if let Some(ent) = overloaded.as_unique() { - designator.set_unique_reference(ent); - ent - } else { - diagnostics.push(Diagnostic::signature_required(designator.pos(self.ctx))); + } + Err(err) => { + diagnostics.push(err); return Ok(()); } - } - Err(err) => { - diagnostics.push(err); - return Ok(()); - } - }; + }; // Attributes affect the underlying entity and cannot be set directly on aliases let ent = ent.as_actual(); @@ -1177,7 +1178,7 @@ impl Diagnostic { fn no_overloaded_with_signature( pos: &SrcPos, des: &Designator, - overloaded: &OverloadedName, + overloaded: &OverloadedName<'_>, ) -> Diagnostic { let mut diagnostic = Diagnostic::new( pos, @@ -1208,7 +1209,7 @@ impl Diagnostic { } } -fn get_entity_class(ent: EntRef) -> Option { +fn get_entity_class(ent: EntRef<'_>) -> Option { match ent.actual_kind() { // Alias is never the direct target of attribute AnyEntKind::ExternalAlias { .. } => None, @@ -1296,7 +1297,7 @@ const UNASSOCIATED_DISPLAY_THRESHOLD: usize = 3; /// "Missing association of element the_element1, the_element2 and the_element3" /// * If there are more elements than [UNASSOCIATED_DISPLAY_THRESHOLD], the message will be truncated /// to "Missing association of element the_element1, the_element2, the_element3 and 17 more" -fn pretty_format_unassociated_message(unassociated: &HashSet<&RecordElement>) -> String { +fn pretty_format_unassociated_message(unassociated: &HashSet<&RecordElement<'_>>) -> String { assert!( !unassociated.is_empty(), "Should never be called with an empty set" diff --git a/vhdl_lang/src/analysis/design_unit.rs b/vhdl_lang/src/analysis/design_unit.rs index b510541f..44f62e2e 100644 --- a/vhdl_lang/src/analysis/design_unit.rs +++ b/vhdl_lang/src/analysis/design_unit.rs @@ -368,7 +368,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { fn check_secondary_before_primary( &self, - primary: &DesignEnt, + primary: &DesignEnt<'_>, secondary_pos: &SrcPos, diagnostics: &mut dyn DiagnosticHandler, ) { @@ -394,7 +394,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { scope: &Scope<'a>, config: &mut ConfigurationDeclaration, diagnostics: &mut dyn DiagnosticHandler, - ) -> EvalResult { + ) -> EvalResult> { let ent_name = &mut config.entity_name; let ent_name_span = ent_name.span; diff --git a/vhdl_lang/src/analysis/expression.rs b/vhdl_lang/src/analysis/expression.rs index d81d974a..d15b36bb 100644 --- a/vhdl_lang/src/analysis/expression.rs +++ b/vhdl_lang/src/analysis/expression.rs @@ -676,7 +676,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { match implicit_bool_types.len().cmp(&1) { std::cmp::Ordering::Equal => { - let typ: TypeEnt = types.into_iter().next().unwrap().into(); + let typ: TypeEnt<'_> = types.into_iter().next().unwrap().into(); self.expr_with_ttyp(scope, typ, expr, diagnostics)?; } std::cmp::Ordering::Greater => { @@ -979,7 +979,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { } Choice::Others => { // @TODO empty others - let remaining_types: FnvHashSet = elems + let remaining_types: FnvHashSet> = elems .iter() .filter_map(|elem| { if !associated.is_associated(&elem) { @@ -1262,7 +1262,7 @@ impl RecordAssociations { fn associate( &mut self, ctx: &dyn TokenAccess, - elem: &RecordElement, + elem: &RecordElement<'_>, pos: TokenSpan, diagnostics: &mut dyn DiagnosticHandler, ) { @@ -1281,7 +1281,7 @@ impl RecordAssociations { } } - fn is_associated(&self, elem: &RecordElement) -> bool { + fn is_associated(&self, elem: &RecordElement<'_>) -> bool { self.0.contains_key(&elem.id()) } } diff --git a/vhdl_lang/src/analysis/literals.rs b/vhdl_lang/src/analysis/literals.rs index 623be337..0e2a07b2 100644 --- a/vhdl_lang/src/analysis/literals.rs +++ b/vhdl_lang/src/analysis/literals.rs @@ -20,8 +20,8 @@ impl<'a, 't> AnalyzeContext<'a, 't> { &self, span: TokenSpan, string_lit: Latin1String, - target_base: TypeEnt, - target_type: TypeEnt, + target_base: TypeEnt<'_>, + target_type: TypeEnt<'_>, diagnostics: &mut dyn DiagnosticHandler, ) { if let Some((elem_type, literals)) = as_single_index_enum_array(target_base) { @@ -214,7 +214,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { } /// Must be an array type with a single index of enum type -fn as_single_index_enum_array(typ: TypeEnt) -> Option<(TypeEnt, &FnvHashSet)> { +fn as_single_index_enum_array(typ: TypeEnt<'_>) -> Option<(TypeEnt<'_>, &FnvHashSet)> { if let Type::Array { indexes, elem_type, .. } = typ.kind() diff --git a/vhdl_lang/src/analysis/lock.rs b/vhdl_lang/src/analysis/lock.rs index c307474d..f13036e4 100644 --- a/vhdl_lang/src/analysis/lock.rs +++ b/vhdl_lang/src/analysis/lock.rs @@ -34,7 +34,7 @@ impl AnalysisLock { } /// Returns an immutable reference to the data and result if it has already been analyzed. - pub fn get(&self) -> Option> { + pub fn get(&self) -> Option> { let guard = self.state.read(); if guard.result.is_some() { Some(ReadGuard { guard }) @@ -62,7 +62,7 @@ impl AnalysisLock { /// Returns an immmutable reference to the data and result. /// /// Panics if the analysis result is not available. - pub fn expect_analyzed(&self) -> ReadGuard { + pub fn expect_analyzed(&self) -> ReadGuard<'_, T, R> { let guard = self.state.read(); if guard.result.is_none() { @@ -77,7 +77,7 @@ impl AnalysisLock { /// This view provides: /// - a mutable reference to the data if not analyzed /// - an immmutable reference to the data if already analyzed - pub fn entry(&self) -> AnalysisEntry { + pub fn entry(&self) -> AnalysisEntry<'_, T, R> { if let Some(guard) = self.get() { AnalysisEntry::Occupied(guard) } else { diff --git a/vhdl_lang/src/analysis/names.rs b/vhdl_lang/src/analysis/names.rs index d3b94892..66aed5f2 100644 --- a/vhdl_lang/src/analysis/names.rs +++ b/vhdl_lang/src/analysis/names.rs @@ -163,7 +163,7 @@ pub enum ResolvedName<'a> { impl<'a> ResolvedName<'a> { /// The name was selected out of a design unit - fn from_design_not_overloaded(ent: &'a AnyEnt) -> Result { + fn from_design_not_overloaded(ent: &'a AnyEnt<'_>) -> Result { let name = match ent.kind() { AnyEntKind::Object(_) => ResolvedName::ObjectName(ObjectName { base: ObjectBase::Object(ObjectEnt::from_any(ent).unwrap()), @@ -221,7 +221,7 @@ impl<'a> ResolvedName<'a> { } /// The name was looked up from the current scope - fn from_scope_not_overloaded(ent: &'a AnyEnt) -> Result { + fn from_scope_not_overloaded(ent: &'a AnyEnt<'_>) -> Result { let name = match ent.kind() { AnyEntKind::Object(_) => ResolvedName::ObjectName(ObjectName { base: ObjectBase::Object(ObjectEnt::from_any(ent).unwrap()), @@ -342,7 +342,7 @@ impl<'a> ResolvedName<'a> { &self, ctx: &dyn TokenAccess, prefix_pos: TokenSpan, - attr: &AttributeSuffix, + attr: &AttributeSuffix<'_>, diagnostics: &mut dyn DiagnosticHandler, ) -> EvalResult> { if let Some(typ) = self.type_mark() { @@ -361,7 +361,7 @@ impl<'a> ResolvedName<'a> { &self, ctx: &dyn TokenAccess, prefix_pos: TokenSpan, - attr: &AttributeSuffix, + attr: &AttributeSuffix<'_>, diagnostics: &mut dyn DiagnosticHandler, ) -> EvalResult> { if let ResolvedName::ObjectName(oname) = self { @@ -667,7 +667,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { prefix_pos: TokenSpan, name_pos: TokenSpan, prefix_typ: TypeEnt<'a>, - suffix: &mut Suffix, + suffix: &mut Suffix<'_>, diagnostics: &mut dyn DiagnosticHandler, ) -> EvalResult>> { match suffix { @@ -856,7 +856,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { prefix_pos: TokenSpan, scope: &Scope<'a>, prefix: &ResolvedName<'a>, - attr: &mut AttributeSuffix, + attr: &mut AttributeSuffix<'_>, diagnostics: &mut dyn DiagnosticHandler, ) -> EvalResult> { match attr.attr.item { @@ -1717,7 +1717,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { name_pos: TokenSpan, suffix_pos: TokenSpan, type_mark: TypeEnt<'a>, - indexes: &mut [Index], + indexes: &mut [Index<'_>], diagnostics: &mut dyn DiagnosticHandler, ) -> EvalResult> { let base_type = type_mark.base_type(); @@ -1870,7 +1870,11 @@ impl Declaration { } impl Diagnostic { - fn cannot_be_prefix(prefix_pos: &SrcPos, resolved: ResolvedName, suffix: Suffix) -> Diagnostic { + fn cannot_be_prefix( + prefix_pos: &SrcPos, + resolved: ResolvedName<'_>, + suffix: Suffix<'_>, + ) -> Diagnostic { let suffix_desc = match suffix { Suffix::Selected(_) => "selected", Suffix::All => "accessed with .all", @@ -1902,8 +1906,8 @@ impl Diagnostic { fn cannot_be_prefix_of_attribute( prefix_pos: &SrcPos, - resolved: &ResolvedName, - attr: &AttributeSuffix, + resolved: &ResolvedName<'_>, + attr: &AttributeSuffix<'_>, ) -> Diagnostic { Diagnostic::new( prefix_pos, @@ -1918,7 +1922,7 @@ impl Diagnostic { fn dimension_mismatch( pos: &SrcPos, - base_type: TypeEnt, + base_type: TypeEnt<'_>, got: usize, expected: usize, ) -> Diagnostic { @@ -1971,7 +1975,7 @@ impl Diagnostic { fn check_no_attr_argument( ctx: &dyn TokenAccess, - suffix: &AttributeSuffix, + suffix: &AttributeSuffix<'_>, diagnostics: &mut dyn DiagnosticHandler, ) { if let Some(ref expr) = suffix.expr { @@ -2001,7 +2005,7 @@ fn check_no_sattr_argument( fn check_single_argument<'a>( ctx: &dyn TokenAccess, pos: TokenSpan, - suffix: &'a mut AttributeSuffix, + suffix: &'a mut AttributeSuffix<'_>, diagnostics: &mut dyn DiagnosticHandler, ) -> Option<&'a mut WithTokenSpan> { if let Some(ref mut expr) = suffix.expr { diff --git a/vhdl_lang/src/analysis/package_instance.rs b/vhdl_lang/src/analysis/package_instance.rs index 5d8f9e9b..171f10f6 100644 --- a/vhdl_lang/src/analysis/package_instance.rs +++ b/vhdl_lang/src/analysis/package_instance.rs @@ -240,7 +240,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { uninst_region: &Region<'a>, generic_map: &mut Option, diagnostics: &mut dyn DiagnosticHandler, - ) -> EvalResult<(Region<'a>, FnvHashMap)> { + ) -> EvalResult<(Region<'a>, FnvHashMap>)> { let nested = scope.nested().in_package_declaration(); let (generics, other) = uninst_region.to_package_generic(); diff --git a/vhdl_lang/src/analysis/root.rs b/vhdl_lang/src/analysis/root.rs index 97a6fe7c..07ee9512 100644 --- a/vhdl_lang/src/analysis/root.rs +++ b/vhdl_lang/src/analysis/root.rs @@ -416,7 +416,11 @@ impl DesignRoot { /// /// If the character value is greater than the line length it defaults back to the /// line length. - pub fn item_at_cursor(&self, source: &Source, cursor: Position) -> Option<(SrcPos, EntRef)> { + pub fn item_at_cursor( + &self, + source: &Source, + cursor: Position, + ) -> Option<(SrcPos, EntRef<'_>)> { let mut searcher = ItemAtCursor::new(self, cursor); for unit in self.units_by_source(source) { @@ -433,7 +437,7 @@ impl DesignRoot { None } - pub fn search_reference(&self, source: &Source, cursor: Position) -> Option { + pub fn search_reference(&self, source: &Source, cursor: Position) -> Option> { let (_, ent) = self.item_at_cursor(source, cursor)?; Some(ent) } @@ -497,7 +501,7 @@ impl DesignRoot { .and_then(|ent| ent.decl_pos().cloned()) } /// Search for the declaration at decl_pos and format it - pub fn format_declaration(&self, ent: &AnyEnt) -> Option { + pub fn format_declaration(&self, ent: EntRef<'_>) -> Option { if let AnyEntKind::Library = ent.kind() { Some(format!("library {};", ent.designator())) } else { @@ -514,13 +518,13 @@ impl DesignRoot { } /// Search for all references to the declaration at decl_pos - pub fn find_all_references(&self, ent: EntRef) -> Vec { + pub fn find_all_references(&self, ent: EntRef<'_>) -> Vec { let mut searcher = FindAllReferences::new(self, ent); let _ = self.search(&mut searcher); searcher.references } - pub fn find_all_references_in_source(&self, source: &Source, ent: EntRef) -> Vec { + pub fn find_all_references_in_source(&self, source: &Source, ent: EntRef<'_>) -> Vec { let mut searcher = FindAllReferences::new(self, ent); let _ = self.search_source(source, &mut searcher); searcher.references @@ -616,7 +620,7 @@ impl DesignRoot { } #[cfg(test)] - fn find_std_package(&self, symbol: &str) -> &AnyEnt { + fn find_std_package(&self, symbol: &str) -> EntRef<'_> { let std_lib = self.libraries.get(&self.symbol_utf8("std")).unwrap(); let unit = std_lib .get_unit(&UnitKey::Primary(self.symbol_utf8(symbol))) @@ -629,37 +633,37 @@ impl DesignRoot { } #[cfg(test)] - pub fn find_standard_pkg(&self) -> &AnyEnt { + pub fn find_standard_pkg(&self) -> EntRef<'_> { self.find_std_package("standard") } #[cfg(test)] - pub fn find_textio_pkg(&self) -> &AnyEnt { + pub fn find_textio_pkg(&self) -> EntRef<'_> { self.find_std_package("textio") } #[cfg(test)] - pub fn find_env_pkg(&self) -> &AnyEnt { + pub fn find_env_pkg(&self) -> EntRef<'_> { self.find_std_package("env") } #[cfg(test)] - pub fn find_standard_symbol(&self, name: &str) -> &AnyEnt { + pub fn find_standard_symbol(&self, name: &str) -> EntRef<'_> { self.find_std_symbol("standard", name) } #[cfg(test)] - pub fn find_env_symbol(&self, name: &str) -> &AnyEnt { + pub fn find_env_symbol(&self, name: &str) -> EntRef<'_> { self.find_std_symbol("env", name) } #[cfg(test)] - pub fn find_overloaded_env_symbols(&self, name: &str) -> &NamedEntities { + pub fn find_overloaded_env_symbols(&self, name: &str) -> &NamedEntities<'_> { self.find_std_symbols("env", name) } #[cfg(test)] - fn find_std_symbol(&self, package: &str, name: &str) -> &AnyEnt { + fn find_std_symbol(&self, package: &str, name: &str) -> EntRef<'_> { if let AnyEntKind::Design(Design::Package(_, region)) = self.find_std_package(package).kind() { @@ -671,7 +675,7 @@ impl DesignRoot { } #[cfg(test)] - fn find_std_symbols(&self, package: &str, name: &str) -> &NamedEntities { + fn find_std_symbols(&self, package: &str, name: &str) -> &NamedEntities<'_> { if let AnyEntKind::Design(Design::Package(_, region)) = self.find_std_package(package).kind() { @@ -740,7 +744,7 @@ impl DesignRoot { arena_id: ArenaId, unit_id: &UnitId, source: Source, - unit: &mut UnitWriteGuard, + unit: &mut UnitWriteGuard<'_>, ctx: &dyn TokenAccess, ) { // All units reference the standard arena @@ -1195,7 +1199,7 @@ impl DesignRoot { } /// Get the named entity - pub fn get_ent(&self, id: EntityId) -> &AnyEnt { + pub fn get_ent(&self, id: EntityId) -> EntRef<'_> { self.arenas.get(id) } @@ -1248,7 +1252,7 @@ pub struct EntHierarchy<'a> { impl<'a> EntHierarchy<'a> { fn from_parent(parent: EntRef<'a>, mut symbols: Vec>) -> EntHierarchy<'a> { - let mut by_parent: FnvHashMap> = Default::default(); + let mut by_parent: FnvHashMap>> = Default::default(); symbols.retain(|ent| { if let Some(parent) = ent.parent_in_same_source() { diff --git a/vhdl_lang/src/analysis/scope.rs b/vhdl_lang/src/analysis/scope.rs index f9aaf81f..c4110c60 100644 --- a/vhdl_lang/src/analysis/scope.rs +++ b/vhdl_lang/src/analysis/scope.rs @@ -262,7 +262,7 @@ impl<'a> Scope<'a> { self.0.as_ref().borrow_mut().add(ent, diagnostics); } - pub fn make_potentially_visible(&self, visible_pos: Option<&SrcPos>, ent: &'a AnyEnt) { + pub fn make_potentially_visible(&self, visible_pos: Option<&SrcPos>, ent: EntRef<'a>) { self.0.as_ref().borrow_mut().make_potentially_visible( visible_pos, ent.designator().clone(), diff --git a/vhdl_lang/src/analysis/semantic.rs b/vhdl_lang/src/analysis/semantic.rs index cd04e046..4407df03 100644 --- a/vhdl_lang/src/analysis/semantic.rs +++ b/vhdl_lang/src/analysis/semantic.rs @@ -210,7 +210,11 @@ impl<'a> ResolvedName<'a> { } impl Diagnostic { - pub(crate) fn type_mismatch(pos: &SrcPos, desc: &str, expected_type: TypeEnt) -> Diagnostic { + pub(crate) fn type_mismatch( + pos: &SrcPos, + desc: &str, + expected_type: TypeEnt<'_>, + ) -> Diagnostic { Diagnostic::new( pos, format!("{} does not match {}", desc, expected_type.describe(),), @@ -219,7 +223,7 @@ impl Diagnostic { } pub(crate) fn invalid_selected_name_prefix( - named_entity: &AnyEnt, + named_entity: EntRef<'_>, prefix: &SrcPos, ) -> Diagnostic { Diagnostic::mismatched_kinds( @@ -232,7 +236,7 @@ impl Diagnostic { } pub(crate) fn no_declaration_within( - named_entity: &AnyEnt, + named_entity: EntRef<'_>, pos: &SrcPos, suffix: &Designator, ) -> Diagnostic { diff --git a/vhdl_lang/src/analysis/sequential.rs b/vhdl_lang/src/analysis/sequential.rs index 858221d1..1a972fa3 100644 --- a/vhdl_lang/src/analysis/sequential.rs +++ b/vhdl_lang/src/analysis/sequential.rs @@ -400,7 +400,7 @@ enum SequentialRoot<'a> { Function(TypeEnt<'a>), } -fn find_outer_loop(ent: EntRef, label: Option<&Symbol>) -> bool { +fn find_outer_loop(ent: EntRef<'_>, label: Option<&Symbol>) -> bool { match ent.kind() { AnyEntKind::Sequential(Some(Sequential::Loop)) => { if let Some(label) = label { diff --git a/vhdl_lang/src/analysis/subprogram.rs b/vhdl_lang/src/analysis/subprogram.rs index c16d3bd7..584d2790 100644 --- a/vhdl_lang/src/analysis/subprogram.rs +++ b/vhdl_lang/src/analysis/subprogram.rs @@ -190,7 +190,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { scope: &Scope<'a>, signature: &mut WithTokenSpan, diagnostics: &mut dyn DiagnosticHandler, - ) -> EvalResult { + ) -> EvalResult> { let (args, return_type) = match &mut signature.item { ast::Signature::Function(ref mut args, ref mut ret) => { let args: Vec<_> = args @@ -247,7 +247,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { uninst_name: &ResolvedName<'a>, instance: &mut SubprogramInstantiation, diagnostics: &mut dyn DiagnosticHandler, - ) -> EvalResult { + ) -> EvalResult> { let uninstantiated_subprogram = self.resolve_uninstantiated_subprogram(scope, uninst_name, instance, diagnostics)?; self.check_instantiated_subprogram_kind_matches_declared( @@ -424,7 +424,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { /// This function will push an appropriate diagnostic. fn check_instantiated_subprogram_kind_matches_declared( &self, - ent: &OverloadedEnt, + ent: &OverloadedEnt<'_>, instance: &SubprogramInstantiation, diagnostics: &mut dyn DiagnosticHandler, ) { @@ -452,7 +452,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { &self, scope: &Scope<'a>, decl: &SubprogramSpecification, - signature: &Signature, + signature: &Signature<'_>, ) -> Option> { let des = decl.subpgm_designator().item.clone().into_designator(); @@ -470,7 +470,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { &self, scope: &Scope<'a>, decl: &SubprogramSpecification, - signature: &Signature, + signature: &Signature<'_>, ) -> Option> { let des = decl.subpgm_designator().item.clone().into_designator(); diff --git a/vhdl_lang/src/analysis/tests/hierarchy.rs b/vhdl_lang/src/analysis/tests/hierarchy.rs index d4c9f4da..d98973e6 100644 --- a/vhdl_lang/src/analysis/tests/hierarchy.rs +++ b/vhdl_lang/src/analysis/tests/hierarchy.rs @@ -263,7 +263,7 @@ fn single(name: &str) -> NameHierarchy { } impl<'a> From> for NameHierarchy { - fn from(ent: EntHierarchy) -> Self { + fn from(ent: EntHierarchy<'_>) -> Self { NameHierarchy { name: if matches!(ent.ent.designator(), Designator::Anonymous(_)) { ent.ent.kind().describe().to_string() diff --git a/vhdl_lang/src/analysis/types.rs b/vhdl_lang/src/analysis/types.rs index 05471183..35fa1fe2 100644 --- a/vhdl_lang/src/analysis/types.rs +++ b/vhdl_lang/src/analysis/types.rs @@ -119,7 +119,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { )) } } else { - let ptype_body: &'a AnyEnt = TypeEnt::define_with_opt_id( + let ptype_body: EntRef<'_> = TypeEnt::define_with_opt_id( self.ctx, self.arena, overwrite_id, @@ -176,7 +176,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> { TypeDefinition::Protected(ref mut prot_decl) => { // Protected type name is visible inside its declarative region // This will be overwritten later when the protected type region is finished - let ptype: &'a AnyEnt = TypeEnt::define_with_opt_id( + let ptype: EntRef<'_> = TypeEnt::define_with_opt_id( self.ctx, self.arena, overwrite_id, @@ -223,9 +223,9 @@ impl<'a, 't> AnalyzeContext<'a, 't> { #[allow(invalid_reference_casting)] let region_ptr = unsafe { - let region_ptr = region_ptr as *const Region; - let region_ptr = region_ptr as *mut Region; - &mut *region_ptr as &mut Region + let region_ptr = region_ptr as *const Region<'_>; + let region_ptr = region_ptr as *mut Region<'_>; + &mut *region_ptr as &mut Region<'_> }; *region_ptr = region.into_region(); } @@ -304,7 +304,8 @@ impl<'a, 't> AnalyzeContext<'a, 't> { } } TypeDefinition::Array(ref mut array_indexes, _, ref mut subtype_indication) => { - let mut indexes: Vec> = Vec::with_capacity(array_indexes.len()); + let mut indexes: Vec>> = + Vec::with_capacity(array_indexes.len()); for index in array_indexes.iter_mut() { indexes.push(as_fatal(self.analyze_array_index( scope, diff --git a/vhdl_lang/src/ast/search.rs b/vhdl_lang/src/ast/search.rs index e31dd39f..1bc8a267 100644 --- a/vhdl_lang/src/ast/search.rs +++ b/vhdl_lang/src/ast/search.rs @@ -107,7 +107,7 @@ pub trait Searcher { } /// Search a declaration of a named entity - fn search_decl(&mut self, _ctx: &dyn TokenAccess, _decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, _ctx: &dyn TokenAccess, _decl: FoundDeclaration<'_>) -> SearchState { NotFinished } @@ -1614,7 +1614,7 @@ impl<'a> Searcher for ItemAtCursor<'a> { } } - fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { if let Some(id) = decl.ent_id() { let ent = self.root.get_ent(id); @@ -1668,7 +1668,7 @@ impl<'a, T: Fn(EntRef<'a>) -> bool> FindEnt<'a, T> { } impl<'a, T: Fn(EntRef<'a>) -> bool> Searcher for FindEnt<'a, T> { - fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { if let Some(id) = decl.ent_id() { let ent = self.root.get_ent(id); if (self.cond)(ent) { @@ -1698,7 +1698,7 @@ impl<'a, T: FnMut(EntRef<'a>) -> bool> FindAllEnt<'a, T> { } impl<'a, T: FnMut(EntRef<'a>) -> bool> Searcher for FindAllEnt<'a, T> { - fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { if let Some(id) = decl.ent_id() { let ent = self.root.get_ent(id); if (self.cond)(ent) { @@ -1723,7 +1723,7 @@ impl<'a> FormatDeclaration<'a> { } impl<'a> Searcher for FormatDeclaration<'a> { - fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { let id = if let Some(id) = decl.ent_id() { id } else { @@ -1754,7 +1754,7 @@ pub struct FindAllReferences<'a> { pub references: Vec, } -pub fn is_reference(ent: EntRef, other: EntRef) -> bool { +pub fn is_reference(ent: EntRef<'_>, other: EntRef<'_>) -> bool { if ent.id() == other.id() { return true; } @@ -1781,7 +1781,7 @@ impl<'a> FindAllReferences<'a> { } impl<'a> Searcher for FindAllReferences<'a> { - fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { if let Some(id) = decl.ent_id() { let other = self.root.get_ent(id); @@ -2011,7 +2011,11 @@ pub fn clear_references(tree: &mut impl Search, ctx: &dyn TokenAccess) { NotFinished } - fn search_decl(&mut self, _ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl( + &mut self, + _ctx: &dyn TokenAccess, + decl: FoundDeclaration<'_>, + ) -> SearchState { let reference = decl.ent_id_ref(); reference.clear(); NotFinished diff --git a/vhdl_lang/src/ast/util.rs b/vhdl_lang/src/ast/util.rs index d9abb5ba..02d1f6b9 100644 --- a/vhdl_lang/src/ast/util.rs +++ b/vhdl_lang/src/ast/util.rs @@ -365,7 +365,7 @@ impl Name { impl CallOrIndexed { // During parsing function calls and indexed names are ambiguous // Thus we convert function calls to indexed names during the analysis stage - pub fn as_indexed(&mut self) -> Option { + pub fn as_indexed(&mut self) -> Option> { if !self.could_be_indexed_name() { return None; } @@ -375,7 +375,7 @@ impl CallOrIndexed { ref mut parameters, } = self; - let mut indexes: Vec = Vec::with_capacity(parameters.items.len()); + let mut indexes: Vec> = Vec::with_capacity(parameters.items.len()); for elem in parameters.items.iter_mut() { if let ActualPart::Expression(ref mut expr) = &mut elem.actual.item { diff --git a/vhdl_lang/src/completion/attributes.rs b/vhdl_lang/src/completion/attributes.rs index 620cd4c6..83c961a0 100644 --- a/vhdl_lang/src/completion/attributes.rs +++ b/vhdl_lang/src/completion/attributes.rs @@ -10,7 +10,7 @@ use crate::{named_entity, AnyEntKind, CompletionItem, EntRef, Object}; /// `foo'` /// The provided ent is the entity directly before the tick, i.e., /// `foo` in the example above. -pub(crate) fn completions_for_attribute_name(ent: EntRef) -> Vec { +pub(crate) fn completions_for_attribute_name(ent: EntRef<'_>) -> Vec> { let mut attributes: Vec = Vec::new(); attributes.extend([ AttributeDesignator::SimpleName, @@ -37,7 +37,10 @@ pub(crate) fn completions_for_attribute_name(ent: EntRef) -> Vec } /// Extends applicable attributes when the attribute name is a type. -fn extend_attributes_of_type(typ: &named_entity::Type, attributes: &mut Vec) { +fn extend_attributes_of_type( + typ: &named_entity::Type<'_>, + attributes: &mut Vec, +) { use AttributeDesignator::*; if typ.is_scalar() { attributes.extend([Left, Right, Low, High, Ascending, Image, Value]); @@ -59,7 +62,7 @@ fn extend_attributes_of_type(typ: &named_entity::Type, attributes: &mut Vec) { +fn extend_attributes_of_objects(obj: &Object<'_>, attributes: &mut Vec) { extend_attributes_of_type(obj.subtype.type_mark().kind(), attributes); attributes.push(AttributeDesignator::Type(TypeAttribute::Subtype)); if obj.class == ObjectClass::Signal { diff --git a/vhdl_lang/src/completion/generic.rs b/vhdl_lang/src/completion/generic.rs index 7baf1cc2..fa4b1a23 100644 --- a/vhdl_lang/src/completion/generic.rs +++ b/vhdl_lang/src/completion/generic.rs @@ -60,7 +60,7 @@ impl<'a> CompletionSearcher<'a> { } impl<'a> Searcher for CompletionSearcher<'a> { - fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { let ent_id = match &decl.ast { DeclarationItem::Entity(ent_decl) => { if !ent_decl.get_pos(ctx).contains(self.cursor) { diff --git a/vhdl_lang/src/completion/libraries.rs b/vhdl_lang/src/completion/libraries.rs index b860561b..745f7035 100644 --- a/vhdl_lang/src/completion/libraries.rs +++ b/vhdl_lang/src/completion/libraries.rs @@ -8,7 +8,7 @@ use crate::CompletionItem; use std::iter::once; /// Produces all available libraries. -pub(crate) fn list_all_libraries(root: &DesignRoot) -> Vec { +pub(crate) fn list_all_libraries(root: &DesignRoot) -> Vec> { root.libraries() .map(|lib| CompletionItem::Simple(root.get_ent(lib.id()))) .chain(once(CompletionItem::Work)) diff --git a/vhdl_lang/src/completion/map_aspect.rs b/vhdl_lang/src/completion/map_aspect.rs index 88f0346c..7498dcb0 100644 --- a/vhdl_lang/src/completion/map_aspect.rs +++ b/vhdl_lang/src/completion/map_aspect.rs @@ -76,7 +76,7 @@ impl<'a> MapAspectSearcher<'a> { impl<'a> Searcher for MapAspectSearcher<'a> { /// Visit an instantiation statement extracting completions for ports or generics. - fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration) -> SearchState { + fn search_decl(&mut self, ctx: &dyn TokenAccess, decl: FoundDeclaration<'_>) -> SearchState { match &decl.ast { DeclarationItem::ConcurrentStatement(stmt) => { if let ConcurrentStatement::Instance(inst) = &stmt.statement.item { @@ -128,7 +128,7 @@ enum MapAspectKind { /// From this region, extracts those `AnyEntKind::Object`s where the class of the /// object matches the specified class. -fn extract_objects_with_class(region: &Region, object_class: ObjectClass) -> Vec { +fn extract_objects_with_class(region: &Region<'_>, object_class: ObjectClass) -> Vec { region .entities .values() diff --git a/vhdl_lang/src/data/contents.rs b/vhdl_lang/src/data/contents.rs index 2ff97439..451e2197 100644 --- a/vhdl_lang/src/data/contents.rs +++ b/vhdl_lang/src/data/contents.rs @@ -316,7 +316,7 @@ impl<'a> ContentReader<'a> { self.state = state; } - pub fn set_to(&mut self, reader: &ContentReader) { + pub fn set_to(&mut self, reader: &ContentReader<'_>) { self.state = reader.state; } @@ -368,7 +368,7 @@ mod tests { Contents::from_str(code) } - fn reader(contents: &Contents) -> ContentReader { + fn reader(contents: &Contents) -> ContentReader<'_> { ContentReader::new(contents) } diff --git a/vhdl_lang/src/data/source.rs b/vhdl_lang/src/data/source.rs index 965ee26f..25df10e2 100644 --- a/vhdl_lang/src/data/source.rs +++ b/vhdl_lang/src/data/source.rs @@ -86,7 +86,7 @@ impl UniqueSource { } } - fn contents(&self) -> RwLockReadGuard { + fn contents(&self) -> RwLockReadGuard<'_, Contents> { self.contents.read() } @@ -156,7 +156,7 @@ impl Source { } } - pub fn contents(&self) -> RwLockReadGuard { + pub fn contents(&self) -> RwLockReadGuard<'_, Contents> { self.source.contents() } diff --git a/vhdl_lang/src/formatting/mod.rs b/vhdl_lang/src/formatting/mod.rs index c1f056d8..99f3c36c 100644 --- a/vhdl_lang/src/formatting/mod.rs +++ b/vhdl_lang/src/formatting/mod.rs @@ -99,7 +99,7 @@ pub mod test_utils { input: &str, expected: &str, to_ast: impl FnOnce(&Code) -> T, - format: impl FnOnce(&VHDLFormatter, &T, &mut Buffer), + format: impl FnOnce(&VHDLFormatter<'_>, &T, &mut Buffer), ) { check_formatted_std(input, expected, VHDLStandard::default(), to_ast, format) } @@ -109,7 +109,7 @@ pub mod test_utils { expected: &str, std: VHDLStandard, to_ast: impl FnOnce(&Code) -> T, - format: impl FnOnce(&VHDLFormatter, &T, &mut Buffer), + format: impl FnOnce(&VHDLFormatter<'_>, &T, &mut Buffer), ) { let code = Code::with_standard(input, std); let ast_element = to_ast(&code); diff --git a/vhdl_lang/src/lib.rs b/vhdl_lang/src/lib.rs index f8326602..3d369582 100644 --- a/vhdl_lang/src/lib.rs +++ b/vhdl_lang/src/lib.rs @@ -4,6 +4,7 @@ // // Copyright (c) 2018, Olof Kraigher olof.kraigher@gmail.com #![allow(clippy::upper_case_acronyms)] +#![warn(rust_2018_idioms, future_incompatible)] #[macro_use] extern crate vhdl_lang_macros; diff --git a/vhdl_lang/src/lint/dead_code.rs b/vhdl_lang/src/lint/dead_code.rs index 7a390615..fd84e456 100644 --- a/vhdl_lang/src/lint/dead_code.rs +++ b/vhdl_lang/src/lint/dead_code.rs @@ -63,7 +63,7 @@ impl<'a> Searcher for DeadCodeSearcher<'a> { fn search_decl( &mut self, _ctx: &dyn TokenAccess, - decl: crate::ast::search::FoundDeclaration, + decl: crate::ast::search::FoundDeclaration<'_>, ) -> SearchState { if let Some(id) = decl.ent_id() { self.declarations.insert(self.root.get_ent(id)); @@ -76,14 +76,14 @@ fn search_unit(unit: &LockedUnit, searcher: &mut impl Searcher) { let _ = unit.unit.write().search(&unit.tokens, searcher); } -fn is_package_header(ent: EntRef) -> bool { +fn is_package_header(ent: EntRef<'_>) -> bool { matches!( ent.kind(), AnyEntKind::Design(Design::Package(..)) | AnyEntKind::Design(Design::UninstPackage(..)) ) } -fn is_interface(ent: EntRef) -> bool { +fn is_interface(ent: EntRef<'_>) -> bool { matches!( ent.kind(), AnyEntKind::Object(o) if o.iface.is_some()) @@ -93,7 +93,7 @@ fn is_interface(ent: EntRef) -> bool { ) } -fn can_be_locally_unused(ent: EntRef) -> bool { +fn can_be_locally_unused(ent: EntRef<'_>) -> bool { if let Related::DeclaredBy(related) = ent.related { if !can_be_locally_unused(related) { return false; @@ -262,12 +262,12 @@ mod tests { use crate::syntax::test::check_no_diagnostics; use crate::syntax::test::Code; - fn get_ent(root: &DesignRoot, code: Code) -> EntRef { + fn get_ent(root: &DesignRoot, code: Code) -> EntRef<'_> { root.search_reference(code.source(), code.start()).unwrap() } - fn check_unused(got: FnvHashSet, expected: FnvHashSet) { - fn fmt_ent(ent: EntRef) -> String { + fn check_unused(got: FnvHashSet>, expected: FnvHashSet>) { + fn fmt_ent(ent: EntRef<'_>) -> String { format!( "{}, line {}", ent.describe(), diff --git a/vhdl_lang/src/named_entity.rs b/vhdl_lang/src/named_entity.rs index 4b850baf..5b419c86 100644 --- a/vhdl_lang/src/named_entity.rs +++ b/vhdl_lang/src/named_entity.rs @@ -412,7 +412,7 @@ impl<'a> AnyEnt<'a> { ) } - pub fn is_declared_by(&self, other: EntRef) -> bool { + pub fn is_declared_by(&self, other: EntRef<'_>) -> bool { if let Related::DeclaredBy(ent) = self.related { if ent.id() == other.id() { return true; @@ -431,7 +431,7 @@ impl<'a> AnyEnt<'a> { } } - pub fn is_instance_of(&self, other: EntRef) -> bool { + pub fn is_instance_of(&self, other: EntRef<'_>) -> bool { if let Related::InstanceOf(ent) = &self.related { ent.id() == other.id() } else { @@ -491,7 +491,7 @@ impl<'a> AnyEnt<'a> { } } - pub fn kind(&self) -> &AnyEntKind { + pub fn kind(&self) -> &AnyEntKind<'_> { &self.kind } @@ -510,14 +510,14 @@ impl<'a> AnyEnt<'a> { self.signature().is_some() } - pub fn signature(&self) -> Option<&Signature> { + pub fn signature(&self) -> Option<&Signature<'_>> { match self.actual_kind() { AnyEntKind::Overloaded(ref overloaded) => Some(overloaded.signature()), _ => None, } } - pub fn as_actual(&self) -> &AnyEnt { + pub fn as_actual(&self) -> EntRef<'_> { match self.kind() { AnyEntKind::Overloaded(Overloaded::Alias(ref ent)) => ent.as_actual(), AnyEntKind::Type(Type::Alias(ref ent)) => ent.as_actual(), @@ -562,12 +562,12 @@ impl<'a> AnyEnt<'a> { } /// Strip aliases and return reference to actual entity kind - pub fn actual_kind(&self) -> &AnyEntKind { + pub fn actual_kind(&self) -> &AnyEntKind<'_> { self.as_actual().kind() } /// Returns true if self is alias of other - pub fn is_alias_of(&self, other: &AnyEnt) -> bool { + pub fn is_alias_of(&self, other: EntRef<'_>) -> bool { match self.kind() { AnyEntKind::Type(Type::Alias(ref ent)) => { if ent.id() == other.id() { @@ -609,14 +609,16 @@ impl<'a> AnyEnt<'a> { #[allow(clippy::mut_from_ref)] #[allow(invalid_reference_casting)] unsafe fn unsafe_ref_mut(&self) -> &mut Self { - // NOTE: Use read_volatile to prevent compiler to optimization away assignment to the returned reference - let const_ptr = std::ptr::read_volatile(&self) as *const Self; - let mut_ptr = const_ptr as *mut Self; - &mut *mut_ptr + unsafe { + // NOTE: Use read_volatile to prevent compiler to optimization away assignment to the returned reference + let const_ptr = std::ptr::read_volatile(&self) as *const Self; + let mut_ptr = const_ptr as *mut Self; + &mut *mut_ptr + } } // Used to update the kind of pre-declared symbols that are visible before they have been fully analyzed - pub(crate) unsafe fn set_kind(&self, kind: AnyEntKind) { + pub(crate) unsafe fn set_kind(&self, kind: AnyEntKind<'_>) { unsafe { self.unsafe_ref_mut().kind = kind; } diff --git a/vhdl_lang/src/named_entity/arena.rs b/vhdl_lang/src/named_entity/arena.rs index 69bf6ff6..77a021b0 100644 --- a/vhdl_lang/src/named_entity/arena.rs +++ b/vhdl_lang/src/named_entity/arena.rs @@ -56,7 +56,7 @@ impl LocalArena { } } - unsafe fn alloc(&mut self, mut ent: AnyEnt) -> *const AnyEnt<'static> { + unsafe fn alloc(&mut self, mut ent: AnyEnt<'_>) -> *const AnyEnt<'static> { let idx = self.items.len(); if idx > u32::MAX as usize { @@ -65,22 +65,24 @@ impl LocalArena { let ent_id = EntityId::new_arena(self.id, LocalId(idx as u32)); ent.id = ent_id; - self.items - .push(std::mem::transmute::, AnyEnt<'_>>(ent)); - self.get(ent_id.local_id()) + unsafe { + self.items + .push(std::mem::transmute::, AnyEnt<'_>>(ent)); + self.get(ent_id.local_id()) + } } unsafe fn get(&self, id: LocalId) -> *const AnyEnt<'static> { self.panic_on_missing(id); let item = self.items.get(id.0 as usize).unwrap(); - std::pin::Pin::into_inner(item) as *const AnyEnt + std::pin::Pin::into_inner(item) as *const AnyEnt<'_> } - unsafe fn get_mut(&mut self, id: LocalId) -> *mut AnyEnt { + unsafe fn get_mut(&mut self, id: LocalId) -> *mut AnyEnt<'_> { self.panic_on_missing(id); let item = self.items.get_mut(id.0 as usize).unwrap(); - std::mem::transmute(std::pin::Pin::into_inner(item) as *mut AnyEnt) + unsafe { std::mem::transmute(std::pin::Pin::into_inner(item) as *mut AnyEnt<'_>) } } pub fn contains(&self, id: LocalId) -> bool { @@ -116,7 +118,7 @@ impl<'a> FinalArena { pub fn get(&'a self, id: EntityId) -> EntRef<'a> { unsafe { let ent = self.refs[&id.arena_id().0].get(id.local_id()); - &*ent as &'a AnyEnt + &*ent as &'a AnyEnt<'_> } } @@ -230,9 +232,9 @@ impl Arena { pub(crate) unsafe fn add_implicit<'a>(&'a self, id: EntityId, ent: EntRef<'a>) { let mut local = self.local.borrow_mut(); assert_eq!(id.arena_id(), local.id); - let eref = local.get_mut(id.local_id()); + let eref = unsafe { local.get_mut(id.local_id()) }; unsafe { - let eref: &mut AnyEnt = &mut *eref as &mut AnyEnt; + let eref: &mut AnyEnt<'_> = &mut *eref as &mut AnyEnt<'_>; eref.add_implicit(ent); } } @@ -245,9 +247,9 @@ impl Arena { ) -> Result<(), Diagnostic> { let mut local = self.local.borrow_mut(); assert_eq!(id.arena_id(), local.id); - let eref = local.get_mut(id.local_id()); unsafe { - let eref: &mut AnyEnt = &mut *eref as &mut AnyEnt; + let eref = local.get_mut(id.local_id()); + let eref: &mut AnyEnt<'_> = &mut *eref as &mut AnyEnt<'_>; eref.add_attribute(ent, pos) } } @@ -263,7 +265,7 @@ impl Arena { if p.id == id.arena_id() { // Try local first let ent = p.get(id.local_id()); - return &*ent as &'a AnyEnt; + return &*ent as EntRef<'a>; } } @@ -274,11 +276,11 @@ impl Arena { unsafe { let p = &*self.refs.as_ptr() as &FinalArena; let ent = p.get(id); - ent as &'a AnyEnt + ent as EntRef<'a> } } - pub fn get_type(&self, id: EntityId) -> TypeEnt { + pub fn get_type(&self, id: EntityId) -> TypeEnt<'_> { TypeEnt::from_any(self.get(id)).unwrap() } diff --git a/vhdl_lang/src/named_entity/attribute.rs b/vhdl_lang/src/named_entity/attribute.rs index 1c311da7..f862961d 100644 --- a/vhdl_lang/src/named_entity/attribute.rs +++ b/vhdl_lang/src/named_entity/attribute.rs @@ -6,7 +6,6 @@ use crate::ast::Designator; use crate::data::Symbol; -use crate::AnyEnt; use crate::AnyEntKind; use crate::EntRef; @@ -18,7 +17,7 @@ pub struct AttributeEnt<'a> { } impl<'a> AttributeEnt<'a> { - pub fn from_any(ent: &'a AnyEnt) -> Option { + pub fn from_any(ent: EntRef<'a>) -> Option { if let AnyEntKind::Attribute(..) = ent.actual_kind() { Some(AttributeEnt { ent }) } else { diff --git a/vhdl_lang/src/named_entity/formal_region.rs b/vhdl_lang/src/named_entity/formal_region.rs index 6a2b9cc2..049674ce 100644 --- a/vhdl_lang/src/named_entity/formal_region.rs +++ b/vhdl_lang/src/named_entity/formal_region.rs @@ -263,7 +263,7 @@ impl<'a> RecordRegion<'a> { self.elems.iter().cloned() } - pub fn add(&mut self, ent: &'a AnyEnt) { + pub fn add(&mut self, ent: EntRef<'a>) { if let Some(elem) = RecordElement::from_any(ent) { self.elems.push(elem); } else { diff --git a/vhdl_lang/src/named_entity/object.rs b/vhdl_lang/src/named_entity/object.rs index 9a7be6ef..f049c4d6 100644 --- a/vhdl_lang/src/named_entity/object.rs +++ b/vhdl_lang/src/named_entity/object.rs @@ -19,7 +19,7 @@ pub struct ObjectEnt<'a> { } impl<'a> ObjectEnt<'a> { - pub fn from_any(ent: &'a AnyEnt) -> Option { + pub fn from_any(ent: EntRef<'a>) -> Option { if matches!(ent.actual_kind(), AnyEntKind::Object(..)) { Some(Self { ent }) } else { @@ -110,7 +110,7 @@ impl ObjectInterface<'_> { } } - pub fn mode(&self) -> &InterfaceMode { + pub fn mode(&self) -> &InterfaceMode<'_> { match self { ObjectInterface::Generic => &InterfaceMode::Simple(Mode::In), ObjectInterface::Parameter(m) | ObjectInterface::Port(m) => m, @@ -164,7 +164,7 @@ impl<'a> Object<'a> { matches!(self.iface, Some(ObjectInterface::Parameter(_))) } - pub fn mode(&self) -> Option<&InterfaceMode> { + pub fn mode(&self) -> Option<&InterfaceMode<'_>> { self.iface.as_ref().map(|i| i.mode()) } } @@ -195,7 +195,7 @@ pub struct ViewEnt<'a> { } impl<'a> ViewEnt<'a> { - pub fn from_any(ent: &'a AnyEnt) -> Option { + pub fn from_any(ent: EntRef<'a>) -> Option { if matches!(ent.actual_kind(), AnyEntKind::View(..)) { Some(Self { ent }) } else { diff --git a/vhdl_lang/src/named_entity/overloaded.rs b/vhdl_lang/src/named_entity/overloaded.rs index 1043cd74..1d9df754 100644 --- a/vhdl_lang/src/named_entity/overloaded.rs +++ b/vhdl_lang/src/named_entity/overloaded.rs @@ -233,7 +233,7 @@ pub struct OverloadedEnt<'a> { } impl<'a> OverloadedEnt<'a> { - pub fn from_any(ent: &'a AnyEnt) -> Option { + pub fn from_any(ent: EntRef<'a>) -> Option { if let AnyEntKind::Overloaded(..) = ent.actual_kind() { Some(OverloadedEnt { ent }) } else { diff --git a/vhdl_lang/src/named_entity/region.rs b/vhdl_lang/src/named_entity/region.rs index 53c33906..3c29b753 100644 --- a/vhdl_lang/src/named_entity/region.rs +++ b/vhdl_lang/src/named_entity/region.rs @@ -227,7 +227,7 @@ pub struct OverloadedName<'a> { } impl<'a> OverloadedName<'a> { - pub fn new(entities: Vec) -> OverloadedName { + pub fn new(entities: Vec>) -> OverloadedName<'_> { debug_assert!(!entities.is_empty()); let mut map = FnvHashMap::default(); for ent in entities.into_iter() { @@ -236,7 +236,7 @@ impl<'a> OverloadedName<'a> { OverloadedName { entities: map } } - pub fn single(ent: OverloadedEnt) -> OverloadedName { + pub fn single(ent: OverloadedEnt<'_>) -> OverloadedName<'_> { let mut map = FnvHashMap::default(); map.insert(ent.subprogram_key(), ent); OverloadedName { entities: map } @@ -269,7 +269,7 @@ impl<'a> OverloadedName<'a> { self.entities().map(|ent| ent.signature()) } - pub fn get(&self, key: &SubprogramKey) -> Option> { + pub fn get(&self, key: &SubprogramKey<'_>) -> Option> { self.entities.get(key).cloned() } @@ -403,7 +403,7 @@ impl<'a> AsUnique<'a> for NamedEntities<'a> { } pub trait SetReference { - fn set_unique_reference(&mut self, ent: &AnyEnt); + fn set_unique_reference(&mut self, ent: EntRef<'_>); fn set_reference<'a>(&mut self, value: &'a impl AsUnique<'a>) { if let Some(ent) = value.as_unique() { @@ -413,31 +413,31 @@ pub trait SetReference { } impl SetReference for WithRef { - fn set_unique_reference(&mut self, ent: &AnyEnt) { + fn set_unique_reference(&mut self, ent: EntRef<'_>) { self.reference.set_unique_reference(ent); } } impl SetReference for WithTokenSpan { - fn set_unique_reference(&mut self, ent: &AnyEnt) { + fn set_unique_reference(&mut self, ent: EntRef<'_>) { self.item.set_unique_reference(ent); } } impl SetReference for WithToken { - fn set_unique_reference(&mut self, ent: &AnyEnt) { + fn set_unique_reference(&mut self, ent: EntRef<'_>) { self.item.set_unique_reference(ent); } } impl SetReference for Reference { - fn set_unique_reference(&mut self, ent: &AnyEnt) { + fn set_unique_reference(&mut self, ent: EntRef<'_>) { self.set(ent.id()); } } impl SetReference for Name { - fn set_unique_reference(&mut self, ent: &AnyEnt) { + fn set_unique_reference(&mut self, ent: EntRef<'_>) { if let Some(r) = self.suffix_reference_mut() { r.set_unique_reference(ent); } diff --git a/vhdl_lang/src/named_entity/types.rs b/vhdl_lang/src/named_entity/types.rs index 59dc436b..d4046a10 100644 --- a/vhdl_lang/src/named_entity/types.rs +++ b/vhdl_lang/src/named_entity/types.rs @@ -150,7 +150,7 @@ impl<'a> TypeEnt<'a> { TypeEnt(ent) } - pub fn from_any(ent: &'a AnyEnt) -> Option> { + pub fn from_any(ent: EntRef<'a>) -> Option> { if matches!(ent.kind(), AnyEntKind::Type(..)) { Some(TypeEnt(ent)) } else { diff --git a/vhdl_lang/src/named_entity/visibility.rs b/vhdl_lang/src/named_entity/visibility.rs index 4c0a612a..baba2eff 100644 --- a/vhdl_lang/src/named_entity/visibility.rs +++ b/vhdl_lang/src/named_entity/visibility.rs @@ -96,7 +96,7 @@ impl<'a> Visibility<'a> { &mut self, visible_pos: Option<&SrcPos>, designator: Designator, - ent: &'a AnyEnt, + ent: EntRef<'a>, ) { // Add implicit declarations when using declaration // For example all enum literals are made implicitly visible when using an enum type @@ -214,7 +214,7 @@ impl<'a> Visible<'a> { ErrorCode::ConflictingUseClause, ); - fn last_visible_pos(visible_entity: &VisibleEntity) -> u32 { + fn last_visible_pos(visible_entity: &VisibleEntity<'_>) -> u32 { if let Some(pos) = visible_entity.visible_pos.iter().rev().flatten().next() { return pos.range().start.line; } diff --git a/vhdl_lang/src/project.rs b/vhdl_lang/src/project.rs index 16701e1f..933b2afc 100644 --- a/vhdl_lang/src/project.rs +++ b/vhdl_lang/src/project.rs @@ -10,7 +10,7 @@ use crate::ast::DesignFile; use crate::completion::{list_completion_options, CompletionItem}; use crate::config::Config; use crate::lint::dead_code::UnusedDeclarationsLinter; -use crate::named_entity::{AnyEnt, EntRef}; +use crate::named_entity::EntRef; use crate::standard::VHDLStandard; use crate::syntax::VHDLParser; use crate::{data::*, EntHierarchy, EntityId}; @@ -252,17 +252,21 @@ impl Project { /// /// If the character value is greater than the line length it defaults back to the /// line length. - pub fn find_definition(&self, source: &Source, cursor: Position) -> Option { + pub fn find_definition(&self, source: &Source, cursor: Position) -> Option> { let ent = self.root.search_reference(source, cursor)?; self.root.find_definition_of(ent) } - pub fn find_declaration(&self, source: &Source, cursor: Position) -> Option { + pub fn find_declaration(&self, source: &Source, cursor: Position) -> Option> { let ent = self.root.search_reference(source, cursor)?; Some(ent.declaration()) } - pub fn item_at_cursor(&self, source: &Source, cursor: Position) -> Option<(SrcPos, EntRef)> { + pub fn item_at_cursor( + &self, + source: &Source, + cursor: Position, + ) -> Option<(SrcPos, EntRef<'_>)> { self.root.item_at_cursor(source, cursor) } @@ -284,7 +288,7 @@ impl Project { self.root.document_symbols(library_name, source) } - pub fn find_implementation(&self, source: &Source, cursor: Position) -> Vec { + pub fn find_implementation(&self, source: &Source, cursor: Position) -> Vec> { if let Some(ent) = self.find_declaration(source, cursor) { self.root.find_implementation(ent) } else { @@ -293,7 +297,7 @@ impl Project { } /// Search for the declaration at decl_pos and format it - pub fn format_declaration(&self, ent: &AnyEnt) -> Option { + pub fn format_declaration(&self, ent: EntRef<'_>) -> Option { self.root.format_declaration(ent) } @@ -303,11 +307,11 @@ impl Project { } /// Search for all references to the declaration at decl_pos - pub fn find_all_references(&self, ent: &AnyEnt) -> Vec { + pub fn find_all_references(&self, ent: EntRef<'_>) -> Vec { self.root.find_all_references(ent) } - pub fn find_all_references_in_source(&self, source: &Source, ent: &AnyEnt) -> Vec { + pub fn find_all_references_in_source(&self, source: &Source, ent: EntRef<'_>) -> Vec { self.root.find_all_references_in_source(source, ent) } @@ -325,7 +329,7 @@ impl Project { &self, source: &Source, cursor: Position, - ) -> Vec { + ) -> Vec> { list_completion_options(&self.root, source, cursor) } diff --git a/vhdl_lang/src/syntax/common.rs b/vhdl_lang/src/syntax/common.rs index a7994df2..02263cad 100644 --- a/vhdl_lang/src/syntax/common.rs +++ b/vhdl_lang/src/syntax/common.rs @@ -18,7 +18,7 @@ pub fn parse_optional( parse_fun: F, ) -> ParseResult> where - F: FnOnce(&mut ParsingContext) -> ParseResult, + F: FnOnce(&mut ParsingContext<'_>) -> ParseResult, { let optional = { if ctx.stream.skip_if_kind(keyword) { @@ -32,7 +32,7 @@ where } pub fn check_end_identifier_mismatch( - ctx: &mut ParsingContext, + ctx: &mut ParsingContext<'_>, ident: &WithToken, end_ident: Option>, ) -> Option { @@ -50,7 +50,7 @@ pub fn check_end_identifier_mismatch } pub fn check_label_identifier_mismatch( - ctx: &mut ParsingContext, + ctx: &mut ParsingContext<'_>, label: Option<&Ident>, end_ident: Option, ) -> Option { diff --git a/vhdl_lang/src/syntax/concurrent_statement.rs b/vhdl_lang/src/syntax/concurrent_statement.rs index 8f98e613..0d6f503c 100644 --- a/vhdl_lang/src/syntax/concurrent_statement.rs +++ b/vhdl_lang/src/syntax/concurrent_statement.rs @@ -475,7 +475,7 @@ fn parse_for_generate_statement( /// 11.8 Generate statements fn parse_if_generate_statement( - ctx: &mut ParsingContext, + ctx: &mut ParsingContext<'_>, label: Option<&Ident>, ) -> ParseResult { let mut conditionals = Vec::new(); diff --git a/vhdl_lang/src/syntax/declarative_part.rs b/vhdl_lang/src/syntax/declarative_part.rs index db6c9e88..eeef3872 100644 --- a/vhdl_lang/src/syntax/declarative_part.rs +++ b/vhdl_lang/src/syntax/declarative_part.rs @@ -42,7 +42,7 @@ pub fn parse_package_instantiation( }) } -pub fn is_declarative_part(ctx: &mut ParsingContext) -> ParseResult { +pub fn is_declarative_part(ctx: &mut ParsingContext<'_>) -> ParseResult { Ok(matches!( ctx.stream.peek_expect()?.kind, Use | Type diff --git a/vhdl_lang/src/syntax/interface_declaration.rs b/vhdl_lang/src/syntax/interface_declaration.rs index 1bcfdea8..372fc52a 100644 --- a/vhdl_lang/src/syntax/interface_declaration.rs +++ b/vhdl_lang/src/syntax/interface_declaration.rs @@ -284,7 +284,7 @@ fn parse_interface_package( } fn parse_interface_declaration( - ctx: &mut ParsingContext, + ctx: &mut ParsingContext<'_>, list_type: InterfaceType, ) -> ParseResult { peek_token!( @@ -441,17 +441,17 @@ fn parse_one_interface_declaration( } #[cfg(test)] -pub fn parse_parameter(ctx: &mut ParsingContext) -> ParseResult { +pub fn parse_parameter(ctx: &mut ParsingContext<'_>) -> ParseResult { parse_one_interface_declaration(ctx, InterfaceType::Parameter) } #[cfg(test)] -pub fn parse_port(ctx: &mut ParsingContext) -> ParseResult { +pub fn parse_port(ctx: &mut ParsingContext<'_>) -> ParseResult { parse_one_interface_declaration(ctx, InterfaceType::Port) } #[cfg(test)] -pub fn parse_generic(ctx: &mut ParsingContext) -> ParseResult { +pub fn parse_generic(ctx: &mut ParsingContext<'_>) -> ParseResult { parse_one_interface_declaration(ctx, InterfaceType::Generic) } diff --git a/vhdl_lang/src/syntax/range.rs b/vhdl_lang/src/syntax/range.rs index 7cdc4e6b..e97b787c 100644 --- a/vhdl_lang/src/syntax/range.rs +++ b/vhdl_lang/src/syntax/range.rs @@ -15,7 +15,7 @@ use crate::ast::*; use crate::data::Diagnostic; use vhdl_lang::syntax::parser::ParsingContext; -pub fn parse_direction(ctx: &mut ParsingContext) -> ParseResult { +pub fn parse_direction(ctx: &mut ParsingContext<'_>) -> ParseResult { Ok(expect_token!( ctx.stream, token, To => Direction::Ascending, diff --git a/vhdl_lang/src/syntax/test.rs b/vhdl_lang/src/syntax/test.rs index ad591aaf..054df7b5 100644 --- a/vhdl_lang/src/syntax/test.rs +++ b/vhdl_lang/src/syntax/test.rs @@ -508,7 +508,7 @@ impl Code { R: Debug, F: FnOnce(&mut ParsingContext<'_>) -> ParseResult, { - let parse_fun_eof = |ctx: &mut ParsingContext| { + let parse_fun_eof = |ctx: &mut ParsingContext<'_>| { let result = parse_fun(ctx); match result { Err(err) => { @@ -570,7 +570,7 @@ impl Code { } pub fn character(&self) -> WithToken { - self.parse_ok_no_diagnostics(|ctx: &mut ParsingContext| { + self.parse_ok_no_diagnostics(|ctx: &mut ParsingContext<'_>| { let id = ctx.stream.expect_kind(Kind::Character)?; ctx.stream.index(id).to_character_value(id) }) @@ -806,7 +806,7 @@ fn substr_range(source: &Source, range: Range, substr: &str, occurence: usize) - } /// Fast forward tokenstream until position -fn forward(stream: &TokenStream, start: Position) { +fn forward(stream: &TokenStream<'_>, start: Position) { // short-circuit when start is zero. // Also prevents the case where the token stream is empty if start.line == 0 && start.character == 0 { diff --git a/vhdl_lang/src/syntax/tokens/tokenizer.rs b/vhdl_lang/src/syntax/tokens/tokenizer.rs index 91d69143..3b48a6c1 100644 --- a/vhdl_lang/src/syntax/tokens/tokenizer.rs +++ b/vhdl_lang/src/syntax/tokens/tokenizer.rs @@ -977,7 +977,7 @@ fn can_be_char(last_token_kind: Option) -> bool { } fn parse_integer( - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, base: u64, stop_on_suffix: bool, ) -> Result<(u64, Latin1String), TokenError> { @@ -1055,7 +1055,7 @@ fn parse_integer( } } -fn parse_exponent(reader: &mut ContentReader) -> Result<(i32, Latin1String), TokenError> { +fn parse_exponent(reader: &mut ContentReader<'_>) -> Result<(i32, Latin1String), TokenError> { let start = reader.pos(); let mut buffer = Latin1String::empty(); let negative = { @@ -1106,7 +1106,7 @@ impl TokenState { // Assumes first quote is already consumed fn parse_quoted( buffer: &mut Latin1String, - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, quote: u8, include_quote: bool, ) -> Result { @@ -1157,13 +1157,13 @@ fn parse_quoted( // Assumes first quote is already consumed fn parse_string( buffer: &mut Latin1String, - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, ) -> Result { parse_quoted(buffer, reader, b'"', false) } /// Assume -- has already been consumed -fn parse_comment(reader: &mut ContentReader) -> Comment { +fn parse_comment(reader: &mut ContentReader<'_>) -> Comment { let start_pos = reader.pos().prev_char().prev_char(); let mut value = String::new(); while let Some(chr) = reader.peek_char() { @@ -1183,7 +1183,7 @@ fn parse_comment(reader: &mut ContentReader) -> Comment { } /// Assume /* has been consumed -fn parse_multi_line_comment(reader: &mut ContentReader) -> Result { +fn parse_multi_line_comment(reader: &mut ContentReader<'_>) -> Result { let start_pos = reader.pos().prev_char().prev_char(); let mut value = String::new(); while let Some(chr) = reader.pop_char() { @@ -1215,7 +1215,7 @@ fn parse_multi_line_comment(reader: &mut ContentReader) -> Result, ) -> Result<(f64, Latin1String), TokenError> { buffer.clear(); let mut text = Latin1String::empty(); @@ -1261,7 +1261,7 @@ fn exponentiate(value: u64, exp: u32) -> Option { /// LRM 15.5 Abstract literals fn parse_abstract_literal( buffer: &mut Latin1String, - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, ) -> Result<(Kind, Value), TokenError> { let state = reader.state(); let initial = parse_integer(reader, 10, true); @@ -1392,8 +1392,10 @@ fn parse_abstract_literal( /// LRM 15.8 Bit string literals /// Parse the base specifier such as ub, sx, b etc -/// Also requires and consumes the trailing quoute " -fn parse_base_specifier(reader: &mut ContentReader) -> Result, TokenError> { +/// Also requires and consumes the trailing quote " +fn parse_base_specifier( + reader: &mut ContentReader<'_>, +) -> Result, TokenError> { let base_specifier = match reader.pop_lowercase()? { Some(b'u') => match reader.pop_lowercase()? { Some(b'b') => BaseSpecifier::UB, @@ -1422,7 +1424,9 @@ fn parse_base_specifier(reader: &mut ContentReader) -> Result Result, TokenError> { +fn maybe_base_specifier( + reader: &mut ContentReader<'_>, +) -> Result, TokenError> { let mut lookahead = reader.clone(); if let Some(value) = parse_base_specifier(&mut lookahead)? { reader.set_to(&lookahead); @@ -1434,7 +1438,7 @@ fn maybe_base_specifier(reader: &mut ContentReader) -> Result, base_specifier: BaseSpecifier, bit_string_length: Option, start: usize, @@ -1468,7 +1472,7 @@ fn parse_bit_string( /// LRM 15.4 Identifiers fn parse_basic_identifier_or_keyword( buffer: &mut Latin1String, - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, symbols: &Symbols, ) -> Result<(Kind, Value), TokenError> { buffer.bytes.clear(); @@ -1490,7 +1494,7 @@ fn parse_basic_identifier_or_keyword( /// Assumes leading ' has already been consumed /// Only consumes from reader if Some is returned fn parse_character_literal( - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, ) -> Result, TokenError> { let mut lookahead = reader.clone(); @@ -1512,7 +1516,7 @@ fn parse_character_literal( /// Clears the buffer prior to reading fn read_until_newline( buffer: &mut Latin1String, - reader: &mut ContentReader, + reader: &mut ContentReader<'_>, ) -> Result<(), TokenError> { buffer.bytes.clear(); while let Some(b) = reader.peek()? { @@ -1525,7 +1529,7 @@ fn read_until_newline( Ok(()) } -fn get_leading_comments(reader: &mut ContentReader) -> Result, TokenError> { +fn get_leading_comments(reader: &mut ContentReader<'_>) -> Result, TokenError> { let mut comments: Vec = Vec::new(); loop { @@ -1566,7 +1570,7 @@ fn get_leading_comments(reader: &mut ContentReader) -> Result, Toke } /// Skip whitespace but not newline -fn skip_whitespace_in_line(reader: &mut ContentReader) { +fn skip_whitespace_in_line(reader: &mut ContentReader<'_>) { while let Ok(Some(byte)) = reader.peek() { match byte { b' ' | b'\t' => { @@ -1580,7 +1584,7 @@ fn skip_whitespace_in_line(reader: &mut ContentReader) { } /// Skip all whitespace -fn skip_whitespace(reader: &mut ContentReader) { +fn skip_whitespace(reader: &mut ContentReader<'_>) { while let Ok(Some(byte)) = reader.peek() { match byte { b' ' | b'\t' | b'\n' => { @@ -1593,7 +1597,7 @@ fn skip_whitespace(reader: &mut ContentReader) { } } -fn get_trailing_comment(reader: &mut ContentReader) -> Result, TokenError> { +fn get_trailing_comment(reader: &mut ContentReader<'_>) -> Result, TokenError> { skip_whitespace_in_line(reader); let state = reader.state(); diff --git a/vhdl_lang/src/syntax/tokens/tokenstream.rs b/vhdl_lang/src/syntax/tokens/tokenstream.rs index 2e9892a6..6e7b5393 100644 --- a/vhdl_lang/src/syntax/tokens/tokenstream.rs +++ b/vhdl_lang/src/syntax/tokens/tokenstream.rs @@ -32,7 +32,7 @@ impl<'a> TokenStream<'a> { /// This needs special handling as the text that follows the identifier is arbitrary. fn handle_tool_directive( grave_accent: Token, - tokenizer: &mut Tokenizer, + tokenizer: &mut Tokenizer<'_>, diagnostics: &mut dyn DiagnosticHandler, ) { let start_pos = grave_accent.pos.clone();