Skip to content

Commit

Permalink
clippy: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed Dec 27, 2024
1 parent 4ed669e commit 1872b9a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ struct ObjCompiler<'c, 'v, 'l, 's, 'r, 'q> {
}

// compile supported drafts
impl<'c, 'v, 'l, 's, 'r, 'q> ObjCompiler<'c, 'v, 'l, 's, 'r, 'q> {
impl ObjCompiler<'_, '_, '_, '_, '_, '_> {
fn compile_obj(&mut self, s: &mut Schema) -> Result<(), CompileError> {
self.compile_draft4(s)?;
if self.draft_version() >= 6 {
Expand Down Expand Up @@ -628,7 +628,7 @@ impl<'c, 'v, 'l, 's, 'r, 'q> ObjCompiler<'c, 'v, 'l, 's, 'r, 'q> {
}

// enqueue helpers
impl<'c, 'v, 'l, 's, 'r, 'q> ObjCompiler<'c, 'v, 'l, 's, 'r, 'q> {
impl ObjCompiler<'_, '_, '_, '_, '_, '_> {
fn enqueue_schema(&mut self, ptr: JsonPointer) -> SchemaIndex {
let up = UrlPtr {
url: self.up.url.clone(),
Expand Down Expand Up @@ -701,7 +701,7 @@ impl<'c, 'v, 'l, 's, 'r, 'q> ObjCompiler<'c, 'v, 'l, 's, 'r, 'q> {
}

// query helpers
impl<'c, 'v, 'l, 's, 'r, 'q> ObjCompiler<'c, 'v, 'l, 's, 'r, 'q> {
impl<'v> ObjCompiler<'_, 'v, '_, '_, '_, '_> {
fn draft_version(&self) -> usize {
self.root.draft.version
}
Expand Down
4 changes: 2 additions & 2 deletions src/draft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ impl Draft {
// anchor with same root_ptr already exists
return Ok(());
}
return Err(CompileError::DuplicateAnchor {
Err(CompileError::DuplicateAnchor {
url: url.as_str().to_owned(),
anchor: entry.key().to_string(),
ptr1: entry.get().to_string(),
ptr2: sch_ptr.to_string(),
});
})
}
entry => {
entry.or_insert(sch_ptr.to_owned());
Expand Down
4 changes: 2 additions & 2 deletions src/ecma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct Translator<'a> {
out: Option<String>,
}

impl<'a> Translator<'a> {
impl Translator<'_> {
fn replace(&mut self, span: &Span, with: &str) {
let (start, end) = (span.start.offset, span.end.offset);
self.out = Some(format!("{}{with}{}", &self.pat[..start], &self.pat[end..]));
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<'a> Translator<'a> {
}
}

impl<'a> Visitor for Translator<'a> {
impl Visitor for Translator<'_> {
type Output = Option<String>;
type Err = &'static str;

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ pub struct ValidationError<'s, 'v> {
pub causes: Vec<ValidationError<'s, 'v>>,
}

impl<'s, 'v> Error for ValidationError<'s, 'v> {}
impl Error for ValidationError<'_, '_> {}

/// A list specifying general categories of validation errors.
#[derive(Debug)]
Expand Down Expand Up @@ -557,7 +557,7 @@ pub enum ErrorKind<'s, 'v> {
OneOf(Option<(usize, usize)>),
}

impl<'s, 'v> Display for ErrorKind<'s, 'v> {
impl Display for ErrorKind<'_, '_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Group => write!(f, "validation failed"),
Expand Down
5 changes: 2 additions & 3 deletions src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ impl DefaultUrlLoader {
})?
};
self.add_doc(url.clone(), doc);
return self
.get_doc(url)
.ok_or(CompileError::Bug("doc must exist".into()));
self.get_doc(url)
.ok_or(CompileError::Bug("doc must exist".into()))
}

pub(crate) fn get_draft(
Expand Down
22 changes: 11 additions & 11 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{

use crate::{util::*, ErrorKind, InstanceLocation, ValidationError};

impl<'s, 'v> ValidationError<'s, 'v> {
impl<'s> ValidationError<'s, '_> {
fn absolute_keyword_location(&self) -> AbsoluteKeywordLocation<'s> {
if let ErrorKind::Reference { url, .. } = &self.kind {
AbsoluteKeywordLocation {
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'s, 'v> ValidationError<'s, 'v> {

// DfsIterator --

impl<'s, 'v> Display for ValidationError<'s, 'v> {
impl Display for ValidationError<'_, '_> {
/// Formats error hierarchy. Use `#` to show the schema location.
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut indent = Indent::default();
Expand Down Expand Up @@ -282,7 +282,7 @@ impl<'a, 's, 'v> SchemaLocation<'a, 's, 'v> {
}
}

impl<'a, 's, 'v> Display for SchemaLocation<'a, 's, 'v> {
impl Display for SchemaLocation<'_, '_, '_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut iter = self.stack.iter().cloned();
let cur = iter.next_back().unwrap();
Expand Down Expand Up @@ -423,7 +423,7 @@ pub struct OutputUnit<'e, 's, 'v> {
pub error: OutputError<'e, 's, 'v>,
}

impl<'e, 's, 'v> Serialize for OutputUnit<'e, 's, 'v> {
impl Serialize for OutputUnit<'_, '_, '_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -445,7 +445,7 @@ impl<'e, 's, 'v> Serialize for OutputUnit<'e, 's, 'v> {
}
}

impl<'e, 's, 'v> Display for OutputUnit<'e, 's, 'v> {
impl Display for OutputUnit<'_, '_, '_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write_json_to_fmt(f, self)
}
Expand All @@ -459,7 +459,7 @@ pub enum OutputError<'e, 's, 'v> {
Branch(Vec<OutputUnit<'e, 's, 'v>>),
}

impl<'e, 's, 'v> Serialize for OutputError<'e, 's, 'v> {
impl Serialize for OutputError<'_, '_, '_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -479,10 +479,10 @@ impl<'e, 's, 'v> Serialize for OutputError<'e, 's, 'v> {

// AbsoluteKeywordLocation --

impl<'s, 'v> ErrorKind<'s, 'v> {
impl<'s> ErrorKind<'s, '_> {
pub fn keyword_path(&self) -> Option<KeywordPath<'s>> {
#[inline(always)]
fn kw(kw: &'static str) -> Option<KeywordPath> {
fn kw(kw: &'static str) -> Option<KeywordPath<'static>> {
Some(KeywordPath {
keyword: kw,
token: None,
Expand Down Expand Up @@ -550,7 +550,7 @@ pub struct AbsoluteKeywordLocation<'s> {
pub keyword_path: Option<KeywordPath<'s>>,
}

impl<'s> Display for AbsoluteKeywordLocation<'s> {
impl Display for AbsoluteKeywordLocation<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.schema_url.fmt(f)?;
if let Some(path) = &self.keyword_path {
Expand All @@ -577,7 +577,7 @@ pub struct KeywordPath<'s> {
pub token: Option<SchemaToken<'s>>,
}

impl<'s> Display for KeywordPath<'s> {
impl Display for KeywordPath<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.keyword.fmt(f)?;
if let Some(token) = &self.token {
Expand All @@ -597,7 +597,7 @@ pub enum SchemaToken<'s> {
Item(usize),
}

impl<'s> Display for SchemaToken<'s> {
impl Display for SchemaToken<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SchemaToken::Prop(p) => write!(f, "{}", escape(p)),
Expand Down
28 changes: 14 additions & 14 deletions src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct Validator<'v, 's, 'd, 'e> {
bool_result: bool, // is interested to know valid or not (but not actuall error)
}

impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl<'v, 's> Validator<'v, 's, '_, '_> {
fn validate(mut self) -> Result<Uneval<'v>, ValidationError<'s, 'v>> {
let s = self.schema;
let v = self.v;
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}

// type specific validations
impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl<'v> Validator<'v, '_, '_, '_> {
fn obj_validate(&mut self, obj: &'v Map<String, Value>) {
let s = self.schema;
macro_rules! add_err {
Expand Down Expand Up @@ -565,7 +565,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}

// references validation
impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl<'v, 's> Validator<'v, 's, '_, '_> {
fn refs_validate(&mut self) {
let s = self.schema;
macro_rules! add_err {
Expand Down Expand Up @@ -653,7 +653,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}

// conditional validation
impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl Validator<'_, '_, '_, '_> {
fn cond_validate(&mut self) {
let s = self.schema;
macro_rules! add_err {
Expand Down Expand Up @@ -746,7 +746,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}

// uneval validation
impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl Validator<'_, '_, '_, '_> {
fn uneval_validate(&mut self) {
let s = self.schema;
let v = self.v;
Expand Down Expand Up @@ -783,7 +783,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}

// validation helpers
impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl<'v, 's> Validator<'v, 's, '_, '_> {
fn validate_val(
&mut self,
sch: SchemaIndex,
Expand Down Expand Up @@ -843,7 +843,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}

// error helpers
impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
impl<'v, 's> Validator<'v, 's, '_, '_> {
#[inline(always)]
fn error(&self, kind: ErrorKind<'s, 'v>) -> ValidationError<'s, 'v> {
if self.bool_result {
Expand Down Expand Up @@ -981,7 +981,7 @@ struct Scope<'a> {
parent: Option<&'a Scope<'a>>,
}

impl<'a> Scope<'a> {
impl Scope<'_> {
fn child<'x>(
&'x self,
sch: SchemaIndex,
Expand Down Expand Up @@ -1020,7 +1020,7 @@ pub enum InstanceToken<'v> {
Item(usize),
}

impl<'v> From<String> for InstanceToken<'v> {
impl From<String> for InstanceToken<'_> {
fn from(prop: String) -> Self {
InstanceToken::Prop(prop.into())
}
Expand All @@ -1032,7 +1032,7 @@ impl<'v> From<&'v str> for InstanceToken<'v> {
}
}

impl<'v> From<usize> for InstanceToken<'v> {
impl From<usize> for InstanceToken<'_> {
fn from(index: usize) -> Self {
InstanceToken::Item(index)
}
Expand All @@ -1044,7 +1044,7 @@ pub struct InstanceLocation<'v> {
pub tokens: Vec<InstanceToken<'v>>,
}

impl<'v> InstanceLocation<'v> {
impl InstanceLocation<'_> {
fn new() -> Self {
Self::default()
}
Expand All @@ -1062,7 +1062,7 @@ impl<'v> InstanceLocation<'v> {
}
}

impl<'v> Display for InstanceLocation<'v> {
impl Display for InstanceLocation<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for tok in &self.tokens {
f.write_char('/')?;
Expand All @@ -1075,7 +1075,7 @@ impl<'v> Display for InstanceLocation<'v> {
}
}

impl<'s, 'v> ValidationError<'s, 'v> {
impl<'s> ValidationError<'s, '_> {
pub(crate) fn clone_static(self) -> ValidationError<'s, 'static> {
let mut causes = Vec::with_capacity(self.causes.len());
for cause in self.causes {
Expand All @@ -1090,7 +1090,7 @@ impl<'s, 'v> ValidationError<'s, 'v> {
}
}

impl<'s, 'v> ErrorKind<'s, 'v> {
impl<'s> ErrorKind<'s, '_> {
fn clone_static(self) -> ErrorKind<'s, 'static> {
use ErrorKind::*;
match self {
Expand Down

0 comments on commit 1872b9a

Please sign in to comment.