From a120d93e7d81a92ceebbf7bbd5c2c0609fdd3e0c Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sun, 17 Mar 2024 03:15:56 -0700 Subject: [PATCH] Enable the missing-errors-doc clippy checks --- parser/src/emitter.rs | 3 +++ parser/src/lib.rs | 5 +---- parser/src/parser.rs | 6 ++++++ parser/src/scanner.rs | 9 +++++++++ parser/src/yaml.rs | 6 ++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/parser/src/emitter.rs b/parser/src/emitter.rs index 213da01..0c365a8 100644 --- a/parser/src/emitter.rs +++ b/parser/src/emitter.rs @@ -168,6 +168,9 @@ impl<'a> YamlEmitter<'a> { self.multiline_strings } + /// Dump Yaml to an output stream. + /// # Errors + /// Returns `EmitError` when an error occurs. pub fn dump(&mut self, doc: &Yaml) -> EmitResult { // write DocumentStart writeln!(self.writer, "---")?; diff --git a/parser/src/lib.rs b/parser/src/lib.rs index 4ba632e..0651aea 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -31,10 +31,7 @@ //! ``` #![cfg_attr(feature = "cargo-clippy", warn(clippy::pedantic))] -#![cfg_attr( - feature = "cargo-clippy", - allow(clippy::should_implement_trait, clippy::missing_errors_doc,) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::should_implement_trait))] extern crate hashlink; diff --git a/parser/src/parser.rs b/parser/src/parser.rs index f6c2eb5..8c21edb 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -218,6 +218,8 @@ impl> Parser { /// /// Any subsequent call to [`Parser::peek`] will return the same value, until a call to /// [`Parser::next`] or [`Parser::load`]. + /// # Errors + /// Returns `ScanError` when loading the next event fails. pub fn peek(&mut self) -> Result<&(Event, Marker), ScanError> { if let Some(ref x) = self.current { Ok(x) @@ -228,6 +230,8 @@ impl> Parser { } /// Try to load the next event and return it, consuming it from `self`. + /// # Errors + /// Returns `ScanError` when loading the next event fails. pub fn next(&mut self) -> ParseResult { match self.current.take() { None => self.parse(), @@ -299,6 +303,8 @@ impl> Parser { /// /// Note that any [`EventReceiver`] is also a [`MarkedEventReceiver`], so implementing the /// former is enough to call this function. + /// # Errors + /// Returns `ScanError` when loading fails. pub fn load( &mut self, recv: &mut R, diff --git a/parser/src/scanner.rs b/parser/src/scanner.rs index 611d9c0..d6e9788 100644 --- a/parser/src/scanner.rs +++ b/parser/src/scanner.rs @@ -604,6 +604,9 @@ impl> Scanner { self.simple_key_allowed = false; } + /// Fetch the next token in the stream. + /// # Errors + /// Returns `ScanError` when the scanner does not find the next expected token. pub fn fetch_next_token(&mut self) -> ScanResult { self.lookahead(1); // eprintln!("--> fetch_next_token Cur {:?} {:?}", self.mark, self.ch()); @@ -708,6 +711,9 @@ impl> Scanner { } } + /// Return the next token in the stream. + /// # Errors + /// Returns `ScanError` when scanning fails to find an expected next token. pub fn next_token(&mut self) -> Result, ScanError> { if self.stream_end_produced { return Ok(None); @@ -731,6 +737,9 @@ impl> Scanner { Ok(Some(t)) } + /// Fetch tokens from the token stream. + /// # Errors + /// Returns `ScanError` when loading fails. pub fn fetch_more_tokens(&mut self) -> ScanResult { let mut need_more; loop { diff --git a/parser/src/yaml.rs b/parser/src/yaml.rs index 50d0b85..3e2298a 100644 --- a/parser/src/yaml.rs +++ b/parser/src/yaml.rs @@ -208,6 +208,8 @@ impl YamlLoader { /// The `source` is interpreted as YAML documents and is parsed. Parsing succeeds if and only /// if all documents are parsed successfully. An error in a latter document prevents the former /// from being returned. + /// # Errors + /// Returns `ScanError` when loading fails. pub fn load_from_str(source: &str) -> Result, ScanError> { Self::load_from_iter(source.chars()) } @@ -217,6 +219,8 @@ impl YamlLoader { /// The `source` is interpreted as YAML documents and is parsed. Parsing succeeds if and only /// if all documents are parsed successfully. An error in a latter document prevents the former /// from being returned. + /// # Errors + /// Returns `ScanError` when loading fails. pub fn load_from_iter>(source: I) -> Result, ScanError> { let mut loader = YamlLoader::default(); let mut parser = Parser::new(source); @@ -259,6 +263,8 @@ impl YamlDecoder { self } + /// # Errors + /// Returns `LoadError` when decoding fails. pub fn decode(&mut self) -> Result, LoadError> { let mut buffer = Vec::new(); self.source.read_to_end(&mut buffer)?;