diff --git a/py/src/lib.rs b/py/src/lib.rs index 89fbbdfa..200b2f69 100644 --- a/py/src/lib.rs +++ b/py/src/lib.rs @@ -1,9 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 -// This happens in PyO3 generated code, and there doesn't seem to be a more +// These happen in PyO3 generated code, and there doesn't seem to be a more // narrow scope that this can be disabled in (clippy seems a bit confused about // the code causing the warning, in general). #![allow(clippy::needless_option_as_deref)] +#![allow(clippy::borrow_deref_ref)] use pyo3::exceptions::PyValueError; use pyo3::prelude::*; diff --git a/rs/src/export/mod.rs b/rs/src/export/mod.rs index 2a865667..9f7d0964 100644 --- a/rs/src/export/mod.rs +++ b/rs/src/export/mod.rs @@ -10,7 +10,7 @@ mod proto; use crate::output::parse_result; /// Supported output formats for exporting. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Format { /// Emit a newline-separated, flattened list of diagnostics. Diagnostics, diff --git a/rs/src/input/proto.rs b/rs/src/input/proto.rs index 27c4a62f..6cd28959 100644 --- a/rs/src/input/proto.rs +++ b/rs/src/input/proto.rs @@ -17,7 +17,8 @@ use crate::output::primitive_data; use heck::ToUpperCamelCase; -#[allow(clippy::large_enum_variant)] +#[allow(clippy::large_enum_variant)] // caused by generated code +#[allow(clippy::derive_partial_eq_without_eq)] // caused by generated code pub mod substrait { include!(concat!(env!("OUT_DIR"), "/substrait.rs")); pub mod extensions { diff --git a/rs/src/output/comment.rs b/rs/src/output/comment.rs index 45542ad0..9ddd3ca2 100644 --- a/rs/src/output/comment.rs +++ b/rs/src/output/comment.rs @@ -11,7 +11,7 @@ use crate::output::path; /// Representation of a comment message intended only for human consumption. /// Includes basic formatting information. -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct Comment { /// Formatting elements and spans that make up the comment. elements: Vec, @@ -176,7 +176,7 @@ impl From for Comment { } /// A comment element. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Element { /// A span of text. Should not include newlines. Span(Span), @@ -195,7 +195,7 @@ pub enum Element { } /// Like Comment, but single-line. -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq, Default, Eq)] pub struct Brief { /// Spans that make up the comment. These are simply concatenated, but /// spans may contain optional formatting information. @@ -293,7 +293,7 @@ impl From for Comment { } /// A span of text within a comment. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Span { /// The span of text. pub text: String, @@ -331,7 +331,7 @@ fn merge_spans(mut a: Span, b: Span) -> (Span, Option) { } /// A link to something. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Link { /// Link to another node in the tree, via an absolute node path. Path(path::PathBuf), diff --git a/rs/src/output/extension.rs b/rs/src/output/extension.rs index b2e2b7af..02a0afc7 100644 --- a/rs/src/output/extension.rs +++ b/rs/src/output/extension.rs @@ -119,7 +119,7 @@ impl std::fmt::Display for Reference { } /// User-defined type class. -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct DataType { /// The underlying structure of the type. pub structure: Vec<(String, data_type::Simple)>, @@ -132,7 +132,7 @@ pub struct DataType { } /// A parameter slot for a user-defined data type. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct DataTypeParameterSlot { /// YAML-provided name of the parameter. pub name: String, @@ -149,7 +149,7 @@ pub struct DataTypeParameterSlot { } /// Expected metatype and bounds for a type parameter. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum DataTypeParameterBounds { /// The parameter must be bound to a (nested) data type. DataType, @@ -209,7 +209,7 @@ impl TypeVariation { } /// Type variation function behavior. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum FunctionBehavior { Inherits, Separate, @@ -222,7 +222,7 @@ impl Default for FunctionBehavior { } /// Function extension. -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct Function { // TODO: need much more information here to do type checking. } diff --git a/rs/src/output/parse_result.rs b/rs/src/output/parse_result.rs index 29130846..9ce96fda 100644 --- a/rs/src/output/parse_result.rs +++ b/rs/src/output/parse_result.rs @@ -13,7 +13,7 @@ use crate::output::tree; /// are more sensible in the context of a diagnostic, while the names for /// Validity are more sensible when talking about a validation result as a /// whole. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Validity { /// The plan is valid. Valid, diff --git a/rs/src/output/path.rs b/rs/src/output/path.rs index 98c935f1..0c4f7a63 100644 --- a/rs/src/output/path.rs +++ b/rs/src/output/path.rs @@ -11,7 +11,7 @@ use crate::util; /// Element of a path to some field of a protobuf message and/or YAML file. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum PathElement { /// Refers to an optional protobuf field with the given name within the /// message, or a YAML map entry with the given key. @@ -63,7 +63,7 @@ impl PathElement { } /// Refers to a location within a protobuf message. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct PathBuf { pub root: &'static str, pub elements: Vec, diff --git a/rs/src/output/tree.rs b/rs/src/output/tree.rs index c3d10252..92b51848 100644 --- a/rs/src/output/tree.rs +++ b/rs/src/output/tree.rs @@ -214,7 +214,7 @@ pub enum NodeType { } /// Semantical information about a node. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Class { /// Used for nodes for which no better classification exists. Misc, diff --git a/rs/src/parse/expressions/literals.rs b/rs/src/parse/expressions/literals.rs index 9c5fdf78..f7a19563 100644 --- a/rs/src/parse/expressions/literals.rs +++ b/rs/src/parse/expressions/literals.rs @@ -587,7 +587,7 @@ fn parse_interval_year_to_month( } }); let months = x.months.saturating_add(x.years.saturating_mul(12)); - if months < -120000 || months > 120000 { + if !(-120000..=120000).contains(&months) { diagnostic!( y, Error, diff --git a/rs/src/parse/expressions/references/mod.rs b/rs/src/parse/expressions/references/mod.rs index 5775a01c..0a38430b 100644 --- a/rs/src/parse/expressions/references/mod.rs +++ b/rs/src/parse/expressions/references/mod.rs @@ -36,7 +36,7 @@ impl Default for Root { } /// Description of a reference path. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ReferencePath { // *Reversed* list of segments. segments: Vec, diff --git a/rs/src/parse/mod.rs b/rs/src/parse/mod.rs index d35e493b..6bbde72a 100644 --- a/rs/src/parse/mod.rs +++ b/rs/src/parse/mod.rs @@ -59,8 +59,8 @@ //! - returning as many diagnostics as possible, rather than just stopping //! at the first sight of trouble. //! -//! Diagnostics can be pushed into the parser context using the [`diagnostic!`] -//! and [`ediagnostic!`] macros. The latter allows third-party `Err` types to +//! Diagnostics can be pushed into the parser context using the `diagnostic!` +//! and `ediagnostic!` macros. The latter allows third-party `Err` types to //! be pushed as the message, the former uses a [format!] syntax. However, //! sometimes it also very useful to just use the `?` operator for something. //! Therefore, parse functions also return @@ -74,8 +74,7 @@ //! found in the docs for the [diagnostic](crate::output::diagnostic) module. //! //! Beyond diagnostics, it's also possible to push comments into the context. -//! This can be done using the [`comment!`] and [`link!`] macros, or, for more -//! control, by pushing a [] +//! This can be done using the `comment!` and `link!` macros. //! //! ## Data types //!