Enable the missing-errors-doc clippy checks

This commit is contained in:
David Aguilar 2024-03-17 03:15:56 -07:00 committed by Ethiraric
parent 4c64feb5ad
commit 429813a0cd
5 changed files with 25 additions and 4 deletions

View file

@ -168,6 +168,9 @@ impl<'a> YamlEmitter<'a> {
self.multiline_strings self.multiline_strings
} }
/// Dump Yaml to an output stream.
/// # Errors
/// Returns `EmitError` when an error occurs.
pub fn dump(&mut self, doc: &Yaml) -> EmitResult { pub fn dump(&mut self, doc: &Yaml) -> EmitResult {
// write DocumentStart // write DocumentStart
writeln!(self.writer, "---")?; writeln!(self.writer, "---")?;

View file

@ -31,10 +31,7 @@
//! ``` //! ```
#![cfg_attr(feature = "cargo-clippy", warn(clippy::pedantic))] #![cfg_attr(feature = "cargo-clippy", warn(clippy::pedantic))]
#![cfg_attr( #![cfg_attr(feature = "cargo-clippy", allow(clippy::should_implement_trait))]
feature = "cargo-clippy",
allow(clippy::should_implement_trait, clippy::missing_errors_doc,)
)]
extern crate hashlink; extern crate hashlink;

View file

@ -218,6 +218,8 @@ impl<T: Iterator<Item = char>> Parser<T> {
/// ///
/// Any subsequent call to [`Parser::peek`] will return the same value, until a call to /// Any subsequent call to [`Parser::peek`] will return the same value, until a call to
/// [`Parser::next`] or [`Parser::load`]. /// [`Parser::next`] or [`Parser::load`].
/// # Errors
/// Returns `ScanError` when loading the next event fails.
pub fn peek(&mut self) -> Result<&(Event, Marker), ScanError> { pub fn peek(&mut self) -> Result<&(Event, Marker), ScanError> {
if let Some(ref x) = self.current { if let Some(ref x) = self.current {
Ok(x) Ok(x)
@ -228,6 +230,8 @@ impl<T: Iterator<Item = char>> Parser<T> {
} }
/// Try to load the next event and return it, consuming it from `self`. /// 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 { pub fn next(&mut self) -> ParseResult {
match self.current.take() { match self.current.take() {
None => self.parse(), None => self.parse(),
@ -299,6 +303,8 @@ impl<T: Iterator<Item = char>> Parser<T> {
/// ///
/// Note that any [`EventReceiver`] is also a [`MarkedEventReceiver`], so implementing the /// Note that any [`EventReceiver`] is also a [`MarkedEventReceiver`], so implementing the
/// former is enough to call this function. /// former is enough to call this function.
/// # Errors
/// Returns `ScanError` when loading fails.
pub fn load<R: MarkedEventReceiver>( pub fn load<R: MarkedEventReceiver>(
&mut self, &mut self,
recv: &mut R, recv: &mut R,

View file

@ -604,6 +604,9 @@ impl<T: Iterator<Item = char>> Scanner<T> {
self.simple_key_allowed = false; 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 { pub fn fetch_next_token(&mut self) -> ScanResult {
self.lookahead(1); self.lookahead(1);
// eprintln!("--> fetch_next_token Cur {:?} {:?}", self.mark, self.ch()); // eprintln!("--> fetch_next_token Cur {:?} {:?}", self.mark, self.ch());
@ -708,6 +711,9 @@ impl<T: Iterator<Item = char>> Scanner<T> {
} }
} }
/// 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<Option<Token>, ScanError> { pub fn next_token(&mut self) -> Result<Option<Token>, ScanError> {
if self.stream_end_produced { if self.stream_end_produced {
return Ok(None); return Ok(None);
@ -731,6 +737,9 @@ impl<T: Iterator<Item = char>> Scanner<T> {
Ok(Some(t)) Ok(Some(t))
} }
/// Fetch tokens from the token stream.
/// # Errors
/// Returns `ScanError` when loading fails.
pub fn fetch_more_tokens(&mut self) -> ScanResult { pub fn fetch_more_tokens(&mut self) -> ScanResult {
let mut need_more; let mut need_more;
loop { loop {

View file

@ -208,6 +208,8 @@ impl YamlLoader {
/// The `source` is interpreted as YAML documents and is parsed. Parsing succeeds if and only /// 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 /// if all documents are parsed successfully. An error in a latter document prevents the former
/// from being returned. /// from being returned.
/// # Errors
/// Returns `ScanError` when loading fails.
pub fn load_from_str(source: &str) -> Result<Vec<Yaml>, ScanError> { pub fn load_from_str(source: &str) -> Result<Vec<Yaml>, ScanError> {
Self::load_from_iter(source.chars()) 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 /// 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 /// if all documents are parsed successfully. An error in a latter document prevents the former
/// from being returned. /// from being returned.
/// # Errors
/// Returns `ScanError` when loading fails.
pub fn load_from_iter<I: Iterator<Item = char>>(source: I) -> Result<Vec<Yaml>, ScanError> { pub fn load_from_iter<I: Iterator<Item = char>>(source: I) -> Result<Vec<Yaml>, ScanError> {
let mut loader = YamlLoader::default(); let mut loader = YamlLoader::default();
let mut parser = Parser::new(source); let mut parser = Parser::new(source);
@ -259,6 +263,8 @@ impl<T: std::io::Read> YamlDecoder<T> {
self self
} }
/// # Errors
/// Returns `LoadError` when decoding fails.
pub fn decode(&mut self) -> Result<Vec<Yaml>, LoadError> { pub fn decode(&mut self) -> Result<Vec<Yaml>, LoadError> {
let mut buffer = Vec::new(); let mut buffer = Vec::new();
self.source.read_to_end(&mut buffer)?; self.source.read_to_end(&mut buffer)?;