GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Clippy nursery lints (#7875) · RustPython/RustPython@ddfcb25

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Cargo.toml
  • crates
    • capi/src
      • util.rs
    • codegen/src
      • compile.rs
      • ir.rs
      • symboltable.rs
    • common/src
      • cformat.rs
      • format.rs
    • compiler-core/src
      • bytecode.rs
      • bytecode
        • instruction.rs
        • oparg.rs
    • compiler/src
      • lib.rs
    • derive-impl/src
      • pymodule.rs
    • host_env/src
      • windows.rs
    • jit
      • src
        • instructions.rs
        • lib.rs
      • tests
        • common.rs
    • stdlib/src
      • _asyncio.rs
      • _sqlite3.rs
      • grp.rs
      • hashlib.rs
      • lzma.rs
      • mmap.rs
      • multiprocessing.rs
      • overlapped.rs
      • posixsubprocess.rs
      • ssl.rs
      • ssl
        • compat.rs
      • statistics.rs
    • vm/src
      • builtins
        • bytes.rs
        • code.rs
        • complex.rs
        • descriptor.rs
        • frame.rs
        • interpolation.rs
        • set.rs
        • str.rs
        • template.rs
        • tuple.rs
        • type.rs
        • union.rs
      • datastack.rs
      • exception_group.rs
      • exceptions.rs
      • frame.rs
      • function
        • method.rs
      • object
        • core.rs
        • ext.rs
      • protocol
        • number.rs
      • stdlib
        • _abc.rs
        • _ast
          • constant.rs
          • pattern.rs
          • statement.rs
        • _ctypes
          • array.rs
          • base.rs
          • function.rs
          • library.rs
          • pointer.rs
          • simple.rs
          • structure.rs
          • union.rs
        • _functools.rs
        • _io.rs
        • _signal.rs
        • _thread.rs
        • _winapi.rs
        • _wmi.rs
        • os.rs
        • posix.rs
        • pwd.rs
        • typevar.rs
        • winreg.rs
      • types
        • slot.rs
      • vm
        • context.rs
        • mod.rs
        • thread.rs
        • vm_object.rs
        • vm_ops.rs
      • windows.rs
    • wasm/src
      • browser_module.rs
      • js_module.rs
      • vm_class.rs

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Cargo.toml‎

Copy file name to clipboardExpand all lines: Cargo.toml
+17-6Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,24 @@ if_not_else = "allow" # Not always more readable
335335
single_match_else = "allow"
336336
similar_names = "allow"
337337

338+
# restriction lints
338339
alloc_instead_of_core = "warn"
339340
std_instead_of_alloc = "warn"
340341
std_instead_of_core = "warn"
341-
format_collect = "warn"
342-
from_iter_instead_of_collect = "warn"
343-
inefficient_to_string = "warn"
344-
redundant_clone = "warn"
342+
343+
# nursery lints to enforce gradually
345344
debug_assert_with_mut_call = "warn"
346-
unused_peekable = "warn"
345+
derive_partial_eq_without_eq = "warn"
346+
imprecise_flops = "warn"
347347
or_fun_call = "warn"
348-
unnested_or_patterns = "warn"
348+
redundant_clone = "warn"
349+
search_is_some = "warn"
350+
single_option_map = "warn"
351+
trait_duplication_in_bounds = "warn"
352+
unused_peekable = "warn"
353+
unused_rounding = "warn"
354+
use_self = "warn"
355+
useless_let_if_seq = "warn"
349356

350357
# pedantic lints to enforce gradually
351358
cloned_instead_of_copied = "warn"
@@ -355,10 +362,14 @@ explicit_into_iter_loop = "warn"
355362
explicit_iter_loop = "warn"
356363
filter_map_next = "warn"
357364
flat_map_option = "warn"
365+
format_collect = "warn"
366+
from_iter_instead_of_collect = "warn"
358367
inconsistent_struct_constructor = "warn"
368+
inefficient_to_string = "warn"
359369
manual_is_variant_and = "warn"
360370
map_unwrap_or = "warn"
361371
must_use_candidate = "warn"
362372
redundant_else = "warn"
363373
uninlined_format_args = "warn"
364374
unnecessary_wraps = "warn"
375+
unnested_or_patterns = "warn"
Collapse file

‎crates/capi/src/util.rs‎

Copy file name to clipboardExpand all lines: crates/capi/src/util.rs
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ impl FfiResult<isize> for usize {
8686
}
8787

8888
impl FfiResult for c_long {
89-
const ERR_VALUE: c_long = -1;
89+
const ERR_VALUE: Self = -1;
9090

91-
fn into_output(self, _vm: &VirtualMachine) -> c_long {
91+
fn into_output(self, _vm: &VirtualMachine) -> Self {
9292
self
9393
}
9494
}
9595

9696
impl FfiResult for c_double {
97-
const ERR_VALUE: c_double = -1.0;
97+
const ERR_VALUE: Self = -1.0;
9898

99-
fn into_output(self, _vm: &VirtualMachine) -> c_double {
99+
fn into_output(self, _vm: &VirtualMachine) -> Self {
100100
self
101101
}
102102
}
Collapse file

‎crates/codegen/src/compile.rs‎

Copy file name to clipboardExpand all lines: crates/codegen/src/compile.rs
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ impl ExprExt for ast::Expr {
5151
fn is_constant(&self) -> bool {
5252
matches!(
5353
self,
54-
ast::Expr::NumberLiteral(_)
55-
| ast::Expr::StringLiteral(_)
56-
| ast::Expr::BytesLiteral(_)
57-
| ast::Expr::NoneLiteral(_)
58-
| ast::Expr::BooleanLiteral(_)
59-
| ast::Expr::EllipsisLiteral(_)
54+
Self::NumberLiteral(_)
55+
| Self::StringLiteral(_)
56+
| Self::BytesLiteral(_)
57+
| Self::NoneLiteral(_)
58+
| Self::BooleanLiteral(_)
59+
| Self::EllipsisLiteral(_)
6060
)
6161
}
6262

6363
fn is_constant_slice(&self) -> bool {
6464
match self {
65-
ast::Expr::Slice(s) => {
65+
Self::Slice(s) => {
6666
let lower_const =
6767
s.lower.is_none() || s.lower.as_deref().is_some_and(|e| e.is_constant());
6868
let upper_const =
@@ -76,7 +76,7 @@ impl ExprExt for ast::Expr {
7676
}
7777

7878
fn should_use_slice_optimization(&self) -> bool {
79-
!self.is_constant_slice() && matches!(self, ast::Expr::Slice(s) if s.step.is_none())
79+
!self.is_constant_slice() && matches!(self, Self::Slice(s) if s.step.is_none())
8080
}
8181
}
8282

Collapse file

‎crates/codegen/src/ir.rs‎

Copy file name to clipboardExpand all lines: crates/codegen/src/ir.rs
+18-4Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,20 +1231,23 @@ impl CodeInfo {
12311231
op: oparg::BinaryOperator,
12321232
) -> Option<ConstantData> {
12331233
use oparg::BinaryOperator as BinOp;
1234+
12341235
fn repeat_wtf8(value: &Wtf8Buf, n: usize) -> Wtf8Buf {
12351236
let mut result = Wtf8Buf::with_capacity(value.len().saturating_mul(n));
12361237
for _ in 0..n {
12371238
result.push_wtf8(value);
12381239
}
12391240
result
12401241
}
1242+
12411243
fn checked_repeat_count(n: &BigInt, item_size: usize) -> Option<usize> {
12421244
let n = n.to_isize()?;
12431245
if item_size != 0 && (n < 0 || n as usize > MAX_STR_SIZE / item_size) {
12441246
return None;
12451247
}
12461248
Some(n.max(0) as usize)
12471249
}
1250+
12481251
fn eval_complex_binop(
12491252
left: Complex<f64>,
12501253
right: Complex<f64>,
@@ -1259,17 +1262,18 @@ impl CodeInfo {
12591262
BinOp::Add => left + right,
12601263
BinOp::Subtract => {
12611264
let re = left.re - right.re;
1262-
let mut im = left.im - right.im;
12631265
// Preserve CPython's signed-zero behavior for real-zero
12641266
// minus zero-complex expressions such as `0 - 0j`.
1265-
if left.re == 0.0
1267+
let im = if left.re == 0.0
12661268
&& left.im == 0.0
12671269
&& right.re == 0.0
12681270
&& right.im == 0.0
12691271
&& !right.im.is_sign_negative()
12701272
{
1271-
im = -0.0;
1272-
}
1273+
-0.0
1274+
} else {
1275+
left.im - right.im
1276+
};
12731277
Complex::new(re, im)
12741278
}
12751279
BinOp::Multiply => left * right,
@@ -1284,12 +1288,14 @@ impl CodeInfo {
12841288
if right.im != 0.0 || right.re < 0.0 {
12851289
return None;
12861290
}
1291+
12871292
return complex_const(if right.re == 0.0 {
12881293
Complex::new(1.0, 0.0)
12891294
} else {
12901295
Complex::new(0.0, 0.0)
12911296
});
12921297
}
1298+
12931299
if right.im == 0.0
12941300
&& right.re.fract() == 0.0
12951301
&& right.re >= f64::from(i32::MIN)
@@ -1304,6 +1310,7 @@ impl CodeInfo {
13041310
};
13051311
complex_const(value)
13061312
}
1313+
13071314
fn float_div_mod(left: f64, right: f64) -> Option<(f64, f64)> {
13081315
if right == 0.0 {
13091316
return None;
@@ -1330,6 +1337,7 @@ impl CodeInfo {
13301337

13311338
Some((floordiv, modulo))
13321339
}
1340+
13331341
fn constant_as_index(value: &ConstantData) -> Option<i64> {
13341342
match value {
13351343
ConstantData::Integer { value } => value.to_i64().or_else(|| {
@@ -1343,12 +1351,14 @@ impl CodeInfo {
13431351
_ => None,
13441352
}
13451353
}
1354+
13461355
fn slice_bound(value: &ConstantData) -> Option<Option<i64>> {
13471356
match value {
13481357
ConstantData::None => Some(None),
13491358
_ => constant_as_index(value).map(Some),
13501359
}
13511360
}
1361+
13521362
fn adjusted_slice_indices(len: usize, slice: &[ConstantData; 3]) -> Option<Vec<usize>> {
13531363
let len = i64::try_from(len).ok()?;
13541364
let start = slice_bound(&slice[0])?;
@@ -1393,6 +1403,7 @@ impl CodeInfo {
13931403
}
13941404
Some(indices)
13951405
}
1406+
13961407
fn adjusted_const_index(len: usize, index: &ConstantData) -> Option<usize> {
13971408
let len = i64::try_from(len).ok()?;
13981409
let index = constant_as_index(index)?;
@@ -1406,6 +1417,7 @@ impl CodeInfo {
14061417
}
14071418
usize::try_from(index).ok()
14081419
}
1420+
14091421
fn eval_const_subscript(
14101422
container: &ConstantData,
14111423
index: &ConstantData,
@@ -1472,9 +1484,11 @@ impl CodeInfo {
14721484
_ => None,
14731485
}
14741486
}
1487+
14751488
if matches!(op, BinOp::Subscr) {
14761489
return eval_const_subscript(left, right);
14771490
}
1491+
14781492
match (left, right) {
14791493
(ConstantData::Integer { value: l }, ConstantData::Integer { value: r }) => {
14801494
let result = match op {
Collapse file

‎crates/codegen/src/symboltable.rs‎

Copy file name to clipboardExpand all lines: crates/codegen/src/symboltable.rs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct SymbolTable {
3737

3838
/// A list of sub-scopes in the order as found in the
3939
/// AST nodes.
40-
pub sub_tables: Vec<SymbolTable>,
40+
pub sub_tables: Vec<Self>,
4141

4242
/// Cursor pointing to the next sub-table to consume during compilation.
4343
pub next_sub_table: usize,
@@ -63,7 +63,7 @@ pub struct SymbolTable {
6363

6464
/// PEP 649: Reference to annotation scope for this block
6565
/// Annotations are compiled as a separate `__annotate__` function
66-
pub annotation_block: Option<Box<SymbolTable>>,
66+
pub annotation_block: Option<Box<Self>>,
6767

6868
/// True only for deferred function/class/module annotation scopes that
6969
/// should resolve outer names as if they were siblings of the owning
@@ -177,7 +177,7 @@ pub enum SymbolScope {
177177
}
178178

179179
bitflags! {
180-
#[derive(Copy, Clone, Debug, PartialEq)]
180+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
181181
pub struct SymbolFlags: u16 {
182182
const REFERENCED = 0x001; // USE
183183
const ASSIGNED = 0x002; // DEF_LOCAL
Collapse file

‎crates/common/src/cformat.rs‎

Copy file name to clipboardExpand all lines: crates/common/src/cformat.rs
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustpython_literal::{float, format::Case};
1414

1515
use crate::wtf8::{CodePoint, Wtf8, Wtf8Buf};
1616

17-
#[derive(Clone, Copy, Debug, PartialEq)]
17+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1818
pub enum CFormatErrorType {
1919
UnmatchedKeyParentheses,
2020
MissingModuloSign,
@@ -27,7 +27,7 @@ pub enum CFormatErrorType {
2727
// also contains how many chars the parsing function consumed
2828
pub type ParsingError = (CFormatErrorType, usize);
2929

30-
#[derive(Clone, Copy, Debug, PartialEq)]
30+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3131
pub struct CFormatError {
3232
pub typ: CFormatErrorType, // FIXME
3333
pub index: usize,
@@ -54,7 +54,7 @@ impl fmt::Display for CFormatError {
5454

5555
pub type CFormatConversion = super::format::FormatConversion;
5656

57-
#[derive(Debug, PartialEq, Clone, Copy)]
57+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
5858
#[repr(u8)]
5959
pub enum CNumberType {
6060
DecimalD = b'd',
@@ -65,7 +65,7 @@ pub enum CNumberType {
6565
HexUpper = b'X',
6666
}
6767

68-
#[derive(Debug, PartialEq, Clone, Copy)]
68+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
6969
#[repr(u8)]
7070
pub enum CFloatType {
7171
ExponentLower = b'e',
@@ -87,13 +87,13 @@ impl CFloatType {
8787
}
8888
}
8989

90-
#[derive(Debug, PartialEq, Clone, Copy)]
90+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
9191
#[repr(u8)]
9292
pub enum CCharacterType {
9393
Character = b'c',
9494
}
9595

96-
#[derive(Debug, PartialEq, Clone, Copy)]
96+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
9797
pub enum CFormatType {
9898
Number(CNumberType),
9999
Float(CFloatType),
@@ -113,7 +113,7 @@ impl CFormatType {
113113
}
114114
}
115115

116-
#[derive(Debug, PartialEq, Clone, Copy)]
116+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
117117
pub enum CFormatPrecision {
118118
Quantity(CFormatQuantity),
119119
Dot,
@@ -126,7 +126,7 @@ impl From<CFormatQuantity> for CFormatPrecision {
126126
}
127127

128128
bitflags! {
129-
#[derive(Copy, Clone, Debug, PartialEq)]
129+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
130130
pub struct CConversionFlags: u32 {
131131
const ALTERNATE_FORM = 0b0000_0001;
132132
const ZERO_PAD = 0b0000_0010;
@@ -150,7 +150,7 @@ impl CConversionFlags {
150150
}
151151
}
152152

153-
#[derive(Debug, PartialEq, Clone, Copy)]
153+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
154154
pub enum CFormatQuantity {
155155
Amount(usize),
156156
FromValuesTuple,
@@ -254,7 +254,7 @@ impl FormatChar for u8 {
254254
}
255255
}
256256

257-
#[derive(Debug, PartialEq, Clone, Copy)]
257+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
258258
pub struct CFormatSpec {
259259
pub flags: CConversionFlags,
260260
pub min_field_width: Option<CFormatQuantity>,
@@ -263,7 +263,7 @@ pub struct CFormatSpec {
263263
// chars_consumed: usize,
264264
}
265265

266-
#[derive(Debug, PartialEq)]
266+
#[derive(Debug, Eq, PartialEq)]
267267
pub struct CFormatSpecKeyed<T> {
268268
pub mapping_key: Option<T>,
269269
pub spec: CFormatSpec,
@@ -718,7 +718,7 @@ where
718718
Some(contained_text)
719719
}
720720

721-
#[derive(Debug, PartialEq)]
721+
#[derive(Debug, Eq, PartialEq)]
722722
pub enum CFormatPart<T> {
723723
Literal(T),
724724
Spec(CFormatSpecKeyed<T>),
@@ -739,7 +739,7 @@ impl<T> CFormatPart<T> {
739739
}
740740
}
741741

742-
#[derive(Debug, PartialEq)]
742+
#[derive(Debug, Eq, PartialEq)]
743743
pub struct CFormatStrOrBytes<S> {
744744
parts: Vec<(usize, CFormatPart<S>)>,
745745
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.