From b901b16618651245e78bf6cf9aa5f65cbd88db96 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 07:35:15 +0000 Subject: [PATCH 1/9] Update Rust toolchains to nightly-2023-11-20 --- apps/hash-graph/rust-toolchain.toml | 2 +- libs/@local/codec/rust-toolchain.toml | 2 +- libs/@local/hash-authorization/rust-toolchain.toml | 2 +- libs/@local/hash-graph-types/rust/rust-toolchain.toml | 2 +- libs/@local/hash-validation/rust-toolchain.toml | 2 +- libs/@local/status/rust/rust-toolchain.toml | 2 +- libs/@local/temporal-versioning/rust-toolchain.toml | 2 +- libs/antsi/rust-toolchain.toml | 2 +- libs/deer/rust-toolchain.toml | 2 +- libs/error-stack/README.md | 2 +- libs/error-stack/macros/README.md | 2 +- libs/error-stack/rust-toolchain.toml | 2 +- libs/error-stack/src/lib.rs | 2 +- libs/sarif/rust-toolchain.toml | 2 +- tests/hash-graph-integration/rust-toolchain.toml | 2 +- tests/hash-graph-test-data/rust/rust-toolchain.toml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/hash-graph/rust-toolchain.toml b/apps/hash-graph/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/apps/hash-graph/rust-toolchain.toml +++ b/apps/hash-graph/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/codec/rust-toolchain.toml b/libs/@local/codec/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/@local/codec/rust-toolchain.toml +++ b/libs/@local/codec/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-authorization/rust-toolchain.toml b/libs/@local/hash-authorization/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/@local/hash-authorization/rust-toolchain.toml +++ b/libs/@local/hash-authorization/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-graph-types/rust/rust-toolchain.toml b/libs/@local/hash-graph-types/rust/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/@local/hash-graph-types/rust/rust-toolchain.toml +++ b/libs/@local/hash-graph-types/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-validation/rust-toolchain.toml b/libs/@local/hash-validation/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/@local/hash-validation/rust-toolchain.toml +++ b/libs/@local/hash-validation/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/status/rust/rust-toolchain.toml b/libs/@local/status/rust/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/@local/status/rust/rust-toolchain.toml +++ b/libs/@local/status/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/temporal-versioning/rust-toolchain.toml b/libs/@local/temporal-versioning/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/@local/temporal-versioning/rust-toolchain.toml +++ b/libs/@local/temporal-versioning/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/antsi/rust-toolchain.toml b/libs/antsi/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/antsi/rust-toolchain.toml +++ b/libs/antsi/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/deer/rust-toolchain.toml b/libs/deer/rust-toolchain.toml index 04f14b646bd..30fbe3429a9 100644 --- a/libs/deer/rust-toolchain.toml +++ b/libs/deer/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview', 'miri'] diff --git a/libs/error-stack/README.md b/libs/error-stack/README.md index db8619cd72b..31061a0e186 100644 --- a/libs/error-stack/README.md +++ b/libs/error-stack/README.md @@ -8,7 +8,7 @@ [![crates.io](https://img.shields.io/crates/v/error-stack)][crates.io] [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack-orange)][libs.rs] -[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-10-30&color=blue)][rust-version] +[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-20&color=blue)][rust-version] [![documentation](https://img.shields.io/docsrs/error-stack)][documentation] [![license](https://img.shields.io/crates/l/error-stack)][license] [![discord](https://img.shields.io/discord/840573247803097118)][discord] diff --git a/libs/error-stack/macros/README.md b/libs/error-stack/macros/README.md index ee0f6660fd1..a4bf0e09e13 100644 --- a/libs/error-stack/macros/README.md +++ b/libs/error-stack/macros/README.md @@ -7,7 +7,7 @@ [![crates.io](https://img.shields.io/crates/v/error-stack-macros)][crates.io] [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack--macros-orange)][libs.rs] -[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-10-30&color=blue)][rust-version] +[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-20&color=blue)][rust-version] [![documentation](https://img.shields.io/docsrs/error-stack-macros)][documentation] [![license](https://img.shields.io/crates/l/error-stack)][license] [![discord](https://img.shields.io/discord/840573247803097118)][discord] diff --git a/libs/error-stack/rust-toolchain.toml b/libs/error-stack/rust-toolchain.toml index 05a60ab1829..ce4f80483c3 100644 --- a/libs/error-stack/rust-toolchain.toml +++ b/libs/error-stack/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] # Please also update the badges in `README.md`s (`error-stack` and `error-stack-macros`), and `src/lib.rs` -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview', 'miri', 'rust-src'] diff --git a/libs/error-stack/src/lib.rs b/libs/error-stack/src/lib.rs index a96a90b804d..fae948e1dbe 100644 --- a/libs/error-stack/src/lib.rs +++ b/libs/error-stack/src/lib.rs @@ -2,7 +2,7 @@ //! //! [![crates.io](https://img.shields.io/crates/v/error-stack)][crates.io] //! [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack-orange)][libs.rs] -//! [![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-10-30&color=blue)][rust-version] +//! [![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-20&color=blue)][rust-version] //! [![discord](https://img.shields.io/discord/840573247803097118)][discord] //! //! [crates.io]: https://crates.io/crates/error-stack diff --git a/libs/sarif/rust-toolchain.toml b/libs/sarif/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/libs/sarif/rust-toolchain.toml +++ b/libs/sarif/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/tests/hash-graph-integration/rust-toolchain.toml b/tests/hash-graph-integration/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/tests/hash-graph-integration/rust-toolchain.toml +++ b/tests/hash-graph-integration/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/tests/hash-graph-test-data/rust/rust-toolchain.toml b/tests/hash-graph-test-data/rust/rust-toolchain.toml index 85a2aeb7ce0..88c4b71f26b 100644 --- a/tests/hash-graph-test-data/rust/rust-toolchain.toml +++ b/tests/hash-graph-test-data/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-30" +channel = "nightly-2023-11-20" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] From c1cebf271d3b4cb640686410cdf740c921597cca Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 21 Nov 2023 16:23:22 +0100 Subject: [PATCH 2/9] Satisfy clippy Signed-off-by: Tim Diekmann --- .config/lints.toml | 1 + apps/hash-graph/.cargo/config.toml | 1 + .../lib/graph/src/ontology/data_type.rs | 36 ++----- .../lib/graph/src/ontology/entity_type.rs | 100 +++--------------- .../lib/graph/src/ontology/property_type.rs | 77 +------------- .../lib/graph/src/store/query/path.rs | 4 - libs/@local/codec/.cargo/config.toml | 1 + .../hash-authorization/.cargo/config.toml | 1 + .../hash-graph-types/rust/.cargo/config.toml | 1 + .../@local/hash-validation/.cargo/config.toml | 1 + libs/@local/hash-validation/src/data_type.rs | 99 +++++++++-------- libs/@local/status/rust/.cargo/config.toml | 1 + .../temporal-versioning/.cargo/config.toml | 1 + libs/antsi/.cargo/config.toml | 1 + libs/deer/.cargo/config.toml | 1 + libs/error-stack/.cargo/config.toml | 1 + libs/sarif/.cargo/config.toml | 1 + .../hash-graph-integration/.cargo/config.toml | 1 + .../rust/.cargo/config.toml | 1 + 19 files changed, 95 insertions(+), 235 deletions(-) diff --git a/.config/lints.toml b/.config/lints.toml index ef5b2228946..7eea157edec 100644 --- a/.config/lints.toml +++ b/.config/lints.toml @@ -23,6 +23,7 @@ allow = [ "clippy::absolute_paths", "clippy::default_numeric_fallback", "clippy::impl_trait_in_params", + "clippy::iter_over_hash_type", "clippy::min_ident_chars", "clippy::multiple_unsafe_ops_per_block", "clippy::pattern_type_mismatch", diff --git a/apps/hash-graph/.cargo/config.toml b/apps/hash-graph/.cargo/config.toml index 617ee83c464..7d0789aceed 100644 --- a/apps/hash-graph/.cargo/config.toml +++ b/apps/hash-graph/.cargo/config.toml @@ -24,6 +24,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/apps/hash-graph/lib/graph/src/ontology/data_type.rs b/apps/hash-graph/lib/graph/src/ontology/data_type.rs index 1c7386ed8c0..c5958842dcb 100644 --- a/apps/hash-graph/lib/graph/src/ontology/data_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/data_type.rs @@ -71,18 +71,6 @@ pub enum DataTypeQueryPath<'p> { /// [`DataType`]: type_system::DataType Version, /// The [`VersionedUrl`] of the [`DataType`]. - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::DataTypeQueryPath; - /// let path = DataTypeQueryPath::deserialize(json!(["versionedUrl"]))?; - /// assert_eq!(path, DataTypeQueryPath::VersionedUrl); - /// # Ok::<(), serde_json::Error>(()) - /// ``` - /// - /// [`VersionedUrl`]: type_system::url::VersionedUrl - /// [`DataType`]: type_system::DataType VersionedUrl, /// The transaction time of the [`DataType`]. /// @@ -273,12 +261,6 @@ impl fmt::Display for DataTypeQueryPath<'_> { Self::Description => fmt.write_str("description"), Self::Type => fmt.write_str("type"), Self::AdditionalMetadata => fmt.write_str("additionalMetadata"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::PropertyTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), @@ -379,9 +361,9 @@ mod tests { use super::*; fn deserialize<'p>(segments: impl IntoIterator) -> DataTypeQueryPath<'p> { - DataTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( - segments.into_iter(), - )) + DataTypeQueryPath::deserialize( + de::value::SeqDeserializer::<_, de::value::Error>::new(segments.into_iter()) + ) .expect("could not deserialize path") } @@ -399,9 +381,9 @@ mod tests { assert_eq!(deserialize(["description"]), DataTypeQueryPath::Description); assert_eq!( - DataTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( - once("ontology_id") - )) + DataTypeQueryPath::deserialize( + de::value::SeqDeserializer::<_, de::value::Error>::new(once("ontology_id")) + ) .expect_err( "managed to convert data type query path with hidden token when it should have \ errored" @@ -414,9 +396,9 @@ mod tests { ); assert_eq!( - DataTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( - once("schema") - )) + DataTypeQueryPath::deserialize( + de::value::SeqDeserializer::<_, de::value::Error>::new(once("schema")) + ) .expect_err( "managed to convert data type query path with hidden token when it should have \ errored" diff --git a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs index db9a18a8ed4..0af13790445 100644 --- a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs @@ -187,15 +187,6 @@ pub enum EntityTypeQueryPath<'p> { /// [`EntityType::required()`]: type_system::EntityType::required Required, /// The label property metadata of the entity type. - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::EntityTypeQueryPath; - /// let path = EntityTypeQueryPath::deserialize(json!(["labelProperty"]))?; - /// assert_eq!(path, EntityTypeQueryPath::LabelProperty); - /// # Ok::<(), serde_json::Error>(()) - /// ``` LabelProperty, /// The icon of the entity type. /// @@ -209,65 +200,6 @@ pub enum EntityTypeQueryPath<'p> { /// ``` Icon, /// An edge to a [`PropertyType`] using an [`OntologyEdgeKind`]. - /// - /// The corresponding reversed edge is [`PropertyTypeQueryPath::EntityTypeEdge`]. - /// - /// Allowed edge kinds are: - /// - [`ConstrainsPropertiesOn`] - /// - /// [`PropertyType`]: type_system::PropertyType - /// [`EntityType`]: type_system::EntityType - /// [`ConstrainsPropertiesOn`]: OntologyEdgeKind::ConstrainsPropertiesOn - /// - /// - /// ## Constraining property types - /// - /// As an [`EntityType`] can have multiple [`PropertyType`]s, the deserialized path requires an - /// additional selector to identify the [`PropertyType`] to query. Currently, only the `*` - /// selector is available, so the path will be deserialized as `["properties", "*", ...]` - /// where `...` is the path to the desired field of the [`PropertyType`]. - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::{EntityTypeQueryPath, PropertyTypeQueryPath}; - /// # use graph::subgraph::edges::OntologyEdgeKind; - /// let path = EntityTypeQueryPath::deserialize(json!(["properties", "*", "baseUrl"]))?; - /// assert_eq!( - /// path, - /// EntityTypeQueryPath::PropertyTypeEdge { - /// edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, - /// path: PropertyTypeQueryPath::BaseUrl, - /// inheritance_depth: None, - /// } - /// ); - /// # Ok::<(), serde_json::Error>(()) - /// ``` - /// - /// ### Specifying the inheritance depth - /// - /// By passing `inheritanceDepth` as a parameter it's possible to limit the searched depth: - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::{EntityTypeQueryPath, PropertyTypeQueryPath}; - /// # use graph::subgraph::edges::OntologyEdgeKind; - /// let path = EntityTypeQueryPath::deserialize(json!([ - /// "properties(inheritanceDepth=10)", - /// "*", - /// "baseUrl" - /// ]))?; - /// assert_eq!( - /// path, - /// EntityTypeQueryPath::PropertyTypeEdge { - /// edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, - /// path: PropertyTypeQueryPath::BaseUrl, - /// inheritance_depth: Some(10), - /// } - /// ); - /// # Ok::<(), serde_json::Error>(()) - /// ``` PropertyTypeEdge { edge_kind: OntologyEdgeKind, path: PropertyTypeQueryPath<'p>, @@ -346,11 +278,12 @@ pub enum EntityTypeQueryPath<'p> { /// # use serde_json::json; /// # use graph::ontology::EntityTypeQueryPath; /// # use graph::subgraph::edges::{EdgeDirection, OntologyEdgeKind}; - /// let path = EntityTypeQueryPath::deserialize(json!([ - /// "inheritsFrom(inheritanceDepth=10)", - /// "*", - /// "baseUrl" - /// ]))?; + /// let path = + /// EntityTypeQueryPath::deserialize(json!([ + /// "inheritsFrom(inheritanceDepth=10)", + /// "*", + /// "baseUrl" + /// ]))?; /// assert_eq!( /// path, /// EntityTypeQueryPath::EntityTypeEdge { @@ -611,12 +544,6 @@ impl fmt::Display for EntityTypeQueryPath<'_> { direction: _, inheritance_depth: None, } => write!(fmt, "linkDestinations.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::EntityTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), @@ -668,10 +595,11 @@ pub struct EntityTypeQueryPathVisitor { } impl EntityTypeQueryPathVisitor { - pub const EXPECTING: &'static str = - "one of `baseUrl`, `version`, `versionedUrl`, `ownedById`, `recordCreatedById`, \ - `recordArchivedById`, `title`, `description`, `examples`, `properties`, `required`, \ - `labelProperty`, `icon`, `links`, `inheritsFrom`, `children`"; + pub const EXPECTING: &'static str = "one of `baseUrl`, `version`, `versionedUrl`, \ + `ownedById`, `recordCreatedById`, `recordArchivedById`, \ + `title`, `description`, `examples`, `properties`, \ + `required`, `labelProperty`, `icon`, `links`, \ + `inheritsFrom`, `children`"; #[must_use] pub const fn new(position: usize) -> Self { @@ -828,9 +756,9 @@ mod tests { use super::*; fn deserialize<'p>(segments: impl IntoIterator) -> EntityTypeQueryPath<'p> { - EntityTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( - segments.into_iter(), - )) + EntityTypeQueryPath::deserialize( + de::value::SeqDeserializer::<_, de::value::Error>::new(segments.into_iter()) + ) .expect("could not deserialize path") } diff --git a/apps/hash-graph/lib/graph/src/ontology/property_type.rs b/apps/hash-graph/lib/graph/src/ontology/property_type.rs index fad4e822c87..6ba7cef9995 100644 --- a/apps/hash-graph/lib/graph/src/ontology/property_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/property_type.rs @@ -20,18 +20,6 @@ use crate::{ #[derive(Debug, PartialEq, Eq)] pub enum PropertyTypeQueryPath<'p> { /// The [`BaseUrl`] of the [`PropertyType`]. - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::PropertyTypeQueryPath; - /// let path = PropertyTypeQueryPath::deserialize(json!(["baseUrl"]))?; - /// assert_eq!(path, PropertyTypeQueryPath::BaseUrl); - /// # Ok::<(), serde_json::Error>(()) - /// ``` - /// - /// [`PropertyType`]: type_system::PropertyType - /// [`BaseUrl`]: type_system::url::BaseUrl BaseUrl, /// The version of the [`PropertyType`]. /// @@ -118,17 +106,6 @@ pub enum PropertyTypeQueryPath<'p> { /// [`ProvenanceMetadata`]: graph_types::provenance::ProvenanceMetadata RecordArchivedById, /// Corresponds to [`PropertyType::title()`]. - /// - /// [`PropertyType::title()`]: type_system::PropertyType::title - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::PropertyTypeQueryPath; - /// let path = PropertyTypeQueryPath::deserialize(json!(["title"]))?; - /// assert_eq!(path, PropertyTypeQueryPath::Title); - /// # Ok::<(), serde_json::Error>(()) - /// ``` Title, /// Corresponds to [`PropertyType::description()`] /// @@ -146,36 +123,6 @@ pub enum PropertyTypeQueryPath<'p> { /// An edge to a [`DataType`] using an [`OntologyEdgeKind`]. /// /// The corresponding reversed edge is [`DataTypeQueryPath::PropertyTypeEdge`]. - /// - /// Allowed edge kinds are: - /// - [`ConstrainsValuesOn`] - /// - /// [`DataType`]: type_system::DataType - /// [`ConstrainsValuesOn`]: OntologyEdgeKind::ConstrainsValuesOn - /// [`PropertyType`]: type_system::PropertyType - /// - /// ## Constraining data types - /// - /// As a [`PropertyType`] can have multiple [`DataType`]s, the deserialized path requires an - /// additional selector to identify the [`DataType`] to query. Currently, only the `*` selector - /// is available, so the path will be deserialized as `["dataTypes", "*", ...]` where `...` is - /// the path to the desired field of the [`DataType`]. - /// - /// ```rust - /// # use serde::Deserialize; - /// # use serde_json::json; - /// # use graph::ontology::{DataTypeQueryPath, PropertyTypeQueryPath}; - /// # use graph::subgraph::edges::OntologyEdgeKind; - /// let path = PropertyTypeQueryPath::deserialize(json!(["dataTypes", "*", "title"]))?; - /// assert_eq!( - /// path, - /// PropertyTypeQueryPath::DataTypeEdge { - /// edge_kind: OntologyEdgeKind::ConstrainsValuesOn, - /// path: DataTypeQueryPath::Title, - /// } - /// ); - /// # Ok::<(), serde_json::Error>(()) - /// ``` DataTypeEdge { edge_kind: OntologyEdgeKind, path: DataTypeQueryPath<'p>, @@ -321,33 +268,15 @@ impl fmt::Display for PropertyTypeQueryPath<'_> { edge_kind: OntologyEdgeKind::ConstrainsValuesOn, path, } => write!(fmt, "dataTypes.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::DataTypeEdge { edge_kind, path } => write!(fmt, "<{edge_kind:?}>.{path}"), Self::PropertyTypeEdge { edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, path, .. } => write!(fmt, "propertyTypes.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::PropertyTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::EntityTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), @@ -470,9 +399,9 @@ mod tests { use super::*; fn deserialize<'p>(segments: impl IntoIterator) -> PropertyTypeQueryPath<'p> { - PropertyTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( - segments.into_iter(), - )) + PropertyTypeQueryPath::deserialize( + de::value::SeqDeserializer::<_, de::value::Error>::new(segments.into_iter()) + ) .expect("could not deserialize path") } diff --git a/apps/hash-graph/lib/graph/src/store/query/path.rs b/apps/hash-graph/lib/graph/src/store/query/path.rs index 54b99350ba4..aba559bfa95 100644 --- a/apps/hash-graph/lib/graph/src/store/query/path.rs +++ b/apps/hash-graph/lib/graph/src/store/query/path.rs @@ -26,10 +26,6 @@ impl<'p> JsonPath<'p> { writer.write_char('$')?; for token in &self.path { match token { - #[expect( - clippy::use_debug, - reason = "Debug string is escaped, Display string is not" - )] PathToken::Field(field) => { write!(writer, ".{field:?}")?; } diff --git a/libs/@local/codec/.cargo/config.toml b/libs/@local/codec/.cargo/config.toml index cddbd310720..126b978c3fc 100644 --- a/libs/@local/codec/.cargo/config.toml +++ b/libs/@local/codec/.cargo/config.toml @@ -25,6 +25,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/@local/hash-authorization/.cargo/config.toml b/libs/@local/hash-authorization/.cargo/config.toml index cddbd310720..126b978c3fc 100644 --- a/libs/@local/hash-authorization/.cargo/config.toml +++ b/libs/@local/hash-authorization/.cargo/config.toml @@ -25,6 +25,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/@local/hash-graph-types/rust/.cargo/config.toml b/libs/@local/hash-graph-types/rust/.cargo/config.toml index cddbd310720..126b978c3fc 100644 --- a/libs/@local/hash-graph-types/rust/.cargo/config.toml +++ b/libs/@local/hash-graph-types/rust/.cargo/config.toml @@ -25,6 +25,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/@local/hash-validation/.cargo/config.toml b/libs/@local/hash-validation/.cargo/config.toml index cddbd310720..126b978c3fc 100644 --- a/libs/@local/hash-validation/.cargo/config.toml +++ b/libs/@local/hash-validation/.cargo/config.toml @@ -25,6 +25,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/@local/hash-validation/src/data_type.rs b/libs/@local/hash-validation/src/data_type.rs index 78b6c1c1d57..a65e71c7614 100644 --- a/libs/@local/hash-validation/src/data_type.rs +++ b/libs/@local/hash-validation/src/data_type.rs @@ -85,28 +85,34 @@ impl Schema for DataType { _provider: &'a P, ) -> Result<(), Report> { match self.json_type() { - "null" => ensure!( - value.is_null(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Null, - } - ), - "boolean" => ensure!( - value.is_boolean(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Boolean, - } - ), + "null" => { + ensure!( + value.is_null(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Null, + } + ) + } + "boolean" => { + ensure!( + value.is_boolean(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Boolean, + } + ) + } - "number" => ensure!( - value.is_number(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Number, - } - ), + "number" => { + ensure!( + value.is_number(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Number, + } + ) + } "integer" => ensure!( value.is_i64() || value.is_u64(), DataValidationError::InvalidType { @@ -114,27 +120,33 @@ impl Schema for DataType { expected: JsonSchemaValueType::Integer, } ), - "string" => ensure!( - value.is_string(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::String, - } - ), - "array" => ensure!( - value.is_array(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Array, - } - ), - "object" => ensure!( - value.is_object(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Object, - } - ), + "string" => { + ensure!( + value.is_string(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::String, + } + ) + } + "array" => { + ensure!( + value.is_array(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Array, + } + ) + } + "object" => { + ensure!( + value.is_object(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Object, + } + ) + } _ => { bail!(DataValidationError::UnknownType { schema: self.json_type().to_owned() @@ -168,8 +180,7 @@ impl Schema for DataType { impl Validate for JsonValue { type Error = DataValidationError; - #[expect(clippy::let_underscore_untyped, reason = "false positive")] - async fn validate(&self, schema: &DataType, _: &()) -> Result<(), Report> { + async fn validate(&self, schema: &DataType, (): &()) -> Result<(), Report> { schema.validate_value(self, &()).await } } diff --git a/libs/@local/status/rust/.cargo/config.toml b/libs/@local/status/rust/.cargo/config.toml index cddbd310720..126b978c3fc 100644 --- a/libs/@local/status/rust/.cargo/config.toml +++ b/libs/@local/status/rust/.cargo/config.toml @@ -25,6 +25,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/@local/temporal-versioning/.cargo/config.toml b/libs/@local/temporal-versioning/.cargo/config.toml index cddbd310720..126b978c3fc 100644 --- a/libs/@local/temporal-versioning/.cargo/config.toml +++ b/libs/@local/temporal-versioning/.cargo/config.toml @@ -25,6 +25,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/antsi/.cargo/config.toml b/libs/antsi/.cargo/config.toml index 5caa47bbe8c..c8b4359eea8 100644 --- a/libs/antsi/.cargo/config.toml +++ b/libs/antsi/.cargo/config.toml @@ -29,6 +29,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/deer/.cargo/config.toml b/libs/deer/.cargo/config.toml index d055bdf8395..23dfbbb6c33 100644 --- a/libs/deer/.cargo/config.toml +++ b/libs/deer/.cargo/config.toml @@ -30,6 +30,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/error-stack/.cargo/config.toml b/libs/error-stack/.cargo/config.toml index 016ecb0e9d6..d105e9f7369 100644 --- a/libs/error-stack/.cargo/config.toml +++ b/libs/error-stack/.cargo/config.toml @@ -28,6 +28,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/libs/sarif/.cargo/config.toml b/libs/sarif/.cargo/config.toml index 50e2b6fcde4..16ac3e9771e 100644 --- a/libs/sarif/.cargo/config.toml +++ b/libs/sarif/.cargo/config.toml @@ -34,6 +34,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/tests/hash-graph-integration/.cargo/config.toml b/tests/hash-graph-integration/.cargo/config.toml index 617ee83c464..7d0789aceed 100644 --- a/tests/hash-graph-integration/.cargo/config.toml +++ b/tests/hash-graph-integration/.cargo/config.toml @@ -24,6 +24,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", diff --git a/tests/hash-graph-test-data/rust/.cargo/config.toml b/tests/hash-graph-test-data/rust/.cargo/config.toml index 617ee83c464..7d0789aceed 100644 --- a/tests/hash-graph-test-data/rust/.cargo/config.toml +++ b/tests/hash-graph-test-data/rust/.cargo/config.toml @@ -24,6 +24,7 @@ rustflags = [ "-Aclippy::impl_trait_in_params", "-Aclippy::implicit_return", "-Aclippy::indexing_slicing", + "-Aclippy::iter_over_hash_type", "-Aclippy::let_underscore_must_use", "-Aclippy::min_ident_chars", "-Aclippy::missing_assert_message", From c67fc13780394a210a864fa99d8b2b6da4344c3b Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 21 Nov 2023 16:46:30 +0100 Subject: [PATCH 3/9] Satisfy clippy Signed-off-by: Tim Diekmann --- libs/@local/hash-validation/src/data_type.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/@local/hash-validation/src/data_type.rs b/libs/@local/hash-validation/src/data_type.rs index a65e71c7614..70631d462cc 100644 --- a/libs/@local/hash-validation/src/data_type.rs +++ b/libs/@local/hash-validation/src/data_type.rs @@ -92,7 +92,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Null, } - ) + ); } "boolean" => { ensure!( @@ -101,7 +101,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Boolean, } - ) + ); } "number" => { @@ -111,7 +111,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Number, } - ) + ); } "integer" => ensure!( value.is_i64() || value.is_u64(), @@ -127,7 +127,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::String, } - ) + ); } "array" => { ensure!( @@ -136,7 +136,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Array, } - ) + ); } "object" => { ensure!( @@ -145,7 +145,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Object, } - ) + ); } _ => { bail!(DataValidationError::UnknownType { From 344a6ff9f1522fbcc011e9a706ef9858f61ff139 Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 21 Nov 2023 16:57:13 +0100 Subject: [PATCH 4/9] Satisfy clippy Signed-off-by: Tim Diekmann --- apps/hash-graph/lib/graph/src/ontology/entity_type.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs index 0af13790445..dd9b937a032 100644 --- a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs @@ -499,12 +499,6 @@ impl fmt::Display for EntityTypeQueryPath<'_> { path, inheritance_depth: None, } => write!(fmt, "properties.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::PropertyTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), From 86b5b56484f223cc4927f981e56bc529b00030e2 Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 21 Nov 2023 17:12:07 +0100 Subject: [PATCH 5/9] Revert wrongly formatted files Signed-off-by: Tim Diekmann --- libs/@local/hash-validation/src/data_type.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/@local/hash-validation/src/data_type.rs b/libs/@local/hash-validation/src/data_type.rs index 70631d462cc..a65e71c7614 100644 --- a/libs/@local/hash-validation/src/data_type.rs +++ b/libs/@local/hash-validation/src/data_type.rs @@ -92,7 +92,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Null, } - ); + ) } "boolean" => { ensure!( @@ -101,7 +101,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Boolean, } - ); + ) } "number" => { @@ -111,7 +111,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Number, } - ); + ) } "integer" => ensure!( value.is_i64() || value.is_u64(), @@ -127,7 +127,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::String, } - ); + ) } "array" => { ensure!( @@ -136,7 +136,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Array, } - ); + ) } "object" => { ensure!( @@ -145,7 +145,7 @@ impl Schema for DataType { actual: JsonSchemaValueType::from(value), expected: JsonSchemaValueType::Object, } - ); + ) } _ => { bail!(DataValidationError::UnknownType { From 9378410e3e839ca28572bff6042dfc1960cca7a1 Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 21 Nov 2023 17:14:15 +0100 Subject: [PATCH 6/9] Revert wrongly formatted files Signed-off-by: Tim Diekmann --- .../lib/graph/src/ontology/data_type.rs | 30 ++++-- .../lib/graph/src/ontology/entity_type.rs | 94 +++++++++++++++--- .../lib/graph/src/ontology/property_type.rs | 59 +++++++++++- libs/@local/hash-validation/src/data_type.rs | 96 ++++++++----------- 4 files changed, 199 insertions(+), 80 deletions(-) diff --git a/apps/hash-graph/lib/graph/src/ontology/data_type.rs b/apps/hash-graph/lib/graph/src/ontology/data_type.rs index c5958842dcb..4fcebf9b4a7 100644 --- a/apps/hash-graph/lib/graph/src/ontology/data_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/data_type.rs @@ -71,6 +71,18 @@ pub enum DataTypeQueryPath<'p> { /// [`DataType`]: type_system::DataType Version, /// The [`VersionedUrl`] of the [`DataType`]. + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::DataTypeQueryPath; + /// let path = DataTypeQueryPath::deserialize(json!(["versionedUrl"]))?; + /// assert_eq!(path, DataTypeQueryPath::VersionedUrl); + /// # Ok::<(), serde_json::Error>(()) + /// ``` + /// + /// [`VersionedUrl`]: type_system::url::VersionedUrl + /// [`DataType`]: type_system::DataType VersionedUrl, /// The transaction time of the [`DataType`]. /// @@ -361,9 +373,9 @@ mod tests { use super::*; fn deserialize<'p>(segments: impl IntoIterator) -> DataTypeQueryPath<'p> { - DataTypeQueryPath::deserialize( - de::value::SeqDeserializer::<_, de::value::Error>::new(segments.into_iter()) - ) + DataTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( + segments.into_iter(), + )) .expect("could not deserialize path") } @@ -381,9 +393,9 @@ mod tests { assert_eq!(deserialize(["description"]), DataTypeQueryPath::Description); assert_eq!( - DataTypeQueryPath::deserialize( - de::value::SeqDeserializer::<_, de::value::Error>::new(once("ontology_id")) - ) + DataTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( + once("ontology_id") + )) .expect_err( "managed to convert data type query path with hidden token when it should have \ errored" @@ -396,9 +408,9 @@ mod tests { ); assert_eq!( - DataTypeQueryPath::deserialize( - de::value::SeqDeserializer::<_, de::value::Error>::new(once("schema")) - ) + DataTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( + once("schema") + )) .expect_err( "managed to convert data type query path with hidden token when it should have \ errored" diff --git a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs index dd9b937a032..5afd8fbcf73 100644 --- a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs @@ -187,6 +187,15 @@ pub enum EntityTypeQueryPath<'p> { /// [`EntityType::required()`]: type_system::EntityType::required Required, /// The label property metadata of the entity type. + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::EntityTypeQueryPath; + /// let path = EntityTypeQueryPath::deserialize(json!(["labelProperty"]))?; + /// assert_eq!(path, EntityTypeQueryPath::LabelProperty); + /// # Ok::<(), serde_json::Error>(()) + /// ``` LabelProperty, /// The icon of the entity type. /// @@ -200,6 +209,65 @@ pub enum EntityTypeQueryPath<'p> { /// ``` Icon, /// An edge to a [`PropertyType`] using an [`OntologyEdgeKind`]. + /// + /// The corresponding reversed edge is [`PropertyTypeQueryPath::EntityTypeEdge`]. + /// + /// Allowed edge kinds are: + /// - [`ConstrainsPropertiesOn`] + /// + /// [`PropertyType`]: type_system::PropertyType + /// [`EntityType`]: type_system::EntityType + /// [`ConstrainsPropertiesOn`]: OntologyEdgeKind::ConstrainsPropertiesOn + /// + /// + /// ## Constraining property types + /// + /// As an [`EntityType`] can have multiple [`PropertyType`]s, the deserialized path requires an + /// additional selector to identify the [`PropertyType`] to query. Currently, only the `*` + /// selector is available, so the path will be deserialized as `["properties", "*", ...]` + /// where `...` is the path to the desired field of the [`PropertyType`]. + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::{EntityTypeQueryPath, PropertyTypeQueryPath}; + /// # use graph::subgraph::edges::OntologyEdgeKind; + /// let path = EntityTypeQueryPath::deserialize(json!(["properties", "*", "baseUrl"]))?; + /// assert_eq!( + /// path, + /// EntityTypeQueryPath::PropertyTypeEdge { + /// edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, + /// path: PropertyTypeQueryPath::BaseUrl, + /// inheritance_depth: None, + /// } + /// ); + /// # Ok::<(), serde_json::Error>(()) + /// ``` + /// + /// ### Specifying the inheritance depth + /// + /// By passing `inheritanceDepth` as a parameter it's possible to limit the searched depth: + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::{EntityTypeQueryPath, PropertyTypeQueryPath}; + /// # use graph::subgraph::edges::OntologyEdgeKind; + /// let path = EntityTypeQueryPath::deserialize(json!([ + /// "properties(inheritanceDepth=10)", + /// "*", + /// "baseUrl" + /// ]))?; + /// assert_eq!( + /// path, + /// EntityTypeQueryPath::PropertyTypeEdge { + /// edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, + /// path: PropertyTypeQueryPath::BaseUrl, + /// inheritance_depth: Some(10), + /// } + /// ); + /// # Ok::<(), serde_json::Error>(()) + /// ``` PropertyTypeEdge { edge_kind: OntologyEdgeKind, path: PropertyTypeQueryPath<'p>, @@ -278,12 +346,11 @@ pub enum EntityTypeQueryPath<'p> { /// # use serde_json::json; /// # use graph::ontology::EntityTypeQueryPath; /// # use graph::subgraph::edges::{EdgeDirection, OntologyEdgeKind}; - /// let path = - /// EntityTypeQueryPath::deserialize(json!([ - /// "inheritsFrom(inheritanceDepth=10)", - /// "*", - /// "baseUrl" - /// ]))?; + /// let path = EntityTypeQueryPath::deserialize(json!([ + /// "inheritsFrom(inheritanceDepth=10)", + /// "*", + /// "baseUrl" + /// ]))?; /// assert_eq!( /// path, /// EntityTypeQueryPath::EntityTypeEdge { @@ -589,11 +656,10 @@ pub struct EntityTypeQueryPathVisitor { } impl EntityTypeQueryPathVisitor { - pub const EXPECTING: &'static str = "one of `baseUrl`, `version`, `versionedUrl`, \ - `ownedById`, `recordCreatedById`, `recordArchivedById`, \ - `title`, `description`, `examples`, `properties`, \ - `required`, `labelProperty`, `icon`, `links`, \ - `inheritsFrom`, `children`"; + pub const EXPECTING: &'static str = + "one of `baseUrl`, `version`, `versionedUrl`, `ownedById`, `recordCreatedById`, \ + `recordArchivedById`, `title`, `description`, `examples`, `properties`, `required`, \ + `labelProperty`, `icon`, `links`, `inheritsFrom`, `children`"; #[must_use] pub const fn new(position: usize) -> Self { @@ -750,9 +816,9 @@ mod tests { use super::*; fn deserialize<'p>(segments: impl IntoIterator) -> EntityTypeQueryPath<'p> { - EntityTypeQueryPath::deserialize( - de::value::SeqDeserializer::<_, de::value::Error>::new(segments.into_iter()) - ) + EntityTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( + segments.into_iter(), + )) .expect("could not deserialize path") } diff --git a/apps/hash-graph/lib/graph/src/ontology/property_type.rs b/apps/hash-graph/lib/graph/src/ontology/property_type.rs index 6ba7cef9995..910d3873078 100644 --- a/apps/hash-graph/lib/graph/src/ontology/property_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/property_type.rs @@ -20,6 +20,18 @@ use crate::{ #[derive(Debug, PartialEq, Eq)] pub enum PropertyTypeQueryPath<'p> { /// The [`BaseUrl`] of the [`PropertyType`]. + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::PropertyTypeQueryPath; + /// let path = PropertyTypeQueryPath::deserialize(json!(["baseUrl"]))?; + /// assert_eq!(path, PropertyTypeQueryPath::BaseUrl); + /// # Ok::<(), serde_json::Error>(()) + /// ``` + /// + /// [`PropertyType`]: type_system::PropertyType + /// [`BaseUrl`]: type_system::url::BaseUrl BaseUrl, /// The version of the [`PropertyType`]. /// @@ -106,6 +118,17 @@ pub enum PropertyTypeQueryPath<'p> { /// [`ProvenanceMetadata`]: graph_types::provenance::ProvenanceMetadata RecordArchivedById, /// Corresponds to [`PropertyType::title()`]. + /// + /// [`PropertyType::title()`]: type_system::PropertyType::title + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::PropertyTypeQueryPath; + /// let path = PropertyTypeQueryPath::deserialize(json!(["title"]))?; + /// assert_eq!(path, PropertyTypeQueryPath::Title); + /// # Ok::<(), serde_json::Error>(()) + /// ``` Title, /// Corresponds to [`PropertyType::description()`] /// @@ -123,6 +146,36 @@ pub enum PropertyTypeQueryPath<'p> { /// An edge to a [`DataType`] using an [`OntologyEdgeKind`]. /// /// The corresponding reversed edge is [`DataTypeQueryPath::PropertyTypeEdge`]. + /// + /// Allowed edge kinds are: + /// - [`ConstrainsValuesOn`] + /// + /// [`DataType`]: type_system::DataType + /// [`ConstrainsValuesOn`]: OntologyEdgeKind::ConstrainsValuesOn + /// [`PropertyType`]: type_system::PropertyType + /// + /// ## Constraining data types + /// + /// As a [`PropertyType`] can have multiple [`DataType`]s, the deserialized path requires an + /// additional selector to identify the [`DataType`] to query. Currently, only the `*` selector + /// is available, so the path will be deserialized as `["dataTypes", "*", ...]` where `...` is + /// the path to the desired field of the [`DataType`]. + /// + /// ```rust + /// # use serde::Deserialize; + /// # use serde_json::json; + /// # use graph::ontology::{DataTypeQueryPath, PropertyTypeQueryPath}; + /// # use graph::subgraph::edges::OntologyEdgeKind; + /// let path = PropertyTypeQueryPath::deserialize(json!(["dataTypes", "*", "title"]))?; + /// assert_eq!( + /// path, + /// PropertyTypeQueryPath::DataTypeEdge { + /// edge_kind: OntologyEdgeKind::ConstrainsValuesOn, + /// path: DataTypeQueryPath::Title, + /// } + /// ); + /// # Ok::<(), serde_json::Error>(()) + /// ``` DataTypeEdge { edge_kind: OntologyEdgeKind, path: DataTypeQueryPath<'p>, @@ -399,9 +452,9 @@ mod tests { use super::*; fn deserialize<'p>(segments: impl IntoIterator) -> PropertyTypeQueryPath<'p> { - PropertyTypeQueryPath::deserialize( - de::value::SeqDeserializer::<_, de::value::Error>::new(segments.into_iter()) - ) + PropertyTypeQueryPath::deserialize(de::value::SeqDeserializer::<_, de::value::Error>::new( + segments.into_iter(), + )) .expect("could not deserialize path") } diff --git a/libs/@local/hash-validation/src/data_type.rs b/libs/@local/hash-validation/src/data_type.rs index a65e71c7614..2357158bb8e 100644 --- a/libs/@local/hash-validation/src/data_type.rs +++ b/libs/@local/hash-validation/src/data_type.rs @@ -85,34 +85,28 @@ impl Schema for DataType { _provider: &'a P, ) -> Result<(), Report> { match self.json_type() { - "null" => { - ensure!( - value.is_null(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Null, - } - ) - } - "boolean" => { - ensure!( - value.is_boolean(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Boolean, - } - ) - } + "null" => ensure!( + value.is_null(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Null, + } + ), + "boolean" => ensure!( + value.is_boolean(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Boolean, + } + ), - "number" => { - ensure!( - value.is_number(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Number, - } - ) - } + "number" => ensure!( + value.is_number(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Number, + } + ), "integer" => ensure!( value.is_i64() || value.is_u64(), DataValidationError::InvalidType { @@ -120,33 +114,27 @@ impl Schema for DataType { expected: JsonSchemaValueType::Integer, } ), - "string" => { - ensure!( - value.is_string(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::String, - } - ) - } - "array" => { - ensure!( - value.is_array(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Array, - } - ) - } - "object" => { - ensure!( - value.is_object(), - DataValidationError::InvalidType { - actual: JsonSchemaValueType::from(value), - expected: JsonSchemaValueType::Object, - } - ) - } + "string" => ensure!( + value.is_string(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::String, + } + ), + "array" => ensure!( + value.is_array(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Array, + } + ), + "object" => ensure!( + value.is_object(), + DataValidationError::InvalidType { + actual: JsonSchemaValueType::from(value), + expected: JsonSchemaValueType::Object, + } + ), _ => { bail!(DataValidationError::UnknownType { schema: self.json_type().to_owned() From 00ff76552744d404d15bdea0d3e2a7fab2322d7e Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 21 Nov 2023 17:27:09 +0100 Subject: [PATCH 7/9] Revert wrong clippy suggestions Signed-off-by: Tim Diekmann --- .../lib/graph/src/ontology/data_type.rs | 6 ++++++ .../lib/graph/src/ontology/entity_type.rs | 12 ++++++++++++ .../lib/graph/src/ontology/property_type.rs | 18 ++++++++++++++++++ .../lib/graph/src/store/query/path.rs | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/apps/hash-graph/lib/graph/src/ontology/data_type.rs b/apps/hash-graph/lib/graph/src/ontology/data_type.rs index 4fcebf9b4a7..1c7386ed8c0 100644 --- a/apps/hash-graph/lib/graph/src/ontology/data_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/data_type.rs @@ -273,6 +273,12 @@ impl fmt::Display for DataTypeQueryPath<'_> { Self::Description => fmt.write_str("description"), Self::Type => fmt.write_str("type"), Self::AdditionalMetadata => fmt.write_str("additionalMetadata"), + #[expect( + clippy::use_debug, + reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ + (a) never happen and (b) be easy to debug if it does happen. In the \ + future, this will become a compile-time check" + )] Self::PropertyTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), diff --git a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs index 5afd8fbcf73..db9a18a8ed4 100644 --- a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs @@ -566,6 +566,12 @@ impl fmt::Display for EntityTypeQueryPath<'_> { path, inheritance_depth: None, } => write!(fmt, "properties.{path}"), + #[expect( + clippy::use_debug, + reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ + (a) never happen and (b) be easy to debug if it does happen. In the \ + future, this will become a compile-time check" + )] Self::PropertyTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), @@ -605,6 +611,12 @@ impl fmt::Display for EntityTypeQueryPath<'_> { direction: _, inheritance_depth: None, } => write!(fmt, "linkDestinations.{path}"), + #[expect( + clippy::use_debug, + reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ + (a) never happen and (b) be easy to debug if it does happen. In the \ + future, this will become a compile-time check" + )] Self::EntityTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), diff --git a/apps/hash-graph/lib/graph/src/ontology/property_type.rs b/apps/hash-graph/lib/graph/src/ontology/property_type.rs index 910d3873078..fad4e822c87 100644 --- a/apps/hash-graph/lib/graph/src/ontology/property_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/property_type.rs @@ -321,15 +321,33 @@ impl fmt::Display for PropertyTypeQueryPath<'_> { edge_kind: OntologyEdgeKind::ConstrainsValuesOn, path, } => write!(fmt, "dataTypes.{path}"), + #[expect( + clippy::use_debug, + reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ + (a) never happen and (b) be easy to debug if it does happen. In the \ + future, this will become a compile-time check" + )] Self::DataTypeEdge { edge_kind, path } => write!(fmt, "<{edge_kind:?}>.{path}"), Self::PropertyTypeEdge { edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, path, .. } => write!(fmt, "propertyTypes.{path}"), + #[expect( + clippy::use_debug, + reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ + (a) never happen and (b) be easy to debug if it does happen. In the \ + future, this will become a compile-time check" + )] Self::PropertyTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), + #[expect( + clippy::use_debug, + reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ + (a) never happen and (b) be easy to debug if it does happen. In the \ + future, this will become a compile-time check" + )] Self::EntityTypeEdge { edge_kind, path, .. } => write!(fmt, "<{edge_kind:?}>.{path}"), diff --git a/apps/hash-graph/lib/graph/src/store/query/path.rs b/apps/hash-graph/lib/graph/src/store/query/path.rs index aba559bfa95..54b99350ba4 100644 --- a/apps/hash-graph/lib/graph/src/store/query/path.rs +++ b/apps/hash-graph/lib/graph/src/store/query/path.rs @@ -26,6 +26,10 @@ impl<'p> JsonPath<'p> { writer.write_char('$')?; for token in &self.path { match token { + #[expect( + clippy::use_debug, + reason = "Debug string is escaped, Display string is not" + )] PathToken::Field(field) => { write!(writer, ".{field:?}")?; } From c9257bfdecb16f2b0ac8539260c4ea64dbcbd69e Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Sun, 26 Nov 2023 20:16:14 +0100 Subject: [PATCH 8/9] Bump toolchain --- apps/hash-graph/rust-toolchain.toml | 2 +- libs/@local/codec/rust-toolchain.toml | 2 +- libs/@local/hash-authorization/rust-toolchain.toml | 2 +- libs/@local/hash-graph-types/rust/rust-toolchain.toml | 2 +- libs/@local/hash-validation/rust-toolchain.toml | 2 +- libs/@local/status/rust/rust-toolchain.toml | 2 +- libs/@local/temporal-versioning/rust-toolchain.toml | 2 +- libs/antsi/rust-toolchain.toml | 2 +- libs/deer/rust-toolchain.toml | 2 +- libs/error-stack/README.md | 2 +- libs/error-stack/macros/README.md | 2 +- libs/error-stack/rust-toolchain.toml | 2 +- libs/error-stack/src/lib.rs | 2 +- libs/sarif/rust-toolchain.toml | 2 +- tests/hash-graph-integration/rust-toolchain.toml | 2 +- tests/hash-graph-test-data/rust/rust-toolchain.toml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/hash-graph/rust-toolchain.toml b/apps/hash-graph/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/apps/hash-graph/rust-toolchain.toml +++ b/apps/hash-graph/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/codec/rust-toolchain.toml b/libs/@local/codec/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/@local/codec/rust-toolchain.toml +++ b/libs/@local/codec/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-authorization/rust-toolchain.toml b/libs/@local/hash-authorization/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/@local/hash-authorization/rust-toolchain.toml +++ b/libs/@local/hash-authorization/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-graph-types/rust/rust-toolchain.toml b/libs/@local/hash-graph-types/rust/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/@local/hash-graph-types/rust/rust-toolchain.toml +++ b/libs/@local/hash-graph-types/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-validation/rust-toolchain.toml b/libs/@local/hash-validation/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/@local/hash-validation/rust-toolchain.toml +++ b/libs/@local/hash-validation/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/status/rust/rust-toolchain.toml b/libs/@local/status/rust/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/@local/status/rust/rust-toolchain.toml +++ b/libs/@local/status/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/temporal-versioning/rust-toolchain.toml b/libs/@local/temporal-versioning/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/@local/temporal-versioning/rust-toolchain.toml +++ b/libs/@local/temporal-versioning/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/antsi/rust-toolchain.toml b/libs/antsi/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/antsi/rust-toolchain.toml +++ b/libs/antsi/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/deer/rust-toolchain.toml b/libs/deer/rust-toolchain.toml index 30fbe3429a9..9666a12a152 100644 --- a/libs/deer/rust-toolchain.toml +++ b/libs/deer/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview', 'miri'] diff --git a/libs/error-stack/README.md b/libs/error-stack/README.md index 31061a0e186..72e0a8cb2e9 100644 --- a/libs/error-stack/README.md +++ b/libs/error-stack/README.md @@ -8,7 +8,7 @@ [![crates.io](https://img.shields.io/crates/v/error-stack)][crates.io] [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack-orange)][libs.rs] -[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-20&color=blue)][rust-version] +[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-26&color=blue)][rust-version] [![documentation](https://img.shields.io/docsrs/error-stack)][documentation] [![license](https://img.shields.io/crates/l/error-stack)][license] [![discord](https://img.shields.io/discord/840573247803097118)][discord] diff --git a/libs/error-stack/macros/README.md b/libs/error-stack/macros/README.md index a4bf0e09e13..c62e9013ae4 100644 --- a/libs/error-stack/macros/README.md +++ b/libs/error-stack/macros/README.md @@ -7,7 +7,7 @@ [![crates.io](https://img.shields.io/crates/v/error-stack-macros)][crates.io] [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack--macros-orange)][libs.rs] -[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-20&color=blue)][rust-version] +[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-26&color=blue)][rust-version] [![documentation](https://img.shields.io/docsrs/error-stack-macros)][documentation] [![license](https://img.shields.io/crates/l/error-stack)][license] [![discord](https://img.shields.io/discord/840573247803097118)][discord] diff --git a/libs/error-stack/rust-toolchain.toml b/libs/error-stack/rust-toolchain.toml index ce4f80483c3..e2edb929c44 100644 --- a/libs/error-stack/rust-toolchain.toml +++ b/libs/error-stack/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] # Please also update the badges in `README.md`s (`error-stack` and `error-stack-macros`), and `src/lib.rs` -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview', 'miri', 'rust-src'] diff --git a/libs/error-stack/src/lib.rs b/libs/error-stack/src/lib.rs index fae948e1dbe..fd39d18d083 100644 --- a/libs/error-stack/src/lib.rs +++ b/libs/error-stack/src/lib.rs @@ -2,7 +2,7 @@ //! //! [![crates.io](https://img.shields.io/crates/v/error-stack)][crates.io] //! [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack-orange)][libs.rs] -//! [![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-20&color=blue)][rust-version] +//! [![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-26&color=blue)][rust-version] //! [![discord](https://img.shields.io/discord/840573247803097118)][discord] //! //! [crates.io]: https://crates.io/crates/error-stack diff --git a/libs/sarif/rust-toolchain.toml b/libs/sarif/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/libs/sarif/rust-toolchain.toml +++ b/libs/sarif/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/tests/hash-graph-integration/rust-toolchain.toml b/tests/hash-graph-integration/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/tests/hash-graph-integration/rust-toolchain.toml +++ b/tests/hash-graph-integration/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/tests/hash-graph-test-data/rust/rust-toolchain.toml b/tests/hash-graph-test-data/rust/rust-toolchain.toml index 88c4b71f26b..3ef1ea538d9 100644 --- a/tests/hash-graph-test-data/rust/rust-toolchain.toml +++ b/tests/hash-graph-test-data/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-20" +channel = "nightly-2023-11-26" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] From b9fc3398c9e6ffe84f02e7d96a34282b93f23b77 Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Mon, 27 Nov 2023 11:32:29 +0100 Subject: [PATCH 9/9] Satisfy clippy --- .../lib/graph/src/ontology/data_type.rs | 16 ++++---- .../lib/graph/src/ontology/entity_type.rs | 31 +++++++------- .../lib/graph/src/ontology/property_type.rs | 40 ++++++++----------- .../lib/graph/src/store/query/path.rs | 6 +-- apps/hash-graph/rust-toolchain.toml | 2 +- libs/@local/codec/rust-toolchain.toml | 2 +- .../hash-authorization/rust-toolchain.toml | 2 +- .../hash-graph-types/rust/rust-toolchain.toml | 2 +- .../hash-validation/rust-toolchain.toml | 2 +- libs/@local/status/rust/rust-toolchain.toml | 2 +- .../temporal-versioning/rust-toolchain.toml | 2 +- libs/antsi/rust-toolchain.toml | 2 +- libs/deer/rust-toolchain.toml | 2 +- libs/error-stack/README.md | 2 +- libs/error-stack/macros/README.md | 2 +- libs/error-stack/rust-toolchain.toml | 2 +- libs/error-stack/src/lib.rs | 2 +- libs/sarif/rust-toolchain.toml | 2 +- .../rust-toolchain.toml | 2 +- .../rust/rust-toolchain.toml | 2 +- 20 files changed, 56 insertions(+), 69 deletions(-) diff --git a/apps/hash-graph/lib/graph/src/ontology/data_type.rs b/apps/hash-graph/lib/graph/src/ontology/data_type.rs index 1c7386ed8c0..ecc64f9abbd 100644 --- a/apps/hash-graph/lib/graph/src/ontology/data_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/data_type.rs @@ -1,8 +1,8 @@ -use std::fmt; +use std::fmt::{self, Write}; use serde::{ de::{self, Deserializer, SeqAccess, Visitor}, - Deserialize, + Deserialize, Serialize, }; use utoipa::ToSchema; @@ -273,15 +273,13 @@ impl fmt::Display for DataTypeQueryPath<'_> { Self::Description => fmt.write_str("description"), Self::Type => fmt.write_str("type"), Self::AdditionalMetadata => fmt.write_str("additionalMetadata"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::PropertyTypeEdge { edge_kind, path, .. - } => write!(fmt, "<{edge_kind:?}>.{path}"), + } => { + fmt.write_char('<')?; + edge_kind.serialize(&mut *fmt)?; + write!(fmt, ">.{path}") + } } } } diff --git a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs index db9a18a8ed4..90a66b8fb72 100644 --- a/apps/hash-graph/lib/graph/src/ontology/entity_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/entity_type.rs @@ -1,8 +1,11 @@ -use std::{fmt, str::FromStr}; +use std::{ + fmt::{self, Write}, + str::FromStr, +}; use serde::{ de::{self, Deserializer, SeqAccess, Visitor}, - Deserialize, + Deserialize, Serialize, }; use utoipa::ToSchema; @@ -566,15 +569,13 @@ impl fmt::Display for EntityTypeQueryPath<'_> { path, inheritance_depth: None, } => write!(fmt, "properties.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::PropertyTypeEdge { edge_kind, path, .. - } => write!(fmt, "<{edge_kind:?}>.{path}"), + } => { + fmt.write_char('<')?; + edge_kind.serialize(&mut *fmt)?; + write!(fmt, ">.{path}") + } Self::EntityTypeEdge { edge_kind: OntologyEdgeKind::InheritsFrom, path, @@ -611,15 +612,13 @@ impl fmt::Display for EntityTypeQueryPath<'_> { direction: _, inheritance_depth: None, } => write!(fmt, "linkDestinations.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::EntityTypeEdge { edge_kind, path, .. - } => write!(fmt, "<{edge_kind:?}>.{path}"), + } => { + fmt.write_char('<')?; + edge_kind.serialize(&mut *fmt)?; + write!(fmt, ">.{path}") + } Self::EntityEdge { edge_kind: SharedEdgeKind::IsOfType, path, diff --git a/apps/hash-graph/lib/graph/src/ontology/property_type.rs b/apps/hash-graph/lib/graph/src/ontology/property_type.rs index fad4e822c87..7c1abe014d4 100644 --- a/apps/hash-graph/lib/graph/src/ontology/property_type.rs +++ b/apps/hash-graph/lib/graph/src/ontology/property_type.rs @@ -1,8 +1,8 @@ -use std::fmt; +use std::{fmt, fmt::Write}; use serde::{ de::{self, Deserializer, SeqAccess, Visitor}, - Deserialize, + Deserialize, Serialize, }; use utoipa::ToSchema; @@ -321,36 +321,30 @@ impl fmt::Display for PropertyTypeQueryPath<'_> { edge_kind: OntologyEdgeKind::ConstrainsValuesOn, path, } => write!(fmt, "dataTypes.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] - Self::DataTypeEdge { edge_kind, path } => write!(fmt, "<{edge_kind:?}>.{path}"), + Self::DataTypeEdge { edge_kind, path } => { + fmt.write_char('<')?; + edge_kind.serialize(&mut *fmt)?; + write!(fmt, ">.{path}") + } Self::PropertyTypeEdge { edge_kind: OntologyEdgeKind::ConstrainsPropertiesOn, path, .. } => write!(fmt, "propertyTypes.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] Self::PropertyTypeEdge { edge_kind, path, .. - } => write!(fmt, "<{edge_kind:?}>.{path}"), - #[expect( - clippy::use_debug, - reason = "We don't have a `Display` impl for `OntologyEdgeKind` and this should \ - (a) never happen and (b) be easy to debug if it does happen. In the \ - future, this will become a compile-time check" - )] + } => { + fmt.write_char('<')?; + edge_kind.serialize(&mut *fmt)?; + write!(fmt, ">.{path}") + } Self::EntityTypeEdge { edge_kind, path, .. - } => write!(fmt, "<{edge_kind:?}>.{path}"), + } => { + fmt.write_char('<')?; + edge_kind.serialize(&mut *fmt)?; + write!(fmt, ">.{path}") + } Self::AdditionalMetadata => fmt.write_str("additionalMetadata"), } } diff --git a/apps/hash-graph/lib/graph/src/store/query/path.rs b/apps/hash-graph/lib/graph/src/store/query/path.rs index 54b99350ba4..eccf1e98d45 100644 --- a/apps/hash-graph/lib/graph/src/store/query/path.rs +++ b/apps/hash-graph/lib/graph/src/store/query/path.rs @@ -26,12 +26,8 @@ impl<'p> JsonPath<'p> { writer.write_char('$')?; for token in &self.path { match token { - #[expect( - clippy::use_debug, - reason = "Debug string is escaped, Display string is not" - )] PathToken::Field(field) => { - write!(writer, ".{field:?}")?; + write!(writer, ".\"{}\"", field.replace('"', "\\\""))?; } PathToken::Index(index) => { write!(writer, "[{index}]")?; diff --git a/apps/hash-graph/rust-toolchain.toml b/apps/hash-graph/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/apps/hash-graph/rust-toolchain.toml +++ b/apps/hash-graph/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/codec/rust-toolchain.toml b/libs/@local/codec/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/@local/codec/rust-toolchain.toml +++ b/libs/@local/codec/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-authorization/rust-toolchain.toml b/libs/@local/hash-authorization/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/@local/hash-authorization/rust-toolchain.toml +++ b/libs/@local/hash-authorization/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-graph-types/rust/rust-toolchain.toml b/libs/@local/hash-graph-types/rust/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/@local/hash-graph-types/rust/rust-toolchain.toml +++ b/libs/@local/hash-graph-types/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/hash-validation/rust-toolchain.toml b/libs/@local/hash-validation/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/@local/hash-validation/rust-toolchain.toml +++ b/libs/@local/hash-validation/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/status/rust/rust-toolchain.toml b/libs/@local/status/rust/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/@local/status/rust/rust-toolchain.toml +++ b/libs/@local/status/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/@local/temporal-versioning/rust-toolchain.toml b/libs/@local/temporal-versioning/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/@local/temporal-versioning/rust-toolchain.toml +++ b/libs/@local/temporal-versioning/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/antsi/rust-toolchain.toml b/libs/antsi/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/antsi/rust-toolchain.toml +++ b/libs/antsi/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/libs/deer/rust-toolchain.toml b/libs/deer/rust-toolchain.toml index 9666a12a152..aaa29cbe026 100644 --- a/libs/deer/rust-toolchain.toml +++ b/libs/deer/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview', 'miri'] diff --git a/libs/error-stack/README.md b/libs/error-stack/README.md index 72e0a8cb2e9..4c5d306d605 100644 --- a/libs/error-stack/README.md +++ b/libs/error-stack/README.md @@ -8,7 +8,7 @@ [![crates.io](https://img.shields.io/crates/v/error-stack)][crates.io] [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack-orange)][libs.rs] -[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-26&color=blue)][rust-version] +[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-27&color=blue)][rust-version] [![documentation](https://img.shields.io/docsrs/error-stack)][documentation] [![license](https://img.shields.io/crates/l/error-stack)][license] [![discord](https://img.shields.io/discord/840573247803097118)][discord] diff --git a/libs/error-stack/macros/README.md b/libs/error-stack/macros/README.md index c62e9013ae4..fa852155ef7 100644 --- a/libs/error-stack/macros/README.md +++ b/libs/error-stack/macros/README.md @@ -7,7 +7,7 @@ [![crates.io](https://img.shields.io/crates/v/error-stack-macros)][crates.io] [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack--macros-orange)][libs.rs] -[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-26&color=blue)][rust-version] +[![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-27&color=blue)][rust-version] [![documentation](https://img.shields.io/docsrs/error-stack-macros)][documentation] [![license](https://img.shields.io/crates/l/error-stack)][license] [![discord](https://img.shields.io/discord/840573247803097118)][discord] diff --git a/libs/error-stack/rust-toolchain.toml b/libs/error-stack/rust-toolchain.toml index e2edb929c44..fb9f49fc14c 100644 --- a/libs/error-stack/rust-toolchain.toml +++ b/libs/error-stack/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] # Please also update the badges in `README.md`s (`error-stack` and `error-stack-macros`), and `src/lib.rs` -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview', 'miri', 'rust-src'] diff --git a/libs/error-stack/src/lib.rs b/libs/error-stack/src/lib.rs index fd39d18d083..7ef14907a82 100644 --- a/libs/error-stack/src/lib.rs +++ b/libs/error-stack/src/lib.rs @@ -2,7 +2,7 @@ //! //! [![crates.io](https://img.shields.io/crates/v/error-stack)][crates.io] //! [![libs.rs](https://img.shields.io/badge/libs.rs-error--stack-orange)][libs.rs] -//! [![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-26&color=blue)][rust-version] +//! [![rust-version](https://img.shields.io/static/v1?label=Rust&message=1.63.0/nightly-2023-11-27&color=blue)][rust-version] //! [![discord](https://img.shields.io/discord/840573247803097118)][discord] //! //! [crates.io]: https://crates.io/crates/error-stack diff --git a/libs/sarif/rust-toolchain.toml b/libs/sarif/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/libs/sarif/rust-toolchain.toml +++ b/libs/sarif/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/tests/hash-graph-integration/rust-toolchain.toml b/tests/hash-graph-integration/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/tests/hash-graph-integration/rust-toolchain.toml +++ b/tests/hash-graph-integration/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview'] diff --git a/tests/hash-graph-test-data/rust/rust-toolchain.toml b/tests/hash-graph-test-data/rust/rust-toolchain.toml index 3ef1ea538d9..2c9067d5bb7 100644 --- a/tests/hash-graph-test-data/rust/rust-toolchain.toml +++ b/tests/hash-graph-test-data/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-11-27" components = ['rustfmt', 'clippy', 'llvm-tools-preview']