Skip to content

Commit 2682ee1

Browse files
committed
Make Clippy happy for 1.78 Rust
1 parent 6ffbb66 commit 2682ee1

22 files changed

+191
-125
lines changed

juniper/src/schema/translate/graphql_parser.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ impl<'a, T> SchemaTranslator<'a, graphql_parser::schema::Document<'a, T>>
4040
where
4141
T: Text<'a> + Default,
4242
{
43-
fn translate_schema<S: 'a>(input: &'a SchemaType<S>) -> graphql_parser::schema::Document<'a, T>
43+
fn translate_schema<S>(input: &'a SchemaType<S>) -> graphql_parser::schema::Document<'a, T>
4444
where
45-
S: ScalarValue,
45+
S: ScalarValue + 'a,
4646
{
4747
let mut doc = Document::default();
4848

@@ -94,9 +94,9 @@ impl GraphQLParserTranslator {
9494
}
9595
}
9696

97-
fn translate_value<'a, S: 'a, T>(input: &'a InputValue<S>) -> ExternalValue<'a, T>
97+
fn translate_value<'a, S, T>(input: &'a InputValue<S>) -> ExternalValue<'a, T>
9898
where
99-
S: ScalarValue,
99+
S: ScalarValue + 'a,
100100
T: Text<'a>,
101101
{
102102
match input {
@@ -250,9 +250,9 @@ impl GraphQLParserTranslator {
250250
}
251251
}
252252

253-
fn translate_field<'a, S: 'a, T>(input: &'a Field<S>) -> ExternalField<'a, T>
253+
fn translate_field<'a, S, T>(input: &'a Field<S>) -> ExternalField<'a, T>
254254
where
255-
S: ScalarValue,
255+
S: ScalarValue + 'a,
256256
T: Text<'a>,
257257
{
258258
let arguments = input

juniper/src/schema/translate/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{ScalarValue, SchemaType};
22

3+
#[cfg_attr(not(feature = "schema-language"), allow(dead_code))]
34
pub trait SchemaTranslator<'a, T> {
45
fn translate_schema<S: 'a + ScalarValue>(s: &'a SchemaType<S>) -> T;
56
}

juniper/src/validation/rules/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ use crate::{
3535
};
3636

3737
#[doc(hidden)]
38-
pub fn visit_all_rules<'a, S: Debug>(ctx: &mut ValidatorContext<'a, S>, doc: &'a Document<S>)
38+
pub fn visit_all_rules<'a, S>(ctx: &mut ValidatorContext<'a, S>, doc: &'a Document<S>)
3939
where
40-
S: ScalarValue,
40+
S: Debug + ScalarValue,
4141
{
4242
// Some validators are depending on the results of other ones.
4343
// For example, validators checking fragments usually rely on the fact that

juniper/src/validation/rules/overlapping_fields_can_be_merged.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,26 @@ impl<K: Eq + Hash + Clone, V> OrderedMap<K, V> {
5959
}
6060
}
6161

62-
fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
62+
fn get<Q>(&self, k: &Q) -> Option<&V>
6363
where
6464
K: Borrow<Q>,
65-
Q: Hash + Eq,
65+
Q: Hash + Eq + ?Sized,
6666
{
6767
self.data.get(k)
6868
}
6969

70-
fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
70+
fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
7171
where
7272
K: Borrow<Q>,
73-
Q: Hash + Eq,
73+
Q: Hash + Eq + ?Sized,
7474
{
7575
self.data.get_mut(k)
7676
}
7777

78-
fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
78+
fn contains_key<Q>(&self, k: &Q) -> bool
7979
where
8080
K: Borrow<Q>,
81-
Q: Hash + Eq,
81+
Q: Hash + Eq + ?Sized,
8282
{
8383
self.data.contains_key(k)
8484
}

juniper_codegen/src/common/diagnostic.rs

-14
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,6 @@ mod polyfill {
342342
/// Behaves like [`Result::unwrap()`]: if `self` is [`Ok`] yield the contained value,
343343
/// otherwise abort macro execution.
344344
fn unwrap_or_abort(self) -> Self::Ok;
345-
346-
/// Behaves like [`Result::expect()`]: if `self` is [`Ok`] yield the contained value,
347-
/// otherwise abort macro execution.
348-
///
349-
/// If it aborts then resulting error message will be preceded with the provided `message`.
350-
fn expect_or_abort(self, message: &str) -> Self::Ok;
351345
}
352346

353347
impl<T, E: Into<Diagnostic>> ResultExt for Result<T, E> {
@@ -356,13 +350,5 @@ mod polyfill {
356350
fn unwrap_or_abort(self) -> T {
357351
self.unwrap_or_else(|e| e.into().abort())
358352
}
359-
360-
fn expect_or_abort(self, message: &str) -> T {
361-
self.unwrap_or_else(|e| {
362-
let mut d = e.into();
363-
d.msg = format!("{message}: {}", d.msg);
364-
d.abort()
365-
})
366-
}
367353
}
368354
}

juniper_codegen/src/common/parse/mod.rs

-22
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ impl TypeExt for syn::Type {
252252

253253
/// Extension of [`syn::Generics`] providing common function widely used by this crate for parsing.
254254
pub(crate) trait GenericsExt {
255-
/// Removes all default types out of type parameters and const parameters in these
256-
/// [`syn::Generics`].
257-
fn remove_defaults(&mut self);
258-
259255
/// Moves all trait and lifetime bounds of these [`syn::Generics`] to its [`syn::WhereClause`].
260256
fn move_bounds_to_where_clause(&mut self);
261257

@@ -269,24 +265,6 @@ pub(crate) trait GenericsExt {
269265
}
270266

271267
impl GenericsExt for syn::Generics {
272-
fn remove_defaults(&mut self) {
273-
use syn::GenericParam as P;
274-
275-
for p in &mut self.params {
276-
match p {
277-
P::Type(p) => {
278-
p.eq_token = None;
279-
p.default = None;
280-
}
281-
P::Lifetime(_) => {}
282-
P::Const(p) => {
283-
p.eq_token = None;
284-
p.default = None;
285-
}
286-
}
287-
}
288-
}
289-
290268
fn move_bounds_to_where_clause(&mut self) {
291269
use syn::GenericParam as P;
292270

juniper_codegen/src/graphql_interface/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl Definition {
401401

402402
let enum_gens = {
403403
let mut enum_gens = interface_gens.clone();
404-
enum_gens.params = interface_gens_lifetimes.clone();
404+
enum_gens.params.clone_from(&interface_gens_lifetimes);
405405
enum_gens.params.extend(variant_gens_pars.clone());
406406
enum_gens.params.extend(interface_gens_tys.clone());
407407
enum_gens

tests/codegen/fail/input-object/derive_incompatible_field_type.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error[E0277]: the trait bound `ObjectA: IsInputType<__S>` is not satisfied
1212
<Box<T> as IsInputType<S>>
1313
<juniper::schema::model::DirectiveLocation as IsInputType<__S>>
1414
<Arc<T> as IsInputType<S>>
15-
<Vec<T> as IsInputType<S>>
15+
<TypeKind as IsInputType<__S>>
1616
and $N others
1717

1818
error[E0277]: the trait bound `ObjectA: FromInputValue<__S>` is not satisfied
@@ -32,7 +32,7 @@ error[E0277]: the trait bound `ObjectA: FromInputValue<__S>` is not satisfied
3232
<Box<T> as FromInputValue<S>>
3333
<juniper::schema::model::DirectiveLocation as FromInputValue<__S>>
3434
<Arc<T> as FromInputValue<S>>
35-
<Vec<T> as FromInputValue<S>>
35+
<TypeKind as FromInputValue<__S>>
3636
and $N others
3737
note: required by a bound in `Registry::<'r, S>::arg`
3838
--> $WORKSPACE/juniper/src/executor/mod.rs
@@ -57,7 +57,7 @@ error[E0277]: the trait bound `ObjectA: FromInputValue<__S>` is not satisfied
5757
<Box<T> as FromInputValue<S>>
5858
<juniper::schema::model::DirectiveLocation as FromInputValue<__S>>
5959
<Arc<T> as FromInputValue<S>>
60-
<Vec<T> as FromInputValue<S>>
60+
<TypeKind as FromInputValue<__S>>
6161
and $N others
6262
= note: this error originates in the derive macro `GraphQLInputObject` (in Nightly builds, run with -Z macro-backtrace for more info)
6363

@@ -75,6 +75,6 @@ error[E0277]: the trait bound `ObjectA: ToInputValue<_>` is not satisfied
7575
<Box<T> as ToInputValue<S>>
7676
<juniper::schema::model::DirectiveLocation as ToInputValue<__S>>
7777
<Arc<T> as ToInputValue<S>>
78-
<Vec<T> as ToInputValue<S>>
78+
<TypeKind as ToInputValue<__S>>
7979
and $N others
8080
= note: this error originates in the derive macro `GraphQLInputObject` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
error[E0391]: cycle detected when expanding type alias `Node1Value`
2-
--> fail/interface/struct/attr_cyclic_impl.rs:3:46
3-
|
4-
3 | #[graphql_interface(impl = Node2Value, for = Node2Value)]
5-
| ^^^^^^^^^^
6-
|
2+
--> fail/interface/struct/attr_cyclic_impl.rs:3:46
3+
|
4+
3 | #[graphql_interface(impl = Node2Value, for = Node2Value)]
5+
| ^^^^^^^^^^
6+
|
77
note: ...which requires expanding type alias `Node2Value`...
8-
--> fail/interface/struct/attr_cyclic_impl.rs:8:46
9-
|
10-
8 | #[graphql_interface(impl = Node1Value, for = Node1Value)]
11-
| ^^^^^^^^^^
12-
= note: ...which again requires expanding type alias `Node1Value`, completing the cycle
13-
= note: type aliases cannot be recursive
14-
= help: consider using a struct, enum, or union instead to break the cycle
15-
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
16-
note: cycle used when collecting item types in top-level module
17-
--> fail/interface/struct/attr_cyclic_impl.rs:1:1
18-
|
19-
1 | / use juniper::graphql_interface;
20-
2 | |
21-
3 | | #[graphql_interface(impl = Node2Value, for = Node2Value)]
22-
4 | | struct Node1 {
23-
... |
24-
12 | |
25-
13 | | fn main() {}
26-
| |____________^
27-
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
8+
--> fail/interface/struct/attr_cyclic_impl.rs:8:46
9+
|
10+
8 | #[graphql_interface(impl = Node1Value, for = Node1Value)]
11+
| ^^^^^^^^^^
12+
= note: ...which again requires expanding type alias `Node1Value`, completing the cycle
13+
= note: type aliases cannot be recursive
14+
= help: consider using a struct, enum, or union instead to break the cycle
15+
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
16+
note: cycle used when computing type of `<impl at $DIR/fail/interface/struct/attr_cyclic_impl.rs:3:1: 3:58>`
17+
--> fail/interface/struct/attr_cyclic_impl.rs:3:1
18+
|
19+
3 | #[graphql_interface(impl = Node2Value, for = Node2Value)]
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
22+
= note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/codegen/fail/interface/struct/derive_cyclic_impl.stderr

+5-10
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ note: ...which requires expanding type alias `Node2Value`...
1313
= note: type aliases cannot be recursive
1414
= help: consider using a struct, enum, or union instead to break the cycle
1515
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
16-
note: cycle used when collecting item types in top-level module
17-
--> fail/interface/struct/derive_cyclic_impl.rs:1:1
16+
note: cycle used when computing type of `<impl at $DIR/fail/interface/struct/derive_cyclic_impl.rs:3:10: 3:26>`
17+
--> fail/interface/struct/derive_cyclic_impl.rs:3:10
1818
|
19-
1 | / use juniper::GraphQLInterface;
20-
2 | |
21-
3 | | #[derive(GraphQLInterface)]
22-
4 | | #[graphql(impl = Node2Value, for = Node2Value)]
23-
... |
24-
14 | |
25-
15 | | fn main() {}
26-
| |____________^
19+
3 | #[derive(GraphQLInterface)]
20+
| ^^^^^^^^^^^^^^^^
2721
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
22+
= note: this error originates in the derive macro `GraphQLInterface` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/codegen/fail/interface/trait/argument_non_input_type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ error[E0277]: the trait bound `ObjA: IsInputType<__S>` is not satisfied
1111
<Box<T> as IsInputType<S>>
1212
<juniper::schema::model::DirectiveLocation as IsInputType<__S>>
1313
<Arc<T> as IsInputType<S>>
14-
<Vec<T> as IsInputType<S>>
1514
<TypeKind as IsInputType<__S>>
15+
<Vec<T> as IsInputType<S>>
1616
and $N others
1717

1818
error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied
@@ -31,8 +31,8 @@ error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied
3131
<Box<T> as FromInputValue<S>>
3232
<juniper::schema::model::DirectiveLocation as FromInputValue<__S>>
3333
<Arc<T> as FromInputValue<S>>
34-
<Vec<T> as FromInputValue<S>>
3534
<TypeKind as FromInputValue<__S>>
35+
<Vec<T> as FromInputValue<S>>
3636
and $N others
3737
note: required by a bound in `Registry::<'r, S>::arg`
3838
--> $WORKSPACE/juniper/src/executor/mod.rs
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
error[E0391]: cycle detected when expanding type alias `Node1Value`
2-
--> fail/interface/trait/cyclic_impl.rs:3:46
3-
|
4-
3 | #[graphql_interface(impl = Node2Value, for = Node2Value)]
5-
| ^^^^^^^^^^
6-
|
2+
--> fail/interface/trait/cyclic_impl.rs:3:46
3+
|
4+
3 | #[graphql_interface(impl = Node2Value, for = Node2Value)]
5+
| ^^^^^^^^^^
6+
|
77
note: ...which requires expanding type alias `Node2Value`...
8-
--> fail/interface/trait/cyclic_impl.rs:8:46
9-
|
10-
8 | #[graphql_interface(impl = Node1Value, for = Node1Value)]
11-
| ^^^^^^^^^^
12-
= note: ...which again requires expanding type alias `Node1Value`, completing the cycle
13-
= note: type aliases cannot be recursive
14-
= help: consider using a struct, enum, or union instead to break the cycle
15-
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
16-
note: cycle used when collecting item types in top-level module
17-
--> fail/interface/trait/cyclic_impl.rs:1:1
18-
|
19-
1 | / use juniper::graphql_interface;
20-
2 | |
21-
3 | | #[graphql_interface(impl = Node2Value, for = Node2Value)]
22-
4 | | trait Node1 {
23-
... |
24-
12 | |
25-
13 | | fn main() {}
26-
| |____________^
27-
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
8+
--> fail/interface/trait/cyclic_impl.rs:8:46
9+
|
10+
8 | #[graphql_interface(impl = Node1Value, for = Node1Value)]
11+
| ^^^^^^^^^^
12+
= note: ...which again requires expanding type alias `Node1Value`, completing the cycle
13+
= note: type aliases cannot be recursive
14+
= help: consider using a struct, enum, or union instead to break the cycle
15+
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
16+
note: cycle used when computing type of `<impl at $DIR/fail/interface/trait/cyclic_impl.rs:3:1: 3:58>`
17+
--> fail/interface/trait/cyclic_impl.rs:3:1
18+
|
19+
3 | #[graphql_interface(impl = Node2Value, for = Node2Value)]
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
22+
= note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/codegen/fail/object/argument_non_input_type.stderr

+12-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ error[E0277]: the trait bound `ObjA: IsInputType<__S>` is not satisfied
1111
<Box<T> as IsInputType<S>>
1212
<juniper::schema::model::DirectiveLocation as IsInputType<__S>>
1313
<Arc<T> as IsInputType<S>>
14-
<Vec<T> as IsInputType<S>>
1514
<TypeKind as IsInputType<__S>>
15+
<Vec<T> as IsInputType<S>>
1616
and $N others
1717

1818
error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied
@@ -31,8 +31,8 @@ error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied
3131
<Box<T> as FromInputValue<S>>
3232
<juniper::schema::model::DirectiveLocation as FromInputValue<__S>>
3333
<Arc<T> as FromInputValue<S>>
34-
<Vec<T> as FromInputValue<S>>
3534
<TypeKind as FromInputValue<__S>>
35+
<Vec<T> as FromInputValue<S>>
3636
and $N others
3737
note: required by a bound in `Registry::<'r, S>::arg`
3838
--> $WORKSPACE/juniper/src/executor/mod.rs
@@ -56,8 +56,8 @@ error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied
5656
<Box<T> as FromInputValue<S>>
5757
<juniper::schema::model::DirectiveLocation as FromInputValue<__S>>
5858
<Arc<T> as FromInputValue<S>>
59-
<Vec<T> as FromInputValue<S>>
6059
<TypeKind as FromInputValue<__S>>
60+
<Vec<T> as FromInputValue<S>>
6161
and $N others
6262
= note: this error originates in the attribute macro `graphql_object` (in Nightly builds, run with -Z macro-backtrace for more info)
6363

@@ -74,6 +74,14 @@ error[E0277]: the trait bound `ObjA: FromInputValue<__S>` is not satisfied
7474
<Box<T> as FromInputValue<S>>
7575
<juniper::schema::model::DirectiveLocation as FromInputValue<__S>>
7676
<Arc<T> as FromInputValue<S>>
77-
<Vec<T> as FromInputValue<S>>
7877
<TypeKind as FromInputValue<__S>>
78+
<Vec<T> as FromInputValue<S>>
7979
and $N others
80+
81+
warning: unused variable: `obj`
82+
--> fail/object/argument_non_input_type.rs:12:18
83+
|
84+
12 | fn id(&self, obj: ObjA) -> &str {
85+
| ^^^ help: if this is intentional, prefix it with an underscore: `_obj`
86+
|
87+
= note: `#[warn(unused_variables)]` on by default

0 commit comments

Comments
 (0)