Skip to content

Commit 108ccf2

Browse files
authored
Clippy fixes (#1181)
1 parent 27430bf commit 108ccf2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+191
-201
lines changed

juniper/src/executor/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ where
112112
Self: PartialEq,
113113
{
114114
fn partial_cmp(&self, other: &ExecutionError<S>) -> Option<Ordering> {
115-
(&self.location, &self.path, &self.error.message).partial_cmp(&(
116-
&other.location,
117-
&other.path,
118-
&other.error.message,
119-
))
115+
Some(self.cmp(other))
120116
}
121117
}
122118

juniper/src/executor_tests/directives.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl TestType {
2121

2222
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
2323
where
24-
F: Fn(&Object<DefaultScalarValue>) -> (),
24+
F: Fn(&Object<DefaultScalarValue>),
2525
{
2626
let schema = RootNode::new(
2727
TestType,
@@ -44,7 +44,7 @@ where
4444

4545
async fn run_query<F>(query: &str, f: F)
4646
where
47-
F: Fn(&Object<DefaultScalarValue>) -> (),
47+
F: Fn(&Object<DefaultScalarValue>),
4848
{
4949
run_variable_query(query, Variables::new(), f).await;
5050
}

juniper/src/executor_tests/enums.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl TestType {
3232

3333
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
3434
where
35-
F: Fn(&Object<DefaultScalarValue>) -> (),
35+
F: Fn(&Object<DefaultScalarValue>),
3636
{
3737
let schema = RootNode::new(
3838
TestType,
@@ -55,7 +55,7 @@ where
5555

5656
async fn run_query<F>(query: &str, f: F)
5757
where
58-
F: Fn(&Object<DefaultScalarValue>) -> (),
58+
F: Fn(&Object<DefaultScalarValue>),
5959
{
6060
run_variable_query(query, Variables::new(), f).await;
6161
}

juniper/src/executor_tests/introspection/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Root {
8989

9090
async fn run_type_info_query<F>(doc: &str, f: F)
9191
where
92-
F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)) -> (),
92+
F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)),
9393
{
9494
let schema = RootNode::new(
9595
Root,

juniper/src/executor_tests/introspection/input_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl Root {
114114

115115
async fn run_type_info_query<F>(doc: &str, f: F)
116116
where
117-
F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>) -> (),
117+
F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>),
118118
{
119119
let schema = RootNode::new(
120120
Root,

juniper/src/executor_tests/variables.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl TestType {
120120

121121
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
122122
where
123-
F: Fn(&Object<DefaultScalarValue>) -> (),
123+
F: Fn(&Object<DefaultScalarValue>),
124124
{
125125
let schema = RootNode::new(
126126
TestType,
@@ -143,7 +143,7 @@ where
143143

144144
async fn run_query<F>(query: &str, f: F)
145145
where
146-
F: Fn(&Object<DefaultScalarValue>) -> (),
146+
F: Fn(&Object<DefaultScalarValue>),
147147
{
148148
run_variable_query(query, graphql_vars! {}, f).await;
149149
}

juniper/src/parser/tests/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ where
1616
s,
1717
&SchemaType::new::<QueryRoot, MutationRoot, SubscriptionRoot>(&(), &(), &()),
1818
)
19-
.expect(&format!("Parse error on input {s:#?}"))
19+
.unwrap_or_else(|_| panic!("Parse error on input {s:#?}"))
2020
}
2121

2222
fn parse_document_error<S: ScalarValue>(s: &str) -> Spanning<ParseError> {

juniper/src/parser/tests/lexer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::parser::{Lexer, LexerError, ScalarToken, SourcePosition, Spanning, Token};
22

3-
fn tokenize_to_vec<'a>(s: &'a str) -> Vec<Spanning<Token<'a>>> {
3+
fn tokenize_to_vec(s: &str) -> Vec<Spanning<Token<'_>>> {
44
let mut tokens = Vec::new();
55
let mut lexer = Lexer::new(s);
66

@@ -21,7 +21,7 @@ fn tokenize_to_vec<'a>(s: &'a str) -> Vec<Spanning<Token<'a>>> {
2121
tokens
2222
}
2323

24-
fn tokenize_single<'a>(s: &'a str) -> Spanning<Token<'a>> {
24+
fn tokenize_single(s: &str) -> Spanning<Token<'_>> {
2525
let mut tokens = tokenize_to_vec(s);
2626

2727
assert_eq!(tokens.len(), 2);
@@ -178,7 +178,7 @@ fn strings() {
178178
Spanning::start_end(
179179
&SourcePosition::new(0, 0, 0),
180180
&SourcePosition::new(20, 0, 20),
181-
Token::Scalar(ScalarToken::String(r#"escaped \n\r\b\t\f"#))
181+
Token::Scalar(ScalarToken::String(r"escaped \n\r\b\t\f"))
182182
)
183183
);
184184

@@ -187,7 +187,7 @@ fn strings() {
187187
Spanning::start_end(
188188
&SourcePosition::new(0, 0, 0),
189189
&SourcePosition::new(15, 0, 15),
190-
Token::Scalar(ScalarToken::String(r#"slashes \\ \/"#))
190+
Token::Scalar(ScalarToken::String(r"slashes \\ \/"))
191191
)
192192
);
193193

@@ -196,7 +196,7 @@ fn strings() {
196196
Spanning::start_end(
197197
&SourcePosition::new(0, 0, 0),
198198
&SourcePosition::new(34, 0, 34),
199-
Token::Scalar(ScalarToken::String(r#"unicode \u1234\u5678\u90AB\uCDEF"#)),
199+
Token::Scalar(ScalarToken::String(r"unicode \u1234\u5678\u90AB\uCDEF")),
200200
)
201201
);
202202
}

juniper/src/parser/tests/value.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Query {
3636
}
3737

3838
fn float_field() -> f64 {
39-
3.14
39+
3.12
4040
}
4141

4242
fn string_field() -> String {
@@ -65,11 +65,12 @@ where
6565
S: ScalarValue,
6666
{
6767
let mut lexer = Lexer::new(s);
68-
let mut parser = Parser::new(&mut lexer).expect(&format!("Lexer error on input {s:#?}"));
68+
let mut parser =
69+
Parser::new(&mut lexer).unwrap_or_else(|_| panic!("Lexer error on input {s:#?}"));
6970
let schema = SchemaType::new::<Query, EmptyMutation<()>, EmptySubscription<()>>(&(), &(), &());
7071

7172
parse_value_literal(&mut parser, false, &schema, Some(meta))
72-
.expect(&format!("Parse error on input {s:#?}"))
73+
.unwrap_or_else(|_| panic!("Parse error on input {s:#?}"))
7374
}
7475

7576
#[test]

juniper/src/schema/translate/graphql_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl GraphQLParserTranslator {
264264
.map(|x| GraphQLParserTranslator::translate_argument(x))
265265
.collect()
266266
})
267-
.unwrap_or_else(Vec::new);
267+
.unwrap_or_default();
268268

269269
ExternalField {
270270
position: Pos::default(),

0 commit comments

Comments
 (0)