Skip to content

Commit

Permalink
Fix clippy rants on 1.71.0 (#4067)
Browse files Browse the repository at this point in the history
* Fix clippy rants on 1.71.0

* Update query-engine/metrics/src/lib.rs

Co-authored-by: Alexey Orlenko <alex@aqrln.net>

---------

Co-authored-by: Alexey Orlenko <alex@aqrln.net>
  • Loading branch information
Miguel Fernández and aqrln authored Jul 14, 2023
1 parent 96f20d9 commit 4ea5cb7
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion libs/test-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ fn init_logger() {
.with_writer(std::io::stderr)
.finish()
.with(ErrorLayer::default())
.with(schema_core::TimingsLayer::default());
.with(schema_core::TimingsLayer);

tracing::subscriber::set_global_default(subscriber)
.map_err(|err| eprintln!("Error initializing the global logger: {err}"))
Expand Down
2 changes: 1 addition & 1 deletion psl/parser-database/src/attributes/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub(super) fn composite_type_field(
};

{
let mut field = ctx.types.composite_type_fields.get_mut(&(ctid, field_id)).unwrap();
let field = ctx.types.composite_type_fields.get_mut(&(ctid, field_id)).unwrap();
field.mapped_name = Some(mapped_name_id);
}

Expand Down
5 changes: 3 additions & 2 deletions psl/parser-database/src/attributes/native_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(super) fn visit_composite_type_field_native_type_attribute(
let args = &attr.arguments;
let args: Vec<String> = args.arguments.iter().map(|arg| arg.value.to_string()).collect();

let mut composite_type_field = ctx.types.composite_type_fields.get_mut(&id).unwrap();
composite_type_field.native_type = Some((datasource_name, type_name, args, attr.span))
if let Some(composite_type_field) = ctx.types.composite_type_fields.get_mut(&id) {
composite_type_field.native_type = Some((datasource_name, type_name, args, attr.span))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub async fn one2m(
if parent_field.is_inlined_on_enclosing_model() {
let mut additional_records = vec![];

for mut record in scalars.records.iter_mut() {
for record in scalars.records.iter_mut() {
let child_link: SelectionResult = record.extract_selection_result(&scalars.field_names, &child_link_id)?;
let child_link_values: Vec<PrismaValue> = child_link.pairs.into_iter().map(|(_, v)| v).collect();

Expand Down
8 changes: 3 additions & 5 deletions query-engine/core/src/query_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use petgraph::{
*,
};
use prisma_models::{FieldSelection, Model, SelectionResult};
use std::{borrow::Borrow, collections::HashSet, fmt};
use std::{collections::HashSet, fmt};

pub type QueryGraphResult<T> = std::result::Result<T, QueryGraphError>;

Expand Down Expand Up @@ -270,12 +270,10 @@ impl QueryGraph {
/// Returns all root nodes of the graph.
/// A root node is defined by having no incoming edges.
pub fn root_nodes(&self) -> Vec<NodeRef> {
let graph = self.graph.borrow();

graph
self.graph
.node_indices()
.filter_map(|node_ix| {
if graph.edges_directed(node_ix, Direction::Incoming).next().is_some() {
if self.graph.edges_directed(node_ix, Direction::Incoming).next().is_some() {
None
} else {
Some(NodeRef { node_ix })
Expand Down
3 changes: 1 addition & 2 deletions query-engine/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ static METRIC_RECORDER: Once = Once::new();

fn set_recorder() {
METRIC_RECORDER.call_once(|| {
let recorder = MetricRecorder::default();
metrics::set_boxed_recorder(Box::new(recorder)).unwrap();
metrics::set_boxed_recorder(Box::new(MetricRecorder)).unwrap();
});
}

Expand Down
2 changes: 1 addition & 1 deletion schema-engine/cli/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) fn init_logger() {
.with_writer(std::io::stderr)
.finish()
.with(ErrorLayer::default())
.with(TimingsLayer::default());
.with(TimingsLayer);

tracing::subscriber::set_global_default(subscriber)
.map_err(|err| eprintln!("Error initializing the global logger: {err}"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a> DifferDatabase<'a> {
}

for collection in next.walk_collections() {
let mut entry = collections.entry(collection.name()).or_default();
let entry = collections.entry(collection.name()).or_default();
entry.1 = Some(collection.id());

if let Some(previous_collection_id) = entry.0 {
Expand All @@ -57,7 +57,7 @@ impl<'a> DifferDatabase<'a> {
}

for index in collection.indexes() {
let mut entry = indexes
let entry = indexes
.entry((previous_collection_id, collection.id(), index.name()))
.or_default();
entry.1 = Some(index.id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ impl<'a> Statistics<'a> {

/// Track a collection as prisma model.
pub(super) fn track_model(&mut self, model: &str, collection: CollectionWalker<'a>) {
let mut model = self.models.entry(Name::Model(model.to_string())).or_default();
let model = self.models.entry(Name::Model(model.to_string())).or_default();
model.collection_walker = Some(collection);
}

Expand Down

0 comments on commit 4ea5cb7

Please sign in to comment.