Skip to content

Commit a7f6164

Browse files
committed
fix clippy warnings
1 parent c70b91d commit a7f6164

File tree

10 files changed

+79
-76
lines changed

10 files changed

+79
-76
lines changed

crates/apollo-parser/src/ast/node_ext.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This lint is here as we don't really need users to convert String/i64/f64
2+
// into an AST Node. Should this change, we can remove this lint again.
3+
#![allow(clippy::from_over_into)]
4+
15
use crate::{ast, ast::AstNode, SyntaxNode, TokenText};
26

37
impl ast::Name {

crates/apollo-parser/src/error.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ use std::fmt;
1212
/// ```rust
1313
/// use apollo_parser::Parser;
1414
///
15-
/// fn main() {
16-
/// let input = "union SearchResult = Photo | Person | Cat | Dog";
17-
/// let parser = Parser::new(input);
18-
/// let ast = parser.parse();
15+
/// let input = "union SearchResult = Photo | Person | Cat | Dog";
16+
/// let parser = Parser::new(input);
17+
/// let ast = parser.parse();
1918
///
20-
/// assert!(ast.errors().is_empty());
19+
/// assert!(ast.errors().is_empty());
2120
///
22-
/// let doc = ast.document();
23-
/// }
21+
/// let doc = ast.document();
2422
/// ```
2523
///
2624
/// `Error` struct does not at the moment implement `Display`. We encourage you

crates/apollo-parser/src/lib.rs

Lines changed: 58 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,26 @@
4747
//! ```rust
4848
//! use apollo_parser::Parser;
4949
//!
50-
//! fn main() {
51-
//! let input = "union SearchResult = Photo | Person | Cat | Dog";
52-
//! let parser = Parser::new(input);
53-
//! let ast = parser.parse();
54-
//! }
50+
//! let input = "union SearchResult = Photo | Person | Cat | Dog";
51+
//! let parser = Parser::new(input);
52+
//! let ast = parser.parse();
5553
//! ```
5654
//!
5755
//! `apollo-parser` is built to be error-resilient. This means we don't abort parsing (or lexing) if an error occurs. That means `parser.parse()` will always produce an AST, and it will be accompanied by any errors that are encountered:
5856
//!
5957
//! ```rust
6058
//! use apollo_parser::Parser;
6159
//!
62-
//! fn main() {
63-
//! let input = "union SearchResult = Photo | Person | Cat | Dog";
64-
//! let parser = Parser::new(input);
65-
//! let ast = parser.parse();
60+
//! let input = "union SearchResult = Photo | Person | Cat | Dog";
61+
//! let parser = Parser::new(input);
62+
//! let ast = parser.parse();
6663
//!
67-
//! // ast.errors() returns an errors slice encountered during lexing and parsing
68-
//! assert!(ast.errors().is_empty());
64+
//! // ast.errors() returns an errors slice encountered during lexing and parsing
65+
//! assert!(ast.errors().is_empty());
6966
//!
70-
//! // ast.document() get the Document, or root node, of the tree that you can
71-
//! // start iterating on.
72-
//! let doc = ast.document();
73-
//! }
67+
//! // ast.document() get the Document, or root node, of the tree that you can
68+
//! // start iterating on.
69+
//! let doc = ast.document();
7470
//! ```
7571
//!
7672
//! ### Examples
@@ -90,25 +86,23 @@
9086
//! ```rust
9187
//! use apollo_parser::{ast, Parser};
9288
//!
93-
//! fn main() {
94-
//! let input = "
95-
//! type ProductDimension {
96-
//! size: String
97-
//! weight: Float @tag(name: \"hi from inventory value type field\")
98-
//! }
99-
//! ";
100-
//! let parser = Parser::new(input);
101-
//! let ast = parser.parse();
102-
//! assert!(ast.errors().is_empty());
103-
//!
104-
//! let doc = ast.document();
105-
//!
106-
//! for def in doc.definitions() {
107-
//! if let ast::Definition::ObjectTypeDefinition(object_type) = def {
108-
//! assert_eq!(object_type.name().unwrap().text(), "ProductDimension");
109-
//! for field_def in object_type.fields_definition().unwrap().field_definitions() {
110-
//! println!("{}", field_def.name().unwrap().text()); // size weight
111-
//! }
89+
//! let input = "
90+
//! type ProductDimension {
91+
//! size: String
92+
//! weight: Float @tag(name: \"hi from inventory value type field\")
93+
//! }
94+
//! ";
95+
//! let parser = Parser::new(input);
96+
//! let ast = parser.parse();
97+
//! assert!(ast.errors().is_empty());
98+
//!
99+
//! let doc = ast.document();
100+
//!
101+
//! for def in doc.definitions() {
102+
//! if let ast::Definition::ObjectTypeDefinition(object_type) = def {
103+
//! assert_eq!(object_type.name().unwrap().text(), "ProductDimension");
104+
//! for field_def in object_type.fields_definition().unwrap().field_definitions() {
105+
//! println!("{}", field_def.name().unwrap().text()); // size weight
112106
//! }
113107
//! }
114108
//! }
@@ -119,39 +113,37 @@
119113
//! ```rust
120114
//! use apollo_parser::{ast, Parser};
121115
//!
122-
//! fn main() {
123-
//! let input = "
124-
//! query GraphQuery($graph_id: ID!, $variant: String) {
125-
//! service(id: $graph_id) {
126-
//! schema(tag: $variant) {
127-
//! document
128-
//! }
129-
//! }
116+
//! let input = "
117+
//! query GraphQuery($graph_id: ID!, $variant: String) {
118+
//! service(id: $graph_id) {
119+
//! schema(tag: $variant) {
120+
//! document
130121
//! }
131-
//! ";
132-
//!
133-
//! let parser = Parser::new(input);
134-
//! let ast = parser.parse();
135-
//! assert!(&ast.errors().is_empty());
136-
//!
137-
//! let doc = ast.document();
138-
//!
139-
//! for def in doc.definitions() {
140-
//! if let ast::Definition::OperationDefinition(op_def) = def {
141-
//! assert_eq!(op_def.name().unwrap().text(), "GraphQuery");
142-
//!
143-
//! let variable_defs = op_def.variable_definitions();
144-
//! let variables: Vec<String> = variable_defs
145-
//! .iter()
146-
//! .map(|v| v.variable_definitions())
147-
//! .flatten()
148-
//! .filter_map(|v| Some(v.variable()?.text().to_string()))
149-
//! .collect();
150-
//! assert_eq!(
151-
//! variables.as_slice(),
152-
//! ["graph_id".to_string(), "variant".to_string()]
153-
//! );
154-
//! }
122+
//! }
123+
//! }
124+
//! ";
125+
//!
126+
//! let parser = Parser::new(input);
127+
//! let ast = parser.parse();
128+
//! assert!(&ast.errors().is_empty());
129+
//!
130+
//! let doc = ast.document();
131+
//!
132+
//! for def in doc.definitions() {
133+
//! if let ast::Definition::OperationDefinition(op_def) = def {
134+
//! assert_eq!(op_def.name().unwrap().text(), "GraphQuery");
135+
//!
136+
//! let variable_defs = op_def.variable_definitions();
137+
//! let variables: Vec<String> = variable_defs
138+
//! .iter()
139+
//! .map(|v| v.variable_definitions())
140+
//! .flatten()
141+
//! .filter_map(|v| Some(v.variable()?.text().to_string()))
142+
//! .collect();
143+
//! assert_eq!(
144+
//! variables.as_slice(),
145+
//! ["graph_id".to_string(), "variant".to_string()]
146+
//! );
155147
//! }
156148
//! }
157149
//! ```

crates/apollo-parser/src/parser/generated/syntax_kind.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
bad_style,
66
missing_docs,
77
unreachable_pub,
8-
clippy::manual_non_exhaustive
8+
clippy::manual_non_exhaustive,
9+
clippy::upper_case_acronyms
910
)]
1011
#[doc = r" A token generated by the `Parser`."]
1112
#[non_exhaustive]

crates/apollo-parser/src/parser/grammar/enum_.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::needless_return)]
2+
13
use crate::{
24
parser::grammar::{description, directive, name, value},
35
Parser, SyntaxKind, TokenKind, S, T,

crates/apollo-parser/src/parser/grammar/field.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::needless_return)]
2+
13
use crate::{
24
parser::grammar::{argument, description, directive, name, selection, ty},
35
Parser, SyntaxKind, TokenKind, S, T,

crates/apollo-parser/src/parser/grammar/object.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::needless_return)]
2+
13
use crate::{
24
parser::grammar::{description, directive, document::is_definition, field, name, ty},
35
Parser, SyntaxKind, TokenKind, S, T,

crates/apollo-parser/src/parser/grammar/union_.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::needless_return)]
2+
13
use crate::{
24
parser::grammar::{description, directive, document::is_definition, name, ty},
35
Parser, SyntaxKind, TokenKind, S, T,

crates/apollo-parser/src/parser/grammar/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub(crate) fn object_field(p: &mut Parser) {
126126
value(p);
127127
if p.peek().is_some() {
128128
guard.finish_node();
129-
return object_field(p);
129+
object_field(p)
130130
}
131131
}
132132
}

xtask/src/codegen/gen_syntax_kinds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn generate_kinds(kinds: KindsSrc<'_>) -> Result<String> {
5858
.collect::<Vec<_>>();
5959

6060
let ast = quote! {
61-
#![allow(bad_style, missing_docs, unreachable_pub, clippy::manual_non_exhaustive)]
61+
#![allow(bad_style, missing_docs, unreachable_pub, clippy::manual_non_exhaustive, clippy::upper_case_acronyms)]
6262
/// A token generated by the `Parser`.
6363
#[non_exhaustive]
6464
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]

0 commit comments

Comments
 (0)