Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
aannleax committed Oct 29, 2024
1 parent 4cb1f50 commit e1c5df8
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions nemo/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> ParserErrorReport<'a> {
}
}

impl<'a> std::fmt::Debug for ParserErrorReport<'a> {
impl std::fmt::Debug for ParserErrorReport<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let reports = self.build_reports();

Expand All @@ -111,7 +111,7 @@ impl<'a> std::fmt::Debug for ParserErrorReport<'a> {
}
}

impl<'a> std::fmt::Display for ParserErrorReport<'a> {
impl std::fmt::Display for ParserErrorReport<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut buffer = Vec::new();
if self.write(&mut buffer).is_err() {
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/comment/closed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct ClosedComment<'a> {

const CONTEXT: ParserContext = ParserContext::Comment;

impl<'a> ClosedComment<'a> {
impl ClosedComment<'_> {
// NOTE: Should this return a &str, so that the consumer can decide whether to turn it into an
// owned value or not?
/// Return the content of the comment
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/comment/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct DocComment<'a> {
content: Vec<Span<'a>>,
}

impl<'a> DocComment<'a> {
impl DocComment<'_> {
/// Return the content of the comment
pub fn content(&self) -> Vec<String> {
self.content
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/comment/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct LineComment<'a> {

const CONTEXT: ParserContext = ParserContext::Comment;

impl<'a> LineComment<'a> {
impl LineComment<'_> {
/// Return the content of the comment
pub fn content(&self) -> String {
self.content.fragment().to_string()
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/comment/toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct TopLevelComment<'a> {

const CONTEXT: ParserContext = ParserContext::TopLevelComment;

impl<'a> TopLevelComment<'a> {
impl TopLevelComment<'_> {
/// Return the content of the comment
pub fn content(&self) -> Vec<String> {
self.content
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub enum Directive<'a> {
Unknown(UnknownDirective<'a>),
}

impl<'a> Directive<'a> {
impl Directive<'_> {
/// Return the context of the underlying directive.
pub fn context_type(&self) -> ParserContext {
match self {
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/expression/basic/iri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Iri<'a> {
content: Token<'a>,
}

impl<'a> Iri<'a> {
impl Iri<'_> {
/// Return the content of the iri.
pub fn content(&self) -> String {
self.content.to_string()
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum Guard<'a> {
Infix(InfixExpression<'a>),
}

impl<'a> Guard<'a> {
impl Guard<'_> {
/// Return the [ParserContext] of the underlying expression type.
pub fn context_type(&self) -> ParserContext {
match self {
Expand Down
6 changes: 3 additions & 3 deletions nemo/src/parser/ast/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Sequence<'a, T> {
elements: Vec<T>,
}

impl<'a, T> Sequence<'a, T> {
impl<T> Sequence<'_, T> {
/// Return an iterator over the elements.
pub fn iter(&self) -> impl Iterator<Item = &T> {
self.into_iter()
Expand Down Expand Up @@ -136,7 +136,7 @@ impl<'a, T: std::fmt::Debug + Sync + ProgramAST<'a>> ProgramAST<'a> for Sequence
}
}

impl<'a, 'b, T> IntoIterator for &'b Sequence<'a, T> {
impl<'b, T> IntoIterator for &'b Sequence<'_, T> {
type Item = &'b T;
type IntoIter = std::slice::Iter<'b, T>;

Expand All @@ -145,7 +145,7 @@ impl<'a, 'b, T> IntoIterator for &'b Sequence<'a, T> {
}
}

impl<'a, T> IntoIterator for Sequence<'a, T> {
impl<T> IntoIterator for Sequence<'_, T> {
type Item = T;
type IntoIter = IntoIter<T>;

Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/tag/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct AggregationTag<'a> {
kind: Option<AggregateKind>,
}

impl<'a> AggregationTag<'a> {
impl AggregationTag<'_> {
/// Return the [AggregateKind] that was parsed, if it is known.
pub fn operation(&self) -> Option<AggregateKind> {
self.kind
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/tag/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct DataTypeTag<'a> {
data_type: DataType,
}

impl<'a> DataTypeTag<'a> {
impl DataTypeTag<'_> {
/// Return the [DataType] that was parsed.
pub fn data_type(&self) -> DataType {
self.data_type
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/tag/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct OperationTag<'a> {
kind: OperationKind,
}

impl<'a> OperationTag<'a> {
impl OperationTag<'_> {
/// Return the [OperationKind] that was parsed.
pub fn operation(&self) -> OperationKind {
self.kind
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/tag/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct ParameterName<'a> {
parameter: Parameter,
}

impl<'a> ParameterName<'a> {
impl ParameterName<'_> {
/// Return the [Parameter] that was parsed.
pub fn parameter(&self) -> &Parameter {
&self.parameter
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/tag/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a> StructureTag<'a> {
}
}

impl<'a> Display for StructureTag<'a> {
impl Display for StructureTag<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.kind {
StructureTagKind::Plain(token) => token.fmt(f),
Expand Down
2 changes: 1 addition & 1 deletion nemo/src/parser/ast/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub struct Token<'a> {
kind: TokenKind,
}

impl<'a> Display for Token<'a> {
impl Display for Token<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.span.fmt(f)
}
Expand Down
10 changes: 5 additions & 5 deletions nemo/src/parser/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'a> ParserInput<'a> {
}
}

impl<'a> AsBytes for ParserInput<'a> {
impl AsBytes for ParserInput<'_> {
fn as_bytes(&self) -> &[u8] {
self.span.fragment().as_bytes()
}
Expand All @@ -41,7 +41,7 @@ impl<'a> nom::Compare<ParserInput<'a>> for ParserInput<'a> {
}
}

impl<'a> nom::Compare<&str> for ParserInput<'a> {
impl nom::Compare<&str> for ParserInput<'_> {
fn compare(&self, t: &str) -> nom::CompareResult {
self.span.compare(t)
}
Expand All @@ -51,7 +51,7 @@ impl<'a> nom::Compare<&str> for ParserInput<'a> {
}
}

impl<'a> nom::ExtendInto for ParserInput<'a> {
impl nom::ExtendInto for ParserInput<'_> {
type Item = char;

type Extender = String;
Expand All @@ -65,13 +65,13 @@ impl<'a> nom::ExtendInto for ParserInput<'a> {
}
}

impl<'a> nom::FindSubstring<&str> for ParserInput<'a> {
impl nom::FindSubstring<&str> for ParserInput<'_> {
fn find_substring(&self, substr: &str) -> Option<usize> {
self.span.find_substring(substr)
}
}

impl<'a> InputLength for ParserInput<'a> {
impl InputLength for ParserInput<'_> {
fn input_len(&self) -> usize {
self.span.input_len()
}
Expand Down
4 changes: 2 additions & 2 deletions nemo/src/parser/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'a> Span<'a> {
}
}

impl<'a> std::fmt::Display for Span<'a> {
impl std::fmt::Display for Span<'_> {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
self.fragment.fmt(formatter)
}
Expand Down Expand Up @@ -349,7 +349,7 @@ impl<'a> nom::Compare<Span<'a>> for Span<'a> {
}
}

impl<'a> nom::Compare<&str> for Span<'a> {
impl nom::Compare<&str> for Span<'_> {
fn compare(&self, t: &str) -> nom::CompareResult {
self.fragment.compare(t)
}
Expand Down
4 changes: 2 additions & 2 deletions nemo/src/rule_model/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<'a> ProgramErrorReport<'a> {
}
}

impl<'a> std::fmt::Debug for ProgramErrorReport<'a> {
impl std::fmt::Debug for ProgramErrorReport<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let reports = self.build_reports();

Expand All @@ -170,7 +170,7 @@ impl<'a> std::fmt::Debug for ProgramErrorReport<'a> {
}
}

impl<'a> std::fmt::Display for ProgramErrorReport<'a> {
impl std::fmt::Display for ProgramErrorReport<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut buffer = Vec::new();
if self.write(&mut buffer).is_err() {
Expand Down
5 changes: 2 additions & 3 deletions nemo/src/rule_model/translation/directive/import_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ impl<'a> ASTProgramTranslation<'a> {

if let Some((extension, origin)) = extension {
for &rdf_format in FILE_FORMATS_RDF {
if extension.to_ascii_lowercase()
== rdf_format.extension().to_ascii_lowercase()
if extension.eq_ignore_ascii_case(rdf_format.extension())
{
return Ok(rdf_format);
}
Expand All @@ -81,7 +80,7 @@ impl<'a> ASTProgramTranslation<'a> {
}
} else {
for format in FileFormat::iter() {
if format_tag.to_ascii_lowercase() == format.name().to_ascii_lowercase() {
if format_tag.eq_ignore_ascii_case(format.name()) {
return Ok(format);
}
}
Expand Down

0 comments on commit e1c5df8

Please sign in to comment.