Skip to content

Commit d3e2fa4

Browse files
authored
Remove wrong Deref (#6620)
1 parent 3e2ada0 commit d3e2fa4

File tree

13 files changed

+141
-129
lines changed

13 files changed

+141
-129
lines changed

crates/stdlib/src/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,11 +565,11 @@ mod array {
565565
}
566566

567567
fn f32_try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<f32> {
568-
ArgIntoFloat::try_from_object(vm, obj).map(|x| *x as f32)
568+
ArgIntoFloat::try_from_object(vm, obj).map(|x| x.into_float() as f32)
569569
}
570570

571571
fn f64_try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<f64> {
572-
ArgIntoFloat::try_from_object(vm, obj).map(Into::into)
572+
ArgIntoFloat::try_from_object(vm, obj).map(|x| x.into_float())
573573
}
574574

575575
fn pyfloat_from_f32(value: f32) -> PyFloat {

crates/stdlib/src/bisect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod _bisect {
2424
#[inline]
2525
fn handle_default(arg: OptionalArg<ArgIndex>, vm: &VirtualMachine) -> PyResult<Option<isize>> {
2626
arg.into_option()
27-
.map(|v| v.try_to_primitive(vm))
27+
.map(|v| v.into_int_ref().try_to_primitive(vm))
2828
.transpose()
2929
}
3030

crates/stdlib/src/cmath.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,64 +23,64 @@ mod cmath {
2323

2424
#[pyfunction]
2525
fn phase(z: ArgIntoComplex) -> f64 {
26-
z.arg()
26+
z.into_complex().arg()
2727
}
2828

2929
#[pyfunction]
3030
fn polar(x: ArgIntoComplex) -> (f64, f64) {
31-
x.to_polar()
31+
x.into_complex().to_polar()
3232
}
3333

3434
#[pyfunction]
3535
fn rect(r: ArgIntoFloat, phi: ArgIntoFloat) -> Complex64 {
36-
Complex64::from_polar(*r, *phi)
36+
Complex64::from_polar(r.into_float(), phi.into_float())
3737
}
3838

3939
#[pyfunction]
4040
fn isinf(z: ArgIntoComplex) -> bool {
41-
let Complex64 { re, im } = *z;
41+
let Complex64 { re, im } = z.into_complex();
4242
re.is_infinite() || im.is_infinite()
4343
}
4444

4545
#[pyfunction]
4646
fn isfinite(z: ArgIntoComplex) -> bool {
47-
z.is_finite()
47+
z.into_complex().is_finite()
4848
}
4949

5050
#[pyfunction]
5151
fn isnan(z: ArgIntoComplex) -> bool {
52-
z.is_nan()
52+
z.into_complex().is_nan()
5353
}
5454

5555
#[pyfunction]
5656
fn exp(z: ArgIntoComplex, vm: &VirtualMachine) -> PyResult<Complex64> {
57-
let z = *z;
57+
let z = z.into_complex();
5858
result_or_overflow(z, z.exp(), vm)
5959
}
6060

6161
#[pyfunction]
6262
fn sqrt(z: ArgIntoComplex) -> Complex64 {
63-
z.sqrt()
63+
z.into_complex().sqrt()
6464
}
6565

6666
#[pyfunction]
6767
fn sin(z: ArgIntoComplex) -> Complex64 {
68-
z.sin()
68+
z.into_complex().sin()
6969
}
7070

7171
#[pyfunction]
7272
fn asin(z: ArgIntoComplex) -> Complex64 {
73-
z.asin()
73+
z.into_complex().asin()
7474
}
7575

7676
#[pyfunction]
7777
fn cos(z: ArgIntoComplex) -> Complex64 {
78-
z.cos()
78+
z.into_complex().cos()
7979
}
8080

8181
#[pyfunction]
8282
fn acos(z: ArgIntoComplex) -> Complex64 {
83-
z.acos()
83+
z.into_complex().acos()
8484
}
8585

8686
#[pyfunction]
@@ -90,56 +90,56 @@ mod cmath {
9090
// which returns NaN when base is negative.
9191
// log10(z) / log10(base) yields correct results but division
9292
// doesn't handle pos/neg zero nicely. (i.e log(1, 0.5))
93-
z.log(
93+
z.into_complex().log(
9494
base.into_option()
95-
.map(|base| base.re)
95+
.map(|base| base.into_complex().re)
9696
.unwrap_or(core::f64::consts::E),
9797
)
9898
}
9999

100100
#[pyfunction]
101101
fn log10(z: ArgIntoComplex) -> Complex64 {
102-
z.log(10.0)
102+
z.into_complex().log(10.0)
103103
}
104104

105105
#[pyfunction]
106106
fn acosh(z: ArgIntoComplex) -> Complex64 {
107-
z.acosh()
107+
z.into_complex().acosh()
108108
}
109109

110110
#[pyfunction]
111111
fn atan(z: ArgIntoComplex) -> Complex64 {
112-
z.atan()
112+
z.into_complex().atan()
113113
}
114114

115115
#[pyfunction]
116116
fn atanh(z: ArgIntoComplex) -> Complex64 {
117-
z.atanh()
117+
z.into_complex().atanh()
118118
}
119119

120120
#[pyfunction]
121121
fn tan(z: ArgIntoComplex) -> Complex64 {
122-
z.tan()
122+
z.into_complex().tan()
123123
}
124124

125125
#[pyfunction]
126126
fn tanh(z: ArgIntoComplex) -> Complex64 {
127-
z.tanh()
127+
z.into_complex().tanh()
128128
}
129129

130130
#[pyfunction]
131131
fn sinh(z: ArgIntoComplex) -> Complex64 {
132-
z.sinh()
132+
z.into_complex().sinh()
133133
}
134134

135135
#[pyfunction]
136136
fn cosh(z: ArgIntoComplex) -> Complex64 {
137-
z.cosh()
137+
z.into_complex().cosh()
138138
}
139139

140140
#[pyfunction]
141141
fn asinh(z: ArgIntoComplex) -> Complex64 {
142-
z.asinh()
142+
z.into_complex().asinh()
143143
}
144144

145145
#[derive(FromArgs)]
@@ -156,10 +156,10 @@ mod cmath {
156156

157157
#[pyfunction]
158158
fn isclose(args: IsCloseArgs, vm: &VirtualMachine) -> PyResult<bool> {
159-
let a = *args.a;
160-
let b = *args.b;
161-
let rel_tol = args.rel_tol.map_or(1e-09, Into::into);
162-
let abs_tol = args.abs_tol.map_or(0.0, Into::into);
159+
let a = args.a.into_complex();
160+
let b = args.b.into_complex();
161+
let rel_tol = args.rel_tol.map_or(1e-09, |v| v.into_float());
162+
let abs_tol = args.abs_tol.map_or(0.0, |v| v.into_float());
163163

164164
if rel_tol < 0.0 || abs_tol < 0.0 {
165165
return Err(vm.new_value_error("tolerances must be non-negative"));

0 commit comments

Comments
 (0)