8000 Fix nightly clippy · RustPython/RustPython@f0f4633 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0f4633

Browse files
committed
Fix nightly clippy
1 parent 6c37e8f commit f0f4633

File tree

9 files changed

+21
-17
lines changed

9 files changed

+21
-17
lines changed

common/src/refcount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl RefCount {
6666

6767
pub fn leak(&self) {
6868
debug_assert!(!self.is_leaked());
69-
const BIT_MARKER: usize = (std::isize::MAX as usize) + 1;
69+
const BIT_MARKER: usize = (isize::MAX as usize) + 1;
7070
debug_assert_eq!(BIT_MARKER.count_ones(), 1);
7171
debug_assert_eq!(BIT_MARKER.leading_zeros(), 0);
7272
self.strong.fetch_add(BIT_MARKER, Relaxed);

src/settings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ fn settings_from(matches: &ArgMatches) -> (Settings, RunMode) {
248248
settings.safe_path = true;
249249
}
250250

251-
settings.check_hash_based_pycs = matches
251+
matches
252252
.value_of("check-hash-based-pycs")
253253
.unwrap_or("default")
254-
.to_owned();
254+
.clone_into(&mut settings.check_hash_based_pycs);
255255

256256
let mut dev_mode = false;
257257
let mut warn_default_encoding = false;

stdlib/src/cmath.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ mod cmath {
1212
// Constants
1313
#[pyattr]
1414
use std::f64::consts::{E as e, PI as pi, TAU as tau};
15-
#[pyattr]
16-
use std::f64::{INFINITY as inf, NAN as nan};
15+
#[pyattr(name = "inf")]
16+
const INF: f64 = f64::INFINITY;
17+
#[pyattr(name = "nan")]
18+
const NAN: f64 = f64::NAN;
1719
#[pyattr(name = "infj")]
18-
const INFJ: Complex64 = Complex64::new(0., std::f64::INFINITY);
20+
const INFJ: Complex64 = Complex64::new(0., f64::INFINITY);
1921
#[pyattr(name = "nanj")]
20-
const NANJ: Complex64 = Complex64::new(0., std::f64::NAN);
22+
const NANJ: Complex64 = Complex64::new(0., f64::NAN);
2123

2224
#[pyfunction]
2325
fn phase(z: ArgIntoComplex) -> f64 {

stdlib/src/math.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ mod math {
1616
// Constants
1717
#[pyattr]
1818
use std::f64::consts::{E as e, PI as pi, TAU as tau};
19-
#[pyattr]
20-
use std::f64::{INFINITY as inf, NAN as nan};
19+
#[pyattr(name = "inf")]
20+
const INF: f64 = f64::INFINITY;
21+
#[pyattr(name = "nan")]
22+
const NAN: f64 = f64::NAN;
2123

2224
// Helper macro:
2325
macro_rules! call_math_func {

vm/src/builtins/descriptor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl PyMemberDescriptor {
250250
Ok(if qualname.is_none() {
251251
drop(qualname);
252252
let calculated = calculate_qualname(&self.common, vm)?;
253-
*self.common.qualname.write() = calculated.to_owned();
253+
calculated.clone_into(&mut self.common.qualname.write());
254254
calculated
255255
} else {
256256
qualname.to_owned()

vm/src/convert/try_from.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl PyObjectRef {
3131
}
3232

3333
impl PyObject {
34-
pub fn try_to_value<'a, T: 'a>(&'a self, vm: &VirtualMachine) -> PyResult<T>
34+
pub fn try_to_value<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<T>
3535
where
36-
T: TryFromBorrowedObject<'a>,
36+
T: 'a + TryFromBorrowedObject<'a>,
3737
{
3838
T::try_from_borrowed_object(vm, self)
3939
}
4040

41-
pub fn try_to_ref<'a, T: 'a>(&'a self, vm: &VirtualMachine) -> PyResult<&'a Py<T>>
41+
pub fn try_to_ref<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<&'a Py<T>>
4242
where
43-
T: PyPayload,
43+
T: 'a + PyPayload,
4444
{
4545
self.try_to_value::<&Py<T>>(vm)
4646
}

vm/src/stdlib/itertools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ mod decl {
15851585
for i in idx as usize..r {
15861586
let index = indices[i];
15871587
let elem = &zelf.pool[index];
1588-
result[i] = elem.to_owned();
1588+
elem.clone_into(&mut result[i]);
15891589
}
15901590

15911591
result.to_vec()

vm/src/vm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ impl VirtualMachine {
653653
// TODO: fix extend to do this check (?), see test_extend in Lib/test/list_tests.py,
654654
// https://github.com/python/cpython/blob/v3.9.0/Objects/listobject.c#L922-L928
655655
if let Some(cap) = cap {
656-
if cap >= isize::max_value() as usize {
656+
if cap >= isize::MAX as usize {
657657
return Ok(Vec::new());
658658
}
659659
}

vm/sre_engine/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ fn _match<S: StrDrive>(req: &Request<S>, state: &mut State, mut ctx: MatchContex
671671
min_count: ctx.peek_code(req, 2) as usize,
672672
max_count: ctx.peek_code(req, 3) as usize,
673673
code_position: ctx.code_position,
674-
last_position: std::usize::MAX,
674+
last_position: usize::MAX,
675675
prev_id: ctx.repeat_ctx_id,
676676
};
677677
state.repeat_stack.push(repeat_ctx);

0 commit comments

Comments
 (0)
0