Skip to content

Commit af0eee6

Browse files
committed
cargo fmt
1 parent 9710b82 commit af0eee6

13 files changed

+3339
-2603
lines changed

src/ast.rs

Lines changed: 88 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
33
use std::fmt;
44

5-
#[cfg(feature="bigint")]
5+
#[cfg(feature = "bigint")]
66
use num_bigint::BigUint;
77

8-
#[cfg(feature="wtf8")]
8+
#[cfg(feature = "wtf8")]
99
use wtf8;
1010

11-
#[cfg(feature="bigint")]
11+
#[cfg(feature = "bigint")]
1212
pub type IntegerType = BigUint;
13-
#[cfg(not(feature="bigint"))]
13+
#[cfg(not(feature = "bigint"))]
1414
pub type IntegerType = u64;
1515

16-
#[cfg(feature="wtf8")]
16+
#[cfg(feature = "wtf8")]
1717
pub type PyStringContent = wtf8::Wtf8Buf;
18-
#[cfg(feature="wtf8")]
18+
#[cfg(feature = "wtf8")]
1919
pub type PyStringCodePoint = wtf8::CodePoint;
2020

21-
#[cfg(not(feature="wtf8"))]
21+
#[cfg(not(feature = "wtf8"))]
2222
pub type PyStringContent = String;
23-
#[cfg(not(feature="wtf8"))]
23+
#[cfg(not(feature = "wtf8"))]
2424
pub type PyStringCodePoint = char;
2525

2626
pub type Name = String;
@@ -43,7 +43,7 @@ impl<T> Default for StarParams<T> {
4343
}
4444

4545
/// The list of parameters of a function definition.
46-
#[derive(Clone, Debug, PartialEq, Default,)]
46+
#[derive(Clone, Debug, PartialEq, Default)]
4747
pub struct TypedArgsList {
4848
pub positional_args: Vec<(Name, Option<Expression>, Option<Expression>)>,
4949
pub star_args: StarParams<(Name, Option<Expression>)>,
@@ -99,12 +99,16 @@ pub enum Uop {
9999

100100
impl fmt::Display for Uop {
101101
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
102-
write!(f, "{}", match *self {
103-
Uop::Plus => "+",
104-
Uop::Minus => "-",
105-
Uop::Invert => "~",
106-
Uop::Not => "not ",
107-
})
102+
write!(
103+
f,
104+
"{}",
105+
match *self {
106+
Uop::Plus => "+",
107+
Uop::Minus => "-",
108+
Uop::Invert => "~",
109+
Uop::Not => "not ",
110+
}
111+
)
108112
}
109113
}
110114

@@ -144,42 +148,52 @@ pub enum Bop {
144148

145149
impl fmt::Display for Bop {
146150
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
147-
write!(f, "{}", match *self {
148-
Bop::Add => "+",
149-
Bop::Sub => "-",
150-
Bop::Mult => "*",
151-
Bop::Matmult => "@",
152-
Bop::Mod => "%",
153-
Bop::Floordiv => "//",
154-
Bop::Div => "/",
155-
Bop::Power => "**",
156-
Bop::Lshift => "<<",
157-
Bop::Rshift => ">>",
158-
Bop::BitAnd => "&",
159-
Bop::BitXor => "^",
160-
Bop::BitOr => "|",
161-
Bop::Lt => "<",
162-
Bop::Gt => ">",
163-
Bop::Eq => "==",
164-
Bop::Leq => "<=",
165-
Bop::Geq => ">=",
166-
Bop::Neq => "!=",
167-
Bop::In => " in ",
168-
Bop::NotIn => " not in ",
169-
Bop::Is => " is ",
170-
Bop::IsNot => " is not ",
171-
Bop::And => " and ",
172-
Bop::Or => " or ",
173-
})
151+
write!(
152+
f,
153+
"{}",
154+
match *self {
155+
Bop::Add => "+",
156+
Bop::Sub => "-",
157+
Bop::Mult => "*",
158+
Bop::Matmult => "@",
159+
Bop::Mod => "%",
160+
Bop::Floordiv => "//",
161+
Bop::Div => "/",
162+
Bop::Power => "**",
163+
Bop::Lshift => "<<",
164+
Bop::Rshift => ">>",
165+
Bop::BitAnd => "&",
166+
Bop::BitXor => "^",
167+
Bop::BitOr => "|",
168+
Bop::Lt => "<",
169+
Bop::Gt => ">",
170+
Bop::Eq => "==",
171+
Bop::Leq => "<=",
172+
Bop::Geq => ">=",
173+
Bop::Neq => "!=",
174+
Bop::In => " in ",
175+
Bop::NotIn => " not in ",
176+
Bop::Is => " is ",
177+
Bop::IsNot => " is not ",
178+
Bop::And => " and ",
179+
Bop::Or => " or ",
180+
}
181+
)
174182
}
175183
}
176184

177185
/// One of the `if` or `for` clause(s) of a comprehension list/dict/set or
178186
/// generator expression.
179187
#[derive(Clone, Debug, PartialEq)]
180188
pub enum ComprehensionChunk {
181-
If { cond: Expression },
182-
For { async: bool, item: Vec<Expression>, iterator: Expression },
189+
If {
190+
cond: Expression,
191+
},
192+
For {
193+
async: bool,
194+
item: Vec<Expression>,
195+
iterator: Expression,
196+
},
183197
}
184198

185199
/// `**foo` or `foo:bar`, as in a dict comprehension.
@@ -259,7 +273,7 @@ pub enum Import {
259273
path: Vec<Name>,
260274
/// For `from x import y, z`, this `vec![(y, None), (vec![z], None)]`.
261275
/// For `from x import y as z`, this `vec![(y, Some(z))]`.
262-
names: Vec<(Name, Option<Name>)>
276+
names: Vec<(Name, Option<Name>)>,
263277
},
264278
/// For `from x import *`, this is `vec![]`.
265279
ImportStarFrom {
@@ -268,7 +282,9 @@ pub enum Import {
268282
},
269283
/// `import x.y as z, foo.bar` is
270284
/// `Import::Import(vec![(vec![x, y], Some(z)), (vec![foo, bar], None)])`.
271-
Import { names: Vec<(Vec<Name>, Option<Name>)> },
285+
Import {
286+
names: Vec<(Vec<Name>, Option<Name>)>,
287+
},
272288
}
273289

274290
/// `+=` and its friends.
@@ -291,21 +307,25 @@ pub enum AugAssignOp {
291307

292308
impl fmt::Display for AugAssignOp {
293309
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
294-
write!(f, "{}", match *self {
295-
AugAssignOp::Add => "+=",
296-
AugAssignOp::Sub => "-=",
297-
AugAssignOp::Mult => "*=",
298-
AugAssignOp::MatMult => "@=",
299-
AugAssignOp::Div => "/=",
300-
AugAssignOp::Mod => "%=",
301-
AugAssignOp::BitAnd => "&=",
302-
AugAssignOp::BitOr => "|=",
303-
AugAssignOp::BitXor => "^=",
304-
AugAssignOp::Lshift => "<<=",
305-
AugAssignOp::Rshift => ">>=",
306-
AugAssignOp::Power => "**=",
307-
AugAssignOp::Floordiv => "//=",
308-
})
310+
write!(
311+
f,
312+
"{}",
313+
match *self {
314+
AugAssignOp::Add => "+=",
315+
AugAssignOp::Sub => "-=",
316+
AugAssignOp::Mult => "*=",
317+
AugAssignOp::MatMult => "@=",
318+
AugAssignOp::Div => "/=",
319+
AugAssignOp::Mod => "%=",
320+
AugAssignOp::BitAnd => "&=",
321+
AugAssignOp::BitOr => "|=",
322+
AugAssignOp::BitXor => "^=",
323+
AugAssignOp::Lshift => "<<=",
324+
AugAssignOp::Rshift => ">>=",
325+
AugAssignOp::Power => "**=",
326+
AugAssignOp::Floordiv => "//=",
327+
}
328+
)
309329
}
310330
}
311331

@@ -375,7 +395,13 @@ pub struct Try {
375395
#[derive(Clone, Debug, PartialEq)]
376396
pub enum CompoundStatement {
377397
If(Vec<(Expression, Vec<Statement>)>, Option<Vec<Statement>>),
378-
For { async: bool, item: Vec<Expression>, iterator: Vec<Expression>, for_block: Vec<Statement>, else_block: Option<Vec<Statement>> },
398+
For {
399+
async: bool,
400+
item: Vec<Expression>,
401+
iterator: Vec<Expression>,
402+
for_block: Vec<Statement>,
403+
else_block: Option<Vec<Statement>>,
404+
},
379405
While(Expression, Vec<Statement>, Option<Vec<Statement>>),
380406
With(Vec<(Expression, Option<Expression>)>, Vec<Statement>),
381407
Funcdef(Funcdef),

src/bytes.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ named_args!(longbytes(quote: char) <StrSpan, Vec<u8>>,
5858
)
5959
);
6060

61-
6261
named_args!(shortrawbytes(quote: char) <StrSpan, Vec<u8>>,
6362
fold_many0!(
6463
alt!(
@@ -89,7 +88,6 @@ named_args!(longrawbytes(quote: char) <StrSpan, Vec<u8>>,
8988
)
9089
);
9190

92-
9391
named!(pub bytes<StrSpan, Vec<u8>>,
9492
do_parse!(
9593
prefix: alt!(tag!("br")|tag!("Br")|tag!("bR")|tag!("BR")|tag!("rb")|tag!("rB")|tag!("Rb")|tag!("RB")|tag!("b")|tag!("B")|tag!("")) >>

src/errors.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ impl From<PyParseError> for u32 {
1414
#[cfg(test)]
1515
mod tests {
1616
use nom;
17-
use nom::{Context, ErrorKind};
1817
use nom::types::CompleteStr;
18+
use nom::{Context, ErrorKind};
1919
use nom_locate::LocatedSpan;
2020

2121
use helpers::*;
2222
use statements::statement;
2323

24-
2524
#[test]
2625
fn if_no_condition() {
27-
assert_eq!(statement(make_strspan("if:\n foo"), 0), Err(
28-
nom::Err::Failure(
29-
Context::Code(
30-
LocatedSpan { offset: 2, line: 1, fragment: CompleteStr(":\n foo") },
31-
ErrorKind::Alt
32-
)
33-
)
34-
));
26+
assert_eq!(
27+
statement(make_strspan("if:\n foo"), 0),
28+
Err(nom::Err::Failure(Context::Code(
29+
LocatedSpan {
30+
offset: 2,
31+
line: 1,
32+
fragment: CompleteStr(":\n foo")
33+
},
34+
ErrorKind::Alt
35+
)))
36+
);
3537
}
3638
}

0 commit comments

Comments
 (0)