Skip to content

Commit decb75c

Browse files
Fix clippy warning
1 parent 9c064c1 commit decb75c

17 files changed

Lines changed: 31 additions & 73 deletions

File tree

crates/codegen/src/compile.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,15 +1752,13 @@ impl<'warnings> Compiler<'warnings> {
17521752

17531753
// Check if __class__ is available as a cell/free variable
17541754
// The scope must be Free (from enclosing class) or have DEF_FREE_CLASS flag
1755-
if let Some(symbol) = table.lookup("__class__") {
1755+
{
1756+
let symbol = table.lookup("__class__")?;
17561757
if symbol.scope != SymbolScope::Free
17571758
&& !symbol.flags.contains(SymbolFlags::DEF_FREE_CLASS)
17581759
{
17591760
return None;
17601761
}
1761-
} else {
1762-
// __class__ not in symbol table, optimization not possible
1763-
return None;
17641762
}
17651763

17661764
Some(SuperCallType::ZeroArg)
@@ -8263,7 +8261,6 @@ impl<'warnings> Compiler<'warnings> {
82638261
ast::Expr::Subscript(ast::ExprSubscript {
82648262
value,
82658263
slice,
8266-
ctx: _,
82678264
..
82688265
}) => {
82698266
let use_slice_opt = self.should_apply_two_element_slice_optimization(slice);
@@ -9227,8 +9224,6 @@ impl<'warnings> Compiler<'warnings> {
92279224
};
92289225
let [
92299226
ast::Expr::Generator(ast::ExprGenerator {
9230-
elt: _,
9231-
generators: _,
92329227
..
92339228
}),
92349229
] = &args.args[..]

crates/codegen/src/symboltable.rs

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,6 @@ impl SymbolTableBuilder {
16231623
decorator_list,
16241624
type_params,
16251625
range,
1626-
node_index: _,
16271626
..
16281627
}) => {
16291628
let prev_class = self.class_name.clone();
@@ -1819,7 +1818,6 @@ impl SymbolTableBuilder {
18191818
value,
18201819
simple,
18211820
range,
1822-
node_index: _,
18231821
..
18241822
}) => {
18251823
self.tables.last_mut().unwrap().annotations_used = true;
@@ -2144,21 +2142,19 @@ impl SymbolTableBuilder {
21442142
Expr::BinOp(ExprBinOp {
21452143
left,
21462144
right,
2147-
range: _,
21482145
..
21492146
}) => {
21502147
self.scan_expression(left, context)?;
21512148
self.scan_expression(right, context)?;
21522149
}
21532150
Expr::BoolOp(ExprBoolOp {
2154-
values, range: _, ..
2151+
values, ..
21552152
}) => {
21562153
self.scan_expressions(values, context)?;
21572154
}
21582155
Expr::Compare(ExprCompare {
21592156
left,
21602157
comparators,
2161-
range: _,
21622158
..
21632159
}) => {
21642160
self.scan_expression(left, context)?;
@@ -2167,7 +2163,6 @@ impl SymbolTableBuilder {
21672163
Expr::Subscript(ExprSubscript {
21682164
value,
21692165
slice,
2170-
range: _,
21712166
..
21722167
}) => {
21732168
self.scan_expression(value, ExpressionContext::Load)?;
@@ -2181,8 +2176,6 @@ impl SymbolTableBuilder {
21812176
}
21822177
Expr::Dict(ExprDict {
21832178
items,
2184-
node_index: _,
2185-
range: _,
21862179
..
21872180
}) => {
21882181
for item in items {
@@ -2196,8 +2189,6 @@ impl SymbolTableBuilder {
21962189
}
21972190
Expr::Await(ExprAwait {
21982191
value,
2199-
node_index: _,
2200-
range: _,
22012192
..
22022193
}) => {
22032194
let current_scope = self.tables.last().unwrap().typ;
@@ -2229,8 +2220,6 @@ impl SymbolTableBuilder {
22292220
}
22302221
Expr::Yield(ExprYield {
22312222
value,
2232-
node_index: _,
2233-
range: _,
22342223
..
22352224
}) => {
22362225
if let Some(expression) = value {
@@ -2254,8 +2243,6 @@ impl SymbolTableBuilder {
22542243
}
22552244
Expr::YieldFrom(ExprYieldFrom {
22562245
value,
2257-
node_index: _,
2258-
range: _,
22592246
..
22602247
}) => {
22612248
self.scan_expression(value, context)?;
@@ -2276,26 +2263,24 @@ impl SymbolTableBuilder {
22762263
}
22772264
}
22782265
Expr::UnaryOp(ExprUnaryOp {
2279-
operand, range: _, ..
2266+
operand, ..
22802267
}) => {
22812268
self.scan_expression(operand, context)?;
22822269
}
22832270
Expr::Starred(ExprStarred {
2284-
value, range: _, ..
2271+
value, ..
22852272
}) => {
22862273
self.scan_expression(value, context)?;
22872274
}
2288-
Expr::Tuple(ExprTuple { elts, range: _, .. })
2289-
| Expr::Set(ExprSet { elts, range: _, .. })
2290-
| Expr::List(ExprList { elts, range: _, .. }) => {
2275+
Expr::Tuple(ExprTuple { elts, .. })
2276+
| Expr::Set(ExprSet { elts, .. })
2277+
| Expr::List(ExprList { elts, .. }) => {
22912278
self.scan_expressions(elts, context)?;
22922279
}
22932280
Expr::Slice(ExprSlice {
22942281
lower,
22952282
upper,
22962283
step,
2297-
node_index: _,
2298-
range: _,
22992284
..
23002285
}) => {
23012286
if let Some(lower) = lower {
@@ -2326,7 +2311,6 @@ impl SymbolTableBuilder {
23262311
elt,
23272312
generators,
23282313
range,
2329-
node_index: _,
23302314
..
23312315
}) => {
23322316
let was_in_iter_def_exp = self.in_iter_def_exp;
@@ -2341,7 +2325,6 @@ impl SymbolTableBuilder {
23412325
elt,
23422326
generators,
23432327
range,
2344-
node_index: _,
23452328
..
23462329
}) => {
23472330
let was_in_iter_def_exp = self.in_iter_def_exp;
@@ -2357,7 +2340,6 @@ impl SymbolTableBuilder {
23572340
value,
23582341
generators,
23592342
range,
2360-
node_index: _,
23612343
..
23622344
}) => {
23632345
let was_in_iter_def_exp = self.in_iter_def_exp;
@@ -2379,8 +2361,6 @@ impl SymbolTableBuilder {
23792361
Expr::Call(ExprCall {
23802362
func,
23812363
arguments,
2382-
node_index: _,
2383-
range: _,
23842364
..
23852365
}) => {
23862366
match context {
@@ -2440,8 +2420,6 @@ impl SymbolTableBuilder {
24402420
Expr::Lambda(ExprLambda {
24412421
body,
24422422
parameters,
2443-
node_index: _,
2444-
range: _,
24452423
..
24462424
}) => {
24472425
let was_in_iter_def_exp = self.in_iter_def_exp;
@@ -2538,8 +2516,6 @@ impl SymbolTableBuilder {
25382516
test,
25392517
body,
25402518
orelse,
2541-
node_index: _,
2542-
range: _,
25432519
..
25442520
}) => {
25452521
self.scan_expression(test, ExpressionContext::Load)?;
@@ -2551,7 +2527,6 @@ impl SymbolTableBuilder {
25512527
target,
25522528
value,
25532529
range,
2554-
node_index: _,
25552530
..
25562531
}) => {
25572532
// named expressions are not allowed in the definition of
@@ -2777,7 +2752,6 @@ impl SymbolTableBuilder {
27772752
bound,
27782753
range: type_var_range,
27792754
default,
2780-
node_index: _,
27812755
..
27822756
}) => {
27832757
self.register_name(name.as_str(), SymbolUsage::TypeParam, *type_var_range)?;
@@ -2821,7 +2795,6 @@ impl SymbolTableBuilder {
28212795
name,
28222796
range: param_spec_range,
28232797
default,
2824-
node_index: _,
28252798
..
28262799
}) => {
28272800
self.register_name(name, SymbolUsage::TypeParam, *param_spec_range)?;
@@ -2850,7 +2823,6 @@ impl SymbolTableBuilder {
28502823
name,
28512824
range: type_var_tuple_range,
28522825
default,
2853-
node_index: _,
28542826
..
28552827
}) => {
28562828
self.register_name(name, SymbolUsage::TypeParam, *type_var_tuple_range)?;

crates/derive-impl/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl ItemNursery {
6363
if !inserted {
6464
return Err(syn::Error::new(
6565
item.attr_name.span(),
66-
format!("Duplicated #[py*] attribute found for {:?}", &item.py_names),
66+
format!("Duplicated #[py*] attribute found for {:?}", item.py_names),
6767
));
6868
}
6969
}

crates/vm/src/builtins/builtin_func.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl PyNativeFunction {
157157
// m_self is an instance: use Py_TYPE(m_self).__qualname__
158158
bound.class().name().to_string()
159159
};
160-
vm.ctx.new_str(format!("{}.{}", prefix, &zelf.value.name))
160+
vm.ctx.new_str(format!("{}.{}", prefix, zelf.value.name))
161161
} else {
162162
vm.ctx.intern_str(zelf.value.name).to_owned()
163163
};
@@ -220,7 +220,7 @@ impl fmt::Debug for PyNativeMethod {
220220
f,
221221
"builtin method of {:?} with {:?}",
222222
&*self.class.name(),
223-
&self.func
223+
self.func
224224
)
225225
}
226226
}

crates/vm/src/builtins/descriptor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl PyMethodDescriptor {
127127

128128
#[pygetset]
129129
fn __qualname__(&self) -> String {
130-
format!("{}.{}", self.common.typ.name(), &self.common.name)
130+
format!("{}.{}", self.common.typ.name(), self.common.name)
131131
}
132132

133133
#[pygetset]
@@ -164,7 +164,7 @@ impl Representable for PyMethodDescriptor {
164164
fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
165165
Ok(format!(
166166
"<method '{}' of '{}' objects>",
167-
&zelf.method.name,
167+
zelf.method.name,
168168
zelf.common.typ.name()
169169
))
170170
}

crates/vm/src/builtins/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl PyMemoryView {
198198
let data = self.format_spec.pack(vec![value], vm).map_err(|_| {
199199
vm.new_type_error(format!(
200200
"memoryview: invalid type for format '{}'",
201-
&self.desc.format
201+
self.desc.format
202202
))
203203
})?;
204204
bytes[pos..pos + self.desc.itemsize].copy_from_slice(&data);

crates/vm/src/builtins/super.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl Representable for PySuper {
237237
let obj = zelf.inner.read().obj.clone();
238238
let repr = match obj {
239239
Some((_, ref ty)) => {
240-
format!("<super: <class '{}'>, <{} object>>", &type_name, ty.name())
240+
format!("<super: <class '{}'>, <{} object>>", type_name, ty.name())
241241
}
242242
None => format!("<super: <class '{type_name}'>, NULL>"),
243243
};

crates/vm/src/builtins/type.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl core::fmt::Display for PyType {
431431

432432
impl core::fmt::Debug for PyType {
433433
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
434-
write!(f, "[PyType {}]", &self.name())
434+
write!(f, "[PyType {}]", self.name())
435435
}
436436
}
437437

@@ -1906,13 +1906,7 @@ impl PyType {
19061906
.get(identifier!(vm, __module__))
19071907
.cloned()
19081908
// We need to exclude this method from going into recursion:
1909-
.and_then(|found| {
1910-
if found.fast_isinstance(vm.ctx.types.getset_type) {
1911-
None
1912-
} else {
1913-
Some(found)
1914-
}
1915-
})
1909+
.filter(|found| !found.fast_isinstance(vm.ctx.types.getset_type))
19161910
.unwrap_or_else(|| {
19171911
// For non-heap types, extract module from tp_name (e.g. "typing.TypeAliasType" -> "typing")
19181912
let slot_name = self.slot_name();

crates/vm/src/frame.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,16 +3801,14 @@ impl ExecutingFrame<'_> {
38013801
}
38023802
seen_keys.add(key.as_object().to_owned(), vm)?;
38033803
// value = map.get(key, dummy)
3804-
match get_method.call((key.as_object(), dummy.clone()), vm) {
3805-
Ok(value) => {
3806-
// if value == dummy: key not in map!
3807-
if value.is(&dummy) {
3808-
all_match = false;
3809-
break;
3810-
}
3811-
values.push(value);
3804+
{
3805+
let value = get_method.call((key.as_object(), dummy.clone()), vm)?;
3806+
// if value == dummy: key not in map!
3807+
if value.is(&dummy) {
3808+
all_match = false;
3809+
break;
38123810
}
3813-
Err(e) => return Err(e),
3811+
values.push(value);
38143812
}
38153813
}
38163814
} else {

crates/vm/src/object/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<T> PyInner<T> {
454454

455455
impl<T: fmt::Debug> fmt::Debug for PyInner<T> {
456456
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
457-
write!(f, "[PyObject {:?}]", &self.payload)
457+
write!(f, "[PyObject {:?}]", self.payload)
458458
}
459459
}
460460

0 commit comments

Comments
 (0)