Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rust toolchains to nightly-2023-11-27 #3548

Merged
merged 9 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/lints.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/hash-graph/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
36 changes: 9 additions & 27 deletions apps/hash-graph/lib/graph/src/ontology/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand Down Expand Up @@ -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}"),
Expand Down Expand Up @@ -379,9 +361,9 @@ mod tests {
use super::*;

fn deserialize<'p>(segments: impl IntoIterator<Item = &'p str>) -> 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")
}

Expand All @@ -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"
Expand All @@ -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"
Expand Down
106 changes: 14 additions & 92 deletions apps/hash-graph/lib/graph/src/ontology/entity_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -566,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}"),
Expand Down Expand Up @@ -611,12 +538,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}"),
Expand Down Expand Up @@ -668,10 +589,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 {
Expand Down Expand Up @@ -828,9 +750,9 @@ mod tests {
use super::*;

fn deserialize<'p>(segments: impl IntoIterator<Item = &'p str>) -> 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")
}

Expand Down
77 changes: 3 additions & 74 deletions apps/hash-graph/lib/graph/src/ontology/property_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand Down Expand Up @@ -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()`]
///
Expand All @@ -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>,
Expand Down Expand Up @@ -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}"),
Expand Down Expand Up @@ -470,9 +399,9 @@ mod tests {
use super::*;

fn deserialize<'p>(segments: impl IntoIterator<Item = &'p str>) -> 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")
}

Expand Down
4 changes: 0 additions & 4 deletions apps/hash-graph/lib/graph/src/store/query/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")?;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-graph/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-10-30"
channel = "nightly-2023-11-20"
components = ['rustfmt', 'clippy', 'llvm-tools-preview']
1 change: 1 addition & 0 deletions libs/@local/codec/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion libs/@local/codec/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-10-30"
channel = "nightly-2023-11-20"
components = ['rustfmt', 'clippy', 'llvm-tools-preview']
1 change: 1 addition & 0 deletions libs/@local/hash-authorization/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Loading