Skip to content

chore: update rust version #3043

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

Merged
merged 11 commits into from
Nov 2, 2024
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ jobs:
with:
target: wasm32-unknown-unknown

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.0"

- name: Install Wasm Pack
run: cargo install wasm-bindgen-cli --vers "0.2.92"

Expand Down
2 changes: 1 addition & 1 deletion .nightly/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-06-01"
channel = "nightly-2024-10-20"
profile = "default"
2 changes: 1 addition & 1 deletion benches/request_template_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl PathValue for Context {
}

impl PathString for Context {
fn path_string<'a, T: AsRef<str>>(&'a self, parts: &'a [T]) -> Option<Cow<'_, str>> {
fn path_string<'a, T: AsRef<str>>(&'a self, parts: &'a [T]) -> Option<Cow<'a, str>> {
self.value.path_string(parts)
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.80"
channel = "1.82"
profile = "default"
2 changes: 1 addition & 1 deletion src/cli/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
format!("{}", heading.bold())
}

pub fn meta(meta: &String) -> String {
pub fn meta(meta: &str) -> String {

Check warning on line 12 in src/cli/fmt.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/fmt.rs#L12

Added line #L12 was not covered by tests
format!("{}", meta.yellow())
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/async_graphql_hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl GraphQLArcResponse {
.collect::<Vec<u8>>();

// Wrap the result in square brackets
[&[b'['], &combined[..], &[b']']].concat()
[b"[", &combined[..], b"]"].concat()
}
JITBatchResponse::Single(resp) => resp.body.as_ref().to_owned(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/core/blueprint/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ pub fn to_field_definition(
object_name: &str,
config_module: &ConfigModule,
type_of: &config::Type,
name: &String,
name: &str,
) -> Valid<FieldDefinition, String> {
update_args()
.and(update_http().trace(config::Http::trace_name().as_str()))
Expand Down
4 changes: 2 additions & 2 deletions src/core/config/npo/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a> From<Chunk<Chunk<FieldName<'a>>>> for QueryPath<'a> {
}
}

impl<'a> Display for QueryPath<'a> {
impl Display for QueryPath<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let query_data: Vec<String> = self
.0
Expand Down Expand Up @@ -109,7 +109,7 @@ pub struct PathTracker<'a> {
}

impl<'a> PathTracker<'a> {
pub fn new(config: &'a Config) -> PathTracker {
pub fn new(config: &'a Config) -> PathTracker<'a> {
PathTracker { config, cache: Default::default() }
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/config/reader_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct ConfigReaderContext<'a> {
pub headers: HeaderMap,
}

impl<'a> PathString for ConfigReaderContext<'a> {
impl PathString for ConfigReaderContext<'_> {
fn path_string<T: AsRef<str>>(&self, path: &[T]) -> Option<Cow<'_, str>> {
if path.is_empty() {
return None;
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/transformer/merge_types/similarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SimilarityTypeInfo<'a> {
}

impl<'a> Similarity<'a> {
pub fn new(config: &'a Config) -> Similarity {
pub fn new(config: &'a Config) -> Similarity<'a> {
Similarity { config, type_similarity_cache: PairMap::default() }
}

Expand Down
1 change: 1 addition & 0 deletions src/core/generator/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Generator {
transformers: Vec<Box<dyn Transform<Value = Config, Error = String>>>,
}

#[allow(clippy::large_enum_variant)]
#[derive(Clone)]
pub enum Input {
Json {
Expand Down
2 changes: 1 addition & 1 deletion src/core/grpc/request_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
}

impl crate::core::path::PathString for Context {
fn path_string<'a, T: AsRef<str>>(&'a self, parts: &'a [T]) -> Option<Cow<'_, str>> {
fn path_string<'a, T: AsRef<str>>(&'a self, parts: &'a [T]) -> Option<Cow<'a, str>> {

Check warning on line 207 in src/core/grpc/request_template.rs

View check run for this annotation

Codecov / codecov/patch

src/core/grpc/request_template.rs#L207

Added line #L207 was not covered by tests
self.value.path_string(parts)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/has_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub trait HasHeaders {
fn headers(&self) -> &HeaderMap;
}

impl<'a, Ctx: ResolverContextLike> HasHeaders for EvalContext<'a, Ctx> {
impl<Ctx: ResolverContextLike> HasHeaders for EvalContext<'_, Ctx> {
fn headers(&self) -> &HeaderMap {
self.headers()
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/http/request_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ impl<Ctx: PathString + HasHeaders + PathValue> CacheKey<Ctx> for RequestTemplate

/// ValueStringEval parses the mustache template and uses ctx to retrieve the
/// values for templates.

struct ValueStringEval<A>(std::marker::PhantomData<A>);
impl<A> Default for ValueStringEval<A> {
fn default() -> Self {
Expand Down Expand Up @@ -344,7 +343,7 @@ mod tests {
}

impl crate::core::path::PathString for Context {
fn path_string<'a, T: AsRef<str>>(&'a self, parts: &'a [T]) -> Option<Cow<'_, str>> {
fn path_string<'a, T: AsRef<str>>(&'a self, parts: &'a [T]) -> Option<Cow<'a, str>> {
self.value.path_string(parts)
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/core/ir/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@ use super::{Error, EvalContext, ResolverContextLike, TypedValue};
use crate::core::json::{JsonLike, JsonObjectLike};
use crate::core::serde_value_ext::ValueExt;

// Fake trait to capture proper lifetimes.
// see discussion https://users.rust-lang.org/t/rpitit-allows-more-flexible-code-in-comparison-with-raw-rpit-in-inherit-impl/113417
// TODO: could be removed after migrating to 2024 edition
pub trait Captures<T: ?Sized> {}
impl<T: ?Sized, U: ?Sized> Captures<T> for U {}

impl IR {
#[tracing::instrument(skip_all, fields(otel.name = %self), err)]
pub fn eval<'a, 'b, Ctx>(
&'a self,
ctx: &'b mut EvalContext<'a, Ctx>,
) -> impl Future<Output = Result<ConstValue, Error>> + Send + Captures<&'b &'a ()>
) -> impl Future<Output = Result<ConstValue, Error>> + Send + use<'a, 'b, Ctx>
where
Ctx: ResolverContextLike + Sync,
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/ir/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'a, Ctx: ResolverContextLike> EvalContext<'a, Ctx> {
}
}

impl<'a, Ctx: ResolverContextLike> GraphQLOperationContext for EvalContext<'a, Ctx> {
impl<Ctx: ResolverContextLike> GraphQLOperationContext for EvalContext<'_, Ctx> {
fn directives(&self) -> Option<String> {
let selection_field = self.graphql_ctx.field()?;
selection_field
Expand Down
2 changes: 1 addition & 1 deletion src/core/ir/resolver_context_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> From<async_graphql::dynamic::ResolverContext<'a>> for ResolverContext<'
}
}

impl<'a> ResolverContextLike for ResolverContext<'a> {
impl ResolverContextLike for ResolverContext<'_> {
fn value(&self) -> Option<&Value> {
self.inner.parent_value.as_value()
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/jit/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'a, Input: Clone, Output> Context<'a, Input, Output> {
}
}

impl<'a> ResolverContextLike for Context<'a, ConstValue, ConstValue> {
impl ResolverContextLike for Context<'_, ConstValue, ConstValue> {
fn value(&self) -> Option<&ConstValue> {
self.value
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/jit/fixtures/jp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'a, Value: Deserialize<'a> + Clone + 'a + JsonLike<'a> + std::fmt::Debug> J
JP { test_data, plan, vars }
}

pub fn synth(&'a self) -> Synth<Value> {
pub fn synth(&'a self) -> Synth<'a, Value> {
let ProcessedTestData { posts, users } = self.test_data.to_processed();
let vars = self.vars.clone();

Expand Down
2 changes: 1 addition & 1 deletion src/core/jit/transform/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a, Var, Value> Skip<'a, Var, Value> {
}
}

impl<'a, Var, Value: Clone> Transform for Skip<'a, Var, Value>
impl<Var, Value: Clone> Transform for Skip<'_, Var, Value>
where
Var: for<'b> JsonLike<'b> + Clone,
{
Expand Down
6 changes: 3 additions & 3 deletions src/core/json/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
self.is_null()
}

fn get_path<T: AsRef<str>>(&'ctx self, path: &[T]) -> Option<&Self> {
fn get_path<T: AsRef<str>>(&'ctx self, path: &[T]) -> Option<&'ctx Self> {

Check warning on line 111 in src/core/json/borrow.rs

View check run for this annotation

Codecov / codecov/patch

src/core/json/borrow.rs#L111

Added line #L111 was not covered by tests
let mut val = self;
for token in path {
val = match val {
Expand All @@ -123,14 +123,14 @@
Some(val)
}

fn get_key(&'ctx self, path: &str) -> Option<&Self> {
fn get_key(&'ctx self, path: &str) -> Option<&'ctx Self> {

Check warning on line 126 in src/core/json/borrow.rs

View check run for this annotation

Codecov / codecov/patch

src/core/json/borrow.rs#L126

Added line #L126 was not covered by tests
match self {
Value::Object(map) => map.get(path),
_ => None,
}
}

fn group_by(&'ctx self, path: &[String]) -> std::collections::HashMap<String, Vec<&Self>> {
fn group_by(&'ctx self, path: &[String]) -> std::collections::HashMap<String, Vec<&'ctx Self>> {

Check warning on line 133 in src/core/json/borrow.rs

View check run for this annotation

Codecov / codecov/patch

src/core/json/borrow.rs#L133

Added line #L133 was not covered by tests
let src = gather_path_matches(self, path, vec![]);
group_by_key(src)
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/json/json_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub trait JsonLike<'json>: Sized {
fn as_f64(&self) -> Option<f64>;
fn as_bool(&self) -> Option<bool>;
fn is_null(&self) -> bool;
fn get_path<T: AsRef<str>>(&'json self, path: &[T]) -> Option<&Self>;
fn get_key(&'json self, path: &str) -> Option<&Self>;
fn group_by(&'json self, path: &[String]) -> HashMap<String, Vec<&Self>>;
fn get_path<T: AsRef<str>>(&'json self, path: &[T]) -> Option<&'json Self>;
fn get_key(&'json self, path: &str) -> Option<&'json Self>;
fn group_by(&'json self, path: &[String]) -> HashMap<String, Vec<&'json Self>>;
}

/// A trait for objects that can be used as JSON objects
Expand Down
4 changes: 2 additions & 2 deletions src/core/mustache/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<A> PathStringEval<A> {
}
}

impl<'a, A: PathString> Eval<'a> for PathStringEval<A> {
impl<A: PathString> Eval<'_> for PathStringEval<A> {
type In = A;
type Out = String;

Expand Down Expand Up @@ -78,7 +78,7 @@ impl<A> PathGraphqlEval<A> {
}
}

impl<'a, A: PathGraphql> Eval<'a> for PathGraphqlEval<A> {
impl<A: PathGraphql> Eval<'_> for PathGraphqlEval<A> {
type In = A;
type Out = String;

Expand Down
14 changes: 6 additions & 8 deletions src/core/path.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//! The path module provides a trait for accessing values from a JSON-like
//! structure.
use std::borrow::Cow;

use serde_json::json;

use crate::core::ir::{EvalContext, ResolverContextLike};
use crate::core::json::JsonLike;

///
/// The path module provides a trait for accessing values from a JSON-like
/// structure.

///
/// The PathString trait provides a method for accessing values from a JSON-like
/// structure. The returned value is encoded as a plain string.
Expand Down Expand Up @@ -66,7 +64,7 @@ pub enum ValueString<'a> {
String(Cow<'a, str>),
}

impl<'a, Ctx: ResolverContextLike> EvalContext<'a, Ctx> {
impl<Ctx: ResolverContextLike> EvalContext<'_, Ctx> {
fn to_raw_value<T: AsRef<str>>(&self, path: &[T]) -> Option<ValueString<'_>> {
let ctx = self;

Expand Down Expand Up @@ -101,13 +99,13 @@ impl<'a, Ctx: ResolverContextLike> EvalContext<'a, Ctx> {
}
}

impl<'a, Ctx: ResolverContextLike> PathValue for EvalContext<'a, Ctx> {
impl<Ctx: ResolverContextLike> PathValue for EvalContext<'_, Ctx> {
fn raw_value<'b, T: AsRef<str>>(&'b self, path: &[T]) -> Option<ValueString<'b>> {
self.to_raw_value(path)
}
}

impl<'a, Ctx: ResolverContextLike> PathString for EvalContext<'a, Ctx> {
impl<Ctx: ResolverContextLike> PathString for EvalContext<'_, Ctx> {
fn path_string<T: AsRef<str>>(&self, path: &[T]) -> Option<Cow<'_, str>> {
self.to_raw_value(path).and_then(|value| match value {
ValueString::String(env) => Some(env),
Expand All @@ -116,7 +114,7 @@ impl<'a, Ctx: ResolverContextLike> PathString for EvalContext<'a, Ctx> {
}
}

impl<'a, Ctx: ResolverContextLike> PathGraphql for EvalContext<'a, Ctx> {
impl<Ctx: ResolverContextLike> PathGraphql for EvalContext<'_, Ctx> {
fn path_graphql<T: AsRef<str>>(&self, path: &[T]) -> Option<String> {
if path.len() < 2 {
return None;
Expand Down
1 change: 0 additions & 1 deletion src/core/rest/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub struct Endpoint {
}

/// Creates a Rest instance from @rest directive

impl Endpoint {
pub fn get_method(&self) -> &Method {
&self.method
Expand Down
2 changes: 1 addition & 1 deletion src/core/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const INFO_STR: &str = "INFO";
const WARN_STR: &str = "WARN";
const ERROR_STR: &str = "ERROR";

impl<'a> fmt::Display for FmtLevel<'a> {
impl fmt::Display for FmtLevel<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.ansi {
match *self.level {
Expand Down
Loading