From 1b788f3f2137a798a03c083cf3ff17eafbb5cee7 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 2 Oct 2023 12:04:55 -0400 Subject: [PATCH] Fix lifetimes on StandardProperties. --- src/types/document.rs | 8 ++-- src/types/element.rs | 2 +- src/types/get_standard_properties.rs | 4 +- src/types/greater_element.rs | 20 +++++----- src/types/lesser_element.rs | 32 ++++++++-------- src/types/object.rs | 56 ++++++++++++++-------------- src/types/standard_properties.rs | 2 +- 7 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/types/document.rs b/src/types/document.rs index 6066873..31f471c 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -50,7 +50,7 @@ pub enum TodoKeywordType { } impl<'s> GetStandardProperties<'s> for DocumentElement<'s> { - fn get_standard_properties(&'s self) -> &'s dyn StandardProperties { + fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s> { match self { DocumentElement::Heading(inner) => inner, DocumentElement::Section(inner) => inner, @@ -59,19 +59,19 @@ impl<'s> GetStandardProperties<'s> for DocumentElement<'s> { } impl<'s> StandardProperties<'s> for Document<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Section<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Heading<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } diff --git a/src/types/element.rs b/src/types/element.rs index a5c472c..020b2d1 100644 --- a/src/types/element.rs +++ b/src/types/element.rs @@ -81,7 +81,7 @@ impl<'s> SetSource<'s> for Element<'s> { } impl<'s> GetStandardProperties<'s> for Element<'s> { - fn get_standard_properties(&'s self) -> &'s dyn StandardProperties { + fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s> { match self { Element::Paragraph(inner) => inner, Element::PlainList(inner) => inner, diff --git a/src/types/get_standard_properties.rs b/src/types/get_standard_properties.rs index 3488d30..ae6464b 100644 --- a/src/types/get_standard_properties.rs +++ b/src/types/get_standard_properties.rs @@ -2,11 +2,11 @@ use super::StandardProperties; pub trait GetStandardProperties<'s> { // TODO: Can I eliminate this dynamic dispatch, perhaps using nominal generic structs? Low prioritiy since this is not used during parsing. - fn get_standard_properties(&'s self) -> &'s dyn StandardProperties; + fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s>; } impl<'s, I: StandardProperties<'s>> GetStandardProperties<'s> for I { - fn get_standard_properties(&'s self) -> &'s dyn StandardProperties { + fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s> { self } } diff --git a/src/types/greater_element.rs b/src/types/greater_element.rs index 85f4c57..9285d98 100644 --- a/src/types/greater_element.rs +++ b/src/types/greater_element.rs @@ -99,61 +99,61 @@ pub struct TableRow<'s> { } impl<'s> StandardProperties<'s> for PlainList<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for PlainListItem<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for GreaterBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for DynamicBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for FootnoteDefinition<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Drawer<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for PropertyDrawer<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for NodeProperty<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Table<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for TableRow<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index 80c3d51..1061139 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -115,93 +115,93 @@ impl<'s> Paragraph<'s> { } impl<'s> StandardProperties<'s> for Paragraph<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for TableCell<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Comment<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for VerseBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for CommentBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for ExampleBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for ExportBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for SrcBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Clock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for DiarySexp<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Planning<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for FixedWidthArea<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for HorizontalRule<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Keyword<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for BabelCall<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for LatexEnvironment<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } diff --git a/src/types/object.rs b/src/types/object.rs index 11a07f7..2d8e06e 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -187,7 +187,7 @@ pub struct Timestamp<'s> { } impl<'s> GetStandardProperties<'s> for Object<'s> { - fn get_standard_properties(&'s self) -> &'s dyn StandardProperties { + fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s> { match self { Object::Bold(inner) => inner, Object::Italic(inner) => inner, @@ -221,163 +221,163 @@ impl<'s> GetStandardProperties<'s> for Object<'s> { } impl<'s> StandardProperties<'s> for Bold<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Italic<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Underline<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for StrikeThrough<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Code<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Verbatim<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for RegularLink<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for RadioLink<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for RadioTarget<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for PlainLink<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for AngleLink<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for OrgMacro<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Entity<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for LatexFragment<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for ExportSnippet<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for FootnoteReference<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Citation<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for CitationReference<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for InlineBabelCall<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for InlineSourceBlock<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for LineBreak<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Target<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for StatisticsCookie<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Subscript<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Superscript<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for Timestamp<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } impl<'s> StandardProperties<'s> for PlainText<'s> { - fn get_source(&'s self) -> &'s str { + fn get_source<'b>(&'b self) -> &'s str { self.source } } diff --git a/src/types/standard_properties.rs b/src/types/standard_properties.rs index f6a3987..aa57962 100644 --- a/src/types/standard_properties.rs +++ b/src/types/standard_properties.rs @@ -3,7 +3,7 @@ pub trait StandardProperties<'s> { /// Get the slice of the entire AST node. /// /// This corresponds to :begin to :end in upstream org-mode's standard properties. - fn get_source(&'s self) -> &'s str; + fn get_source<'b>(&'b self) -> &'s str; // Get the slice of the AST node's contents. //