Skip to content

Commit 33adfef

Browse files
committed
Tune lints for 1.84 Rust
1 parent 5bda80e commit 33adfef

File tree

9 files changed

+30
-12
lines changed

9 files changed

+30
-12
lines changed

juniper/src/macros/reflect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ pub const fn fnv1a128(str: Name) -> u128 {
417417
/// Length __in bytes__ of the [`format_type!`] macro result.
418418
#[must_use]
419419
pub const fn type_len_with_wrapped_val(ty: Type, val: WrappedValue) -> usize {
420-
let mut len = ty.as_bytes().len() + "!".as_bytes().len(); // Type!
420+
let mut len = ty.len() + "!".len(); // Type!
421421

422422
let mut curr = val;
423423
while curr % 10 != 0 {
424424
match curr % 10 {
425-
2 => len -= "!".as_bytes().len(), // remove !
426-
3 => len += "[]!".as_bytes().len(), // [Type]!
425+
2 => len -= "!".len(), // remove !
426+
3 => len += "[]!".len(), // [Type]!
427427
_ => {}
428428
}
429429
curr /= 10;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ error[E0277]: the trait bound `ObjA: reflect::Field<__S, 11301463986558097276003
2828
11 | id: String,
2929
| ^^ the trait `reflect::Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
3030
|
31-
= help: the trait `reflect::Field<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA`
31+
= help: the trait `Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
32+
but trait `Field<__S, 140650918148392961738240285796466530725>` is implemented for it
3233

3334
error[E0277]: the trait bound `ObjA: AsyncField<__S, 11301463986558097276003903130001171064>` is not satisfied
3435
--> fail/interface/struct/attr_missing_field.rs:11:5
3536
|
3637
11 | id: String,
3738
| ^^ the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
3839
|
39-
= help: the trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA`
40+
= help: the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
41+
but trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for it

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ error[E0277]: the trait bound `ObjA: reflect::Field<__S, 11301463986558097276003
2828
12 | id: String,
2929
| ^^ the trait `reflect::Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
3030
|
31-
= help: the trait `reflect::Field<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA`
31+
= help: the trait `Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
32+
but trait `Field<__S, 140650918148392961738240285796466530725>` is implemented for it
3233

3334
error[E0277]: the trait bound `ObjA: AsyncField<__S, 11301463986558097276003903130001171064>` is not satisfied
3435
--> fail/interface/struct/derive_missing_field.rs:12:5
3536
|
3637
12 | id: String,
3738
| ^^ the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
3839
|
39-
= help: the trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA`
40+
= help: the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
41+
but trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for it

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `[bool; 2]: From<[bool; 3]>` is not satisfied
22
--> fail/interface/trait/argument_wrong_default_array.rs:3:1
33
|
44
3 | #[graphql_interface]
5-
| ^^^^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]`, which is required by `[bool; 3]: Into<_>`
5+
| ^^^^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]`
66
|
77
= help: the following other types implement trait `From<T>`:
88
`[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>`

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ error[E0277]: the trait bound `ObjA: reflect::Field<__S, 11301463986558097276003
2828
11 | fn id(&self) -> &str;
2929
| ^^ the trait `reflect::Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
3030
|
31-
= help: the trait `reflect::Field<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA`
31+
= help: the trait `Field<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
32+
but trait `Field<__S, 140650918148392961738240285796466530725>` is implemented for it
3233

3334
error[E0277]: the trait bound `ObjA: AsyncField<__S, 11301463986558097276003903130001171064>` is not satisfied
3435
--> fail/interface/trait/missing_field.rs:11:8
3536
|
3637
11 | fn id(&self) -> &str;
3738
| ^^ the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
3839
|
39-
= help: the trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for `ObjA`
40+
= help: the trait `AsyncField<__S, 11301463986558097276003903130001171064>` is not implemented for `ObjA`
41+
but trait `AsyncField<__S, 140650918148392961738240285796466530725>` is implemented for it

tests/codegen/fail/object/argument_wrong_default_array.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `[bool; 2]: From<[bool; 3]>` is not satisfied
22
--> fail/object/argument_wrong_default_array.rs:5:1
33
|
44
5 | #[graphql_object]
5-
| ^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]`, which is required by `[bool; 3]: Into<_>`
5+
| ^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]`
66
|
77
= help: the following other types implement trait `From<T>`:
88
`[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>`

tests/codegen/fail/subscription/argument_wrong_default_array.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `[bool; 2]: From<[bool; 3]>` is not satisfied
22
--> fail/subscription/argument_wrong_default_array.rs:10:1
33
|
44
10 | #[graphql_subscription]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]`, which is required by `[bool; 3]: Into<_>`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]`
66
|
77
= help: the following other types implement trait `From<T>`:
88
`[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>`

tests/integration/tests/codegen_object_attr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ mod generic_lifetime_async {
617617
home_planet: &'p str,
618618
}
619619

620+
#[allow(clippy::needless_lifetimes)] // required by codegen
620621
#[graphql_object]
621622
impl<'p> Human<'p, i32> {
622623
async fn id(&self) -> i32 {
@@ -628,6 +629,7 @@ mod generic_lifetime_async {
628629
}
629630
}
630631

632+
#[allow(clippy::needless_lifetimes)] // required by codegen
631633
#[graphql_object(name = "HumanString")]
632634
impl<'id, 'p> Human<'p, &'id str> {
633635
async fn id(&self) -> &str {
@@ -724,6 +726,7 @@ mod nested_generic_lifetime_async {
724726
primary_function: &'p str,
725727
}
726728

729+
#[allow(clippy::needless_lifetimes)] // required by codegen
727730
#[graphql_object]
728731
impl<'p> Droid<'p, i32> {
729732
async fn id(&self) -> i32 {
@@ -735,6 +738,7 @@ mod nested_generic_lifetime_async {
735738
}
736739
}
737740

741+
#[allow(clippy::needless_lifetimes)] // required by codegen
738742
#[graphql_object(name = "DroidString")]
739743
impl<'id, 'p> Droid<'p, &'id str> {
740744
async fn id(&self) -> &str {
@@ -751,6 +755,7 @@ mod nested_generic_lifetime_async {
751755
home_planet: &'p str,
752756
}
753757

758+
#[allow(clippy::needless_lifetimes)] // required by codegen
754759
#[graphql_object]
755760
impl<'p> Human<'p, i32> {
756761
async fn id(&self) -> i32 {
@@ -769,6 +774,7 @@ mod nested_generic_lifetime_async {
769774
}
770775
}
771776

777+
#[allow(clippy::needless_lifetimes)] // required by codegen
772778
#[graphql_object(name = "HumanString")]
773779
impl<'id, 'p> Human<'p, &'id str> {
774780
async fn id(&self) -> &str {

tests/integration/tests/codegen_subscription_attr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ mod generic_lifetime {
729729
home_planet: &'p str,
730730
}
731731

732+
#[allow(clippy::needless_lifetimes)] // required by codegen
732733
#[graphql_subscription]
733734
impl<'p> Human<'p, i32> {
734735
async fn id(&self) -> Stream<'static, i32> {
@@ -741,6 +742,7 @@ mod generic_lifetime {
741742
}
742743
}
743744

745+
#[allow(clippy::needless_lifetimes)] // required by codegen
744746
#[graphql_subscription(name = "HumanString")]
745747
impl<'id, 'p> Human<'p, &'id str> {
746748
// TODO: Make it work with `Stream<'_, &str>`.
@@ -1539,6 +1541,7 @@ mod explicit_custom_context {
15391541
#[graphql_subscription(context = CustomContext)]
15401542
impl Human {
15411543
// TODO: Make work for `Stream<'c, prelude::String>`.
1544+
#[allow(clippy::needless_lifetimes)] // required by codegen
15421545
async fn id<'c>(&self, context: &'c CustomContext) -> Stream<'static, prelude::String> {
15431546
prelude::Box::pin(stream::once(future::ready(context.0.clone())))
15441547
}
@@ -1628,6 +1631,7 @@ mod inferred_custom_context_from_field {
16281631
#[graphql_subscription]
16291632
impl Human {
16301633
// TODO: Make work for `Stream<'c, prelude::String>`.
1634+
#[allow(clippy::needless_lifetimes)] // required by codegen
16311635
async fn id<'c>(&self, context: &'c CustomContext) -> Stream<'static, prelude::String> {
16321636
prelude::Box::pin(stream::once(future::ready(context.0.clone())))
16331637
}
@@ -1704,6 +1708,7 @@ mod executor {
17041708
#[graphql_subscription(scalar = S: ScalarValue)]
17051709
impl Human {
17061710
// TODO: Make work for `Stream<'e, &'e str>`.
1711+
#[allow(clippy::needless_lifetimes)] // required by codegen
17071712
async fn id<'e, S>(
17081713
&self,
17091714
executor: &'e Executor<'_, '_, (), S>,
@@ -1725,6 +1730,7 @@ mod executor {
17251730
}
17261731

17271732
// TODO: Make work for `Stream<'e, &'e str>`.
1733+
#[allow(clippy::needless_lifetimes)] // required by codegen
17281734
async fn info2<'e, S>(
17291735
_executor: &'e Executor<'_, '_, (), S>,
17301736
) -> Stream<'static, &'static str> {

0 commit comments

Comments
 (0)