Skip to content

Commit e2b28d0

Browse files
authored
Merge pull request #4310 from youknowone/fix-clippy
Fix nightly clippy warnings
2 parents 6f6b7b2 + 2878578 commit e2b28d0

5 files changed

Lines changed: 32 additions & 33 deletions

File tree

‎core/src/bytecode.rs‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,15 @@ impl<C: Constant> BorrowedConstant<'_, C> {
482482
// takes `self` because we need to consume the iterator
483483
pub fn fmt_display(self, f: &mut fmt::Formatter) -> fmt::Result {
484484
match self {
485-
BorrowedConstant::Integer { value } => write!(f, "{}", value),
486-
BorrowedConstant::Float { value } => write!(f, "{}", value),
487-
BorrowedConstant::Complex { value } => write!(f, "{}", value),
485+
BorrowedConstant::Integer { value } => write!(f, "{value}"),
486+
BorrowedConstant::Float { value } => write!(f, "{value}"),
487+
BorrowedConstant::Complex { value } => write!(f, "{value}"),
488488
BorrowedConstant::Boolean { value } => {
489489
write!(f, "{}", if value { "True" } else { "False" })
490490
}
491-
BorrowedConstant::Str { value } => write!(f, "{:?}", value),
491+
BorrowedConstant::Str { value } => write!(f, "{value:?}"),
492492
BorrowedConstant::Bytes { value } => write!(f, "b{:?}", value.as_bstr()),
493-
BorrowedConstant::Code { code } => write!(f, "{:?}", code),
493+
BorrowedConstant::Code { code } => write!(f, "{code:?}"),
494494
BorrowedConstant::Tuple { elements } => {
495495
write!(f, "(")?;
496496
let mut first = true;
@@ -852,7 +852,7 @@ impl<C: Constant> fmt::Display for CodeObject<C> {
852852
self.display_inner(f, false, 1)?;
853853
for constant in &*self.constants {
854854
if let BorrowedConstant::Code { code } = constant.borrow_constant() {
855-
writeln!(f, "\nDisassembly of {:?}", code)?;
855+
writeln!(f, "\nDisassembly of {code:?}")?;
856856
code.fmt(f)?;
857857
}
858858
}
@@ -1118,14 +1118,14 @@ impl Instruction {
11181118
}
11191119
}
11201120
}
1121-
UnaryOperation { op } => w!(UnaryOperation, format_args!("{:?}", op)),
1122-
BinaryOperation { op } => w!(BinaryOperation, format_args!("{:?}", op)),
1121+
UnaryOperation { op } => w!(UnaryOperation, format_args!("{op:?}")),
1122+
BinaryOperation { op } => w!(BinaryOperation, format_args!("{op:?}")),
11231123
BinaryOperationInplace { op } => {
1124-
w!(BinaryOperationInplace, format_args!("{:?}", op))
1124+
w!(BinaryOperationInplace, format_args!("{op:?}"))
11251125
}
11261126
LoadAttr { idx } => w!(LoadAttr, name(*idx)),
1127-
TestOperation { op } => w!(TestOperation, format_args!("{:?}", op)),
1128-
CompareOperation { op } => w!(CompareOperation, format_args!("{:?}", op)),
1127+
TestOperation { op } => w!(TestOperation, format_args!("{op:?}")),
1128+
CompareOperation { op } => w!(CompareOperation, format_args!("{op:?}")),
11291129
Pop => w!(Pop),
11301130
Rotate2 => w!(Rotate2),
11311131
Rotate3 => w!(Rotate3),
@@ -1139,7 +1139,7 @@ impl Instruction {
11391139
JumpIfFalse { target } => w!(JumpIfFalse, target),
11401140
JumpIfTrueOrPop { target } => w!(JumpIfTrueOrPop, target),
11411141
JumpIfFalseOrPop { target } => w!(JumpIfFalseOrPop, target),
1142-
MakeFunction(flags) => w!(MakeFunction, format_args!("{:?}", flags)),
1142+
MakeFunction(flags) => w!(MakeFunction, format_args!("{flags:?}")),
11431143
CallFunctionPositional { nargs } => w!(CallFunctionPositional, nargs),
11441144
CallFunctionKeyword { nargs } => w!(CallFunctionKeyword, nargs),
11451145
CallFunctionEx { has_kwargs } => w!(CallFunctionEx, has_kwargs),
@@ -1163,7 +1163,7 @@ impl Instruction {
11631163
BeforeAsyncWith => w!(BeforeAsyncWith),
11641164
SetupAsyncWith { end } => w!(SetupAsyncWith, end),
11651165
PopBlock => w!(PopBlock),
1166-
Raise { kind } => w!(Raise, format_args!("{:?}", kind)),
1166+
Raise { kind } => w!(Raise, format_args!("{kind:?}")),
11671167
BuildString { size } => w!(BuildString, size),
11681168
BuildTuple { size, unpack } => w!(BuildTuple, size, unpack),
11691169
BuildList { size, unpack } => w!(BuildList, size, unpack),
@@ -1182,7 +1182,7 @@ impl Instruction {
11821182
LoadBuildClass => w!(LoadBuildClass),
11831183
UnpackSequence { size } => w!(UnpackSequence, size),
11841184
UnpackEx { before, after } => w!(UnpackEx, before, after),
1185-
FormatValue { conversion } => w!(FormatValue, format_args!("{:?}", conversion)),
1185+
FormatValue { conversion } => w!(FormatValue, format_args!("{conversion:?}")),
11861186
PopException => w!(PopException),
11871187
Reverse { amount } => w!(Reverse, amount),
11881188
GetAwaitable => w!(GetAwaitable),

‎parser/src/error.rs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl fmt::Display for LexicalErrorType {
3434
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3535
match self {
3636
LexicalErrorType::StringError => write!(f, "Got unexpected string"),
37-
LexicalErrorType::FStringError(error) => write!(f, "Got error in f-string: {}", error),
37+
LexicalErrorType::FStringError(error) => write!(f, "Got error in f-string: {error}"),
3838
LexicalErrorType::UnicodeError => write!(f, "Got unexpected unicode"),
3939
LexicalErrorType::NestingError => write!(f, "Got unexpected nesting"),
4040
LexicalErrorType::IndentationError => {
@@ -56,13 +56,13 @@ impl fmt::Display for LexicalErrorType {
5656
write!(f, "positional argument follows keyword argument")
5757
}
5858
LexicalErrorType::UnrecognizedToken { tok } => {
59-
write!(f, "Got unexpected token {}", tok)
59+
write!(f, "Got unexpected token {tok}")
6060
}
6161
LexicalErrorType::LineContinuationError => {
6262
write!(f, "unexpected character after line continuation character")
6363
}
6464
LexicalErrorType::Eof => write!(f, "unexpected EOF while parsing"),
65-
LexicalErrorType::OtherError(msg) => write!(f, "{}", msg),
65+
LexicalErrorType::OtherError(msg) => write!(f, "{msg}"),
6666
}
6767
}
6868
}
@@ -97,17 +97,16 @@ impl fmt::Display for FStringErrorType {
9797
FStringErrorType::UnopenedRbrace => write!(f, "Unopened '}}'"),
9898
FStringErrorType::ExpectedRbrace => write!(f, "Expected '}}' after conversion flag."),
9999
FStringErrorType::InvalidExpression(error) => {
100-
write!(f, "{}", error)
100+
write!(f, "{error}")
101101
}
102102
FStringErrorType::InvalidConversionFlag => write!(f, "invalid conversion character"),
103103
FStringErrorType::EmptyExpression => write!(f, "empty expression not allowed"),
104104
FStringErrorType::MismatchedDelimiter(first, second) => write!(
105105
f,
106-
"closing parenthesis '{}' does not match opening parenthesis '{}'",
107-
second, first
106+
"closing parenthesis '{second}' does not match opening parenthesis '{first}'"
108107
),
109108
FStringErrorType::SingleRbrace => write!(f, "single '}}' is not allowed"),
110-
FStringErrorType::Unmatched(delim) => write!(f, "unmatched '{}'", delim),
109+
FStringErrorType::Unmatched(delim) => write!(f, "unmatched '{delim}'"),
111110
FStringErrorType::ExpressionNestedTooDeeply => {
112111
write!(f, "expressions nested too deeply")
113112
}
@@ -118,7 +117,7 @@ impl fmt::Display for FStringErrorType {
118117
if *c == '\\' {
119118
write!(f, "f-string expression part cannot include a backslash")
120119
} else {
121-
write!(f, "f-string expression part cannot include '{}'s", c)
120+
write!(f, "f-string expression part cannot include '{c}'s")
122121
}
123122
}
124123
}
@@ -198,18 +197,18 @@ impl fmt::Display for ParseErrorType {
198197
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
199198
match *self {
200199
ParseErrorType::Eof => write!(f, "Got unexpected EOF"),
201-
ParseErrorType::ExtraToken(ref tok) => write!(f, "Got extraneous token: {:?}", tok),
200+
ParseErrorType::ExtraToken(ref tok) => write!(f, "Got extraneous token: {tok:?}"),
202201
ParseErrorType::InvalidToken => write!(f, "Got invalid token"),
203202
ParseErrorType::UnrecognizedToken(ref tok, ref expected) => {
204203
if *tok == Tok::Indent {
205204
write!(f, "unexpected indent")
206205
} else if expected.as_deref() == Some("Indent") {
207206
write!(f, "expected an indented block")
208207
} else {
209-
write!(f, "invalid syntax. Got unexpected token {}", tok)
208+
write!(f, "invalid syntax. Got unexpected token {tok}")
210209
}
211210
}
212-
ParseErrorType::Lexical(ref error) => write!(f, "{}", error),
211+
ParseErrorType::Lexical(ref error) => write!(f, "{error}"),
213212
}
214213
}
215214
}

‎parser/src/fstring.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl FStringParser {
344344
}
345345

346346
fn parse_fstring_expr(source: &str) -> Result<Expr, ParseError> {
347-
let fstring_body = format!("({})", source);
347+
let fstring_body = format!("({source})");
348348
parse_expression(&fstring_body, "<fstring>")
349349
}
350350

‎parser/src/lexer.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ where
321321
let value_text = self.radix_run(radix);
322322
let end_pos = self.get_pos();
323323
let value = BigInt::from_str_radix(&value_text, radix).map_err(|e| LexicalError {
324-
error: LexicalErrorType::OtherError(format!("{:?}", e)),
324+
error: LexicalErrorType::OtherError(format!("{e:?}")),
325325
location: start_pos,
326326
})?;
327327
Ok((start_pos, Tok::Int { value }, end_pos))

‎parser/src/token.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ impl fmt::Display for Tok {
118118
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
119119
use Tok::*;
120120
match self {
121-
Name { name } => write!(f, "'{}'", name),
122-
Int { value } => write!(f, "'{}'", value),
123-
Float { value } => write!(f, "'{}'", value),
124-
Complex { real, imag } => write!(f, "{}j{}", real, imag),
121+
Name { name } => write!(f, "'{name}'"),
122+
Int { value } => write!(f, "'{value}'"),
123+
Float { value } => write!(f, "'{value}'"),
124+
Complex { real, imag } => write!(f, "{real}j{imag}"),
125125
String { value, kind } => {
126126
match kind {
127127
StringKind::F => f.write_str("f")?,
128128
StringKind::U => f.write_str("u")?,
129129
StringKind::Normal => {}
130130
}
131-
write!(f, "{:?}", value)
131+
write!(f, "{value:?}")
132132
}
133133
Bytes { value } => {
134134
write!(f, "b\"")?;
@@ -138,7 +138,7 @@ impl fmt::Display for Tok {
138138
10 => f.write_str("\\n")?,
139139
13 => f.write_str("\\r")?,
140140
32..=126 => f.write_char(*i as char)?,
141-
_ => write!(f, "\\x{:02x}", i)?,
141+
_ => write!(f, "\\x{i:02x}")?,
142142
}
143143
}
144144
f.write_str("\"")

0 commit comments

Comments
 (0)