Skip to content

feat: better `Literal` handling in Turtle

Sign in for the full log view
GitHub Actions / clippy failed Oct 16, 2024 in 0s

clippy

2 errors

Details

Results

Message level Amount
Internal compiler error 0
Error 2
Warning 0
Note 0
Help 0

Versions

  • rustc 1.81.0 (eeb90cda1 2024-09-04)
  • cargo 1.81.0 (2dbb1af80 2024-08-20)
  • clippy 0.1.81 (eeb90cd 2024-09-04)

Annotations

Check failure on line 603 in rdftk_io/src/turtle/writer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

passing a unit value to a function

error: passing a unit value to a function
   --> rdftk_io/src/turtle/writer.rs:570:9
    |
570 | /         Ok(if let Some(literal) = literal.as_literal() {
571 | |             match literal.data_type() {
572 | |                 Some(DataType::Iri) => {
573 | |                     let iri = Iri::parse(literal.lexical_form())?;
...   |
602 | |             panic!("ERROR: this is not a literal: {:?}", literal)
603 | |         })
    | |__________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
    = note: `-D clippy::unit-arg` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unit_arg)]`
help: move the expression in front of the call and replace it with the unit literal `()`
    |
570 ~         if let Some(literal) = literal.as_literal() {
571 +             match literal.data_type() {
572 +                 Some(DataType::Iri) => {
573 +                     let iri = Iri::parse(literal.lexical_form())?;
574 +                     self.write_iri(w, graph, &iri)?
575 +                 }
576 +                 Some(DataType::Boolean)
577 +                 | Some(DataType::Long)
578 +                 | Some(DataType::Int)
579 +                 | Some(DataType::Short)
580 +                 | Some(DataType::Byte)
581 +                 | Some(DataType::UnsignedLong)
582 +                 | Some(DataType::UnsignedInt)
583 +                 | Some(DataType::UnsignedShort)
584 +                 | Some(DataType::UnsignedByte)
585 +                 | Some(DataType::Float)
586 +                 | Some(DataType::Double)
587 +                 | Some(DataType::Decimal) => write!(w, "{}", literal.lexical_form())?,
588 +                 _ => {
589 +                     write!(w, "{:?}", literal.lexical_form())?;
590 +                     match (literal.data_type(), literal.language()) {
591 +                         (Some(data_type), None) => {
592 +                             write!(w, "^^")?;
593 +                             let iri = data_type.as_iri();
594 +                             self.write_iri(w, graph, iri)?;
595 +                         }
596 +                         (None, Some(language)) => write!(w, "@{}", language)?,
597 +                         _ => (),
598 +                     }
599 +                 }
600 +             }
601 +         } else {
602 +             panic!("ERROR: this is not a literal: {:?}", literal)
603 +         };
604 +         Ok(())
    |

Check failure on line 603 in rdftk_io/src/turtle/writer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

passing a unit value to a function

error: passing a unit value to a function
   --> rdftk_io/src/turtle/writer.rs:570:9
    |
570 | /         Ok(if let Some(literal) = literal.as_literal() {
571 | |             match literal.data_type() {
572 | |                 Some(DataType::Iri) => {
573 | |                     let iri = Iri::parse(literal.lexical_form())?;
...   |
602 | |             panic!("ERROR: this is not a literal: {:?}", literal)
603 | |         })
    | |__________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
    = note: `-D clippy::unit-arg` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unit_arg)]`
help: move the expression in front of the call and replace it with the unit literal `()`
    |
570 ~         if let Some(literal) = literal.as_literal() {
571 +             match literal.data_type() {
572 +                 Some(DataType::Iri) => {
573 +                     let iri = Iri::parse(literal.lexical_form())?;
574 +                     self.write_iri(w, graph, &iri)?
575 +                 }
576 +                 Some(DataType::Boolean)
577 +                 | Some(DataType::Long)
578 +                 | Some(DataType::Int)
579 +                 | Some(DataType::Short)
580 +                 | Some(DataType::Byte)
581 +                 | Some(DataType::UnsignedLong)
582 +                 | Some(DataType::UnsignedInt)
583 +                 | Some(DataType::UnsignedShort)
584 +                 | Some(DataType::UnsignedByte)
585 +                 | Some(DataType::Float)
586 +                 | Some(DataType::Double)
587 +                 | Some(DataType::Decimal) => write!(w, "{}", literal.lexical_form())?,
588 +                 _ => {
589 +                     write!(w, "{:?}", literal.lexical_form())?;
590 +                     match (literal.data_type(), literal.language()) {
591 +                         (Some(data_type), None) => {
592 +                             write!(w, "^^")?;
593 +                             let iri = data_type.as_iri();
594 +                             self.write_iri(w, graph, iri)?;
595 +                         }
596 +                         (None, Some(language)) => write!(w, "@{}", language)?,
597 +                         _ => (),
598 +                     }
599 +                 }
600 +             }
601 +         } else {
602 +             panic!("ERROR: this is not a literal: {:?}", literal)
603 +         };
604 +         Ok(())
    |