Skip to content

Commit dd50433

Browse files
authored
Update Clippy to Rust v1.79 (#3987)
1 parent 3f6c7c6 commit dd50433

File tree

8 files changed

+50
-58
lines changed

8 files changed

+50
-58
lines changed

crates/backend/src/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl Encode for u32 {
437437

438438
impl Encode for usize {
439439
fn encode(&self, dst: &mut Encoder) {
440-
assert!(*self <= u32::max_value() as usize);
440+
assert!(*self <= u32::MAX as usize);
441441
(*self as u32).encode(dst);
442442
}
443443
}

crates/webidl/src/util.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ pub(crate) fn array(base_ty: &str, pos: TypePosition, immutable: bool) -> syn::T
103103

104104
/// Map a webidl const value to the correct wasm-bindgen const value
105105
pub fn webidl_const_v_to_backend_const_v(v: &ConstValueLit) -> ConstValue {
106-
use std::f64::{INFINITY, NAN, NEG_INFINITY};
107-
108106
match *v {
109107
ConstValueLit::Boolean(b) => ConstValue::Boolean(b.0),
110-
ConstValueLit::Float(FloatLit::NegInfinity(_)) => ConstValue::Float(NEG_INFINITY),
111-
ConstValueLit::Float(FloatLit::Infinity(_)) => ConstValue::Float(INFINITY),
112-
ConstValueLit::Float(FloatLit::NaN(_)) => ConstValue::Float(NAN),
108+
ConstValueLit::Float(FloatLit::NegInfinity(_)) => ConstValue::Float(f64::NEG_INFINITY),
109+
ConstValueLit::Float(FloatLit::Infinity(_)) => ConstValue::Float(f64::INFINITY),
110+
ConstValueLit::Float(FloatLit::NaN(_)) => ConstValue::Float(f64::NAN),
113111
ConstValueLit::Float(FloatLit::Value(s)) => ConstValue::Float(s.0.parse().unwrap()),
114112
ConstValueLit::Integer(lit) => {
115113
let mklit = |orig_text: &str, base: u32, offset: usize| {
@@ -125,7 +123,7 @@ pub fn webidl_const_v_to_backend_const_v(v: &ConstValueLit) -> ConstValue {
125123
let n = u64::from_str_radix(text, base)
126124
.unwrap_or_else(|_| panic!("literal too big: {}", orig_text));
127125
if negative {
128-
let n = if n > (i64::min_value() as u64).wrapping_neg() {
126+
let n = if n > (i64::MIN as u64).wrapping_neg() {
129127
panic!("literal too big: {}", orig_text)
130128
} else {
131129
n.wrapping_neg() as i64

examples/webaudio/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,7 @@ impl FmOsc {
9393
/// Sets the gain for this oscillator, between 0.0 and 1.0.
9494
#[wasm_bindgen]
9595
pub fn set_gain(&self, mut gain: f32) {
96-
if gain > 1.0 {
97-
gain = 1.0;
98-
}
99-
if gain < 0.0 {
100-
gain = 0.0;
101-
}
96+
gain = gain.clamp(0.0, 1.0);
10297
self.gain.gain().set_value(gain);
10398
}
10499

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use core::ops::{
1717
Add, BitAnd, BitOr, BitXor, Deref, DerefMut, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub,
1818
};
1919
use core::ptr::NonNull;
20-
use core::u32;
2120

2221
use crate::convert::{FromWasmAbi, TryFromJsValue, WasmRet, WasmSlice};
2322

@@ -1503,7 +1502,7 @@ pub mod __rt {
15031502

15041503
pub fn borrow(&self) -> Ref<T> {
15051504
unsafe {
1506-
if self.borrow.get() == usize::max_value() {
1505+
if self.borrow.get() == usize::MAX {
15071506
borrow_fail();
15081507
}
15091508
self.borrow.set(self.borrow.get() + 1);
@@ -1519,7 +1518,7 @@ pub mod __rt {
15191518
if self.borrow.get() != 0 {
15201519
borrow_fail();
15211520
}
1522-
self.borrow.set(usize::max_value());
1521+
self.borrow.set(usize::MAX);
15231522
RefMut {
15241523
value: &mut *self.value.get(),
15251524
borrow: &self.borrow,

tests/wasm/bigint.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ pub fn neg_one() -> i64 {
2525

2626
#[wasm_bindgen]
2727
pub fn i32_min() -> i64 {
28-
i32::min_value() as i64
28+
i32::MIN as i64
2929
}
3030

3131
#[wasm_bindgen]
3232
pub fn u32_max() -> u64 {
33-
u32::max_value() as u64
33+
u32::MAX as u64
3434
}
3535

3636
#[wasm_bindgen]
3737
pub fn i64_min() -> i64 {
38-
i64::min_value()
38+
i64::MIN
3939
}
4040

4141
#[wasm_bindgen]
4242
pub fn u64_max() -> u64 {
43-
u64::max_value()
43+
u64::MAX
4444
}
4545

4646
#[wasm_bindgen]
@@ -65,12 +65,12 @@ pub fn u64_jsvalue_identity(a: u64) -> JsValue {
6565

6666
#[wasm_bindgen]
6767
pub fn i128_min_jsvalue() -> JsValue {
68-
JsValue::from(i128::min_value())
68+
JsValue::from(i128::MIN)
6969
}
7070

7171
#[wasm_bindgen]
7272
pub fn u128_max_jsvalue() -> JsValue {
73-
JsValue::from(u128::max_value())
73+
JsValue::from(u128::MAX)
7474
}
7575

7676
#[wasm_bindgen]

tests/wasm/math.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,24 @@ macro_rules! t_roundtrip {
9494

9595
#[wasm_bindgen_test]
9696
fn limits_correct() {
97-
t_roundtrip!(roundtrip_i8(i8::min_value()));
97+
t_roundtrip!(roundtrip_i8(i8::MIN));
9898
t_roundtrip!(roundtrip_i8(0));
99-
t_roundtrip!(roundtrip_i8(i8::max_value()));
100-
t_roundtrip!(roundtrip_i16(i16::min_value()));
99+
t_roundtrip!(roundtrip_i8(i8::MAX));
100+
t_roundtrip!(roundtrip_i16(i16::MIN));
101101
t_roundtrip!(roundtrip_i16(0));
102-
t_roundtrip!(roundtrip_i16(i16::max_value()));
103-
t_roundtrip!(roundtrip_i32(i32::min_value()));
102+
t_roundtrip!(roundtrip_i16(i16::MAX));
103+
t_roundtrip!(roundtrip_i32(i32::MIN));
104104
t_roundtrip!(roundtrip_i32(0));
105-
t_roundtrip!(roundtrip_i32(i32::max_value()));
106-
t_roundtrip!(roundtrip_u8(u8::min_value()));
105+
t_roundtrip!(roundtrip_i32(i32::MAX));
106+
t_roundtrip!(roundtrip_u8(u8::MIN));
107107
t_roundtrip!(roundtrip_u8(0));
108-
t_roundtrip!(roundtrip_u8(u8::max_value()));
109-
t_roundtrip!(roundtrip_u16(u16::min_value()));
108+
t_roundtrip!(roundtrip_u8(u8::MAX));
109+
t_roundtrip!(roundtrip_u16(u16::MIN));
110110
t_roundtrip!(roundtrip_u16(0));
111-
t_roundtrip!(roundtrip_u16(u16::max_value()));
112-
t_roundtrip!(roundtrip_u32(u32::min_value()));
111+
t_roundtrip!(roundtrip_u16(u16::MAX));
112+
t_roundtrip!(roundtrip_u32(u32::MIN));
113113
t_roundtrip!(roundtrip_u32(0));
114-
t_roundtrip!(roundtrip_u32(u32::max_value()));
114+
t_roundtrip!(roundtrip_u32(u32::MAX));
115115

116116
test_js_roundtrip();
117117

tests/wasm/optional_primitives.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ pub fn optional_i32_neg_one() -> Option<i32> {
4343

4444
#[wasm_bindgen]
4545
pub fn optional_i32_min() -> Option<i32> {
46-
Some(i32::min_value())
46+
Some(i32::MIN)
4747
}
4848

4949
#[wasm_bindgen]
5050
pub fn optional_i32_max() -> Option<i32> {
51-
Some(i32::max_value())
51+
Some(i32::MAX)
5252
}
5353

5454
#[wasm_bindgen]
@@ -73,12 +73,12 @@ pub fn optional_u32_one() -> Option<u32> {
7373

7474
#[wasm_bindgen]
7575
pub fn optional_u32_min() -> Option<u32> {
76-
Some(u32::min_value())
76+
Some(u32::MIN)
7777
}
7878

7979
#[wasm_bindgen]
8080
pub fn optional_u32_max() -> Option<u32> {
81-
Some(u32::max_value())
81+
Some(u32::MAX)
8282
}
8383

8484
#[wasm_bindgen]
@@ -108,12 +108,12 @@ pub fn optional_isize_neg_one() -> Option<isize> {
108108

109109
#[wasm_bindgen]
110110
pub fn optional_isize_min() -> Option<isize> {
111-
Some(isize::min_value())
111+
Some(isize::MIN)
112112
}
113113

114114
#[wasm_bindgen]
115115
pub fn optional_isize_max() -> Option<isize> {
116-
Some(isize::max_value())
116+
Some(isize::MAX)
117117
}
118118

119119
#[wasm_bindgen]
@@ -138,12 +138,12 @@ pub fn optional_usize_one() -> Option<usize> {
138138

139139
#[wasm_bindgen]
140140
pub fn optional_usize_min() -> Option<usize> {
141-
Some(usize::min_value())
141+
Some(usize::MIN)
142142
}
143143

144144
#[wasm_bindgen]
145145
pub fn optional_usize_max() -> Option<usize> {
146-
Some(usize::max_value())
146+
Some(usize::MAX)
147147
}
148148

149149
#[wasm_bindgen]
@@ -223,12 +223,12 @@ pub fn optional_i8_neg_one() -> Option<i8> {
223223

224224
#[wasm_bindgen]
225225
pub fn optional_i8_min() -> Option<i8> {
226-
Some(i8::min_value())
226+
Some(i8::MIN)
227227
}
228228

229229
#[wasm_bindgen]
230230
pub fn optional_i8_max() -> Option<i8> {
231-
Some(i8::max_value())
231+
Some(i8::MAX)
232232
}
233233

234234
#[wasm_bindgen]
@@ -253,12 +253,12 @@ pub fn optional_u8_one() -> Option<u8> {
253253

254254
#[wasm_bindgen]
255255
pub fn optional_u8_min() -> Option<u8> {
256-
Some(u8::min_value())
256+
Some(u8::MIN)
257257
}
258258

259259
#[wasm_bindgen]
260260
pub fn optional_u8_max() -> Option<u8> {
261-
Some(u8::max_value())
261+
Some(u8::MAX)
262262
}
263263

264264
#[wasm_bindgen]
@@ -288,12 +288,12 @@ pub fn optional_i16_neg_one() -> Option<i16> {
288288

289289
#[wasm_bindgen]
290290
pub fn optional_i16_min() -> Option<i16> {
291-
Some(i16::min_value())
291+
Some(i16::MIN)
292292
}
293293

294294
#[wasm_bindgen]
295295
pub fn optional_i16_max() -> Option<i16> {
296-
Some(i16::max_value())
296+
Some(i16::MAX)
297297
}
298298

299299
#[wasm_bindgen]
@@ -318,12 +318,12 @@ pub fn optional_u16_one() -> Option<u16> {
318318

319319
#[wasm_bindgen]
320320
pub fn optional_u16_min() -> Option<u16> {
321-
Some(u16::min_value())
321+
Some(u16::MIN)
322322
}
323323

324324
#[wasm_bindgen]
325325
pub fn optional_u16_max() -> Option<u16> {
326-
Some(u16::max_value())
326+
Some(u16::MAX)
327327
}
328328

329329
#[wasm_bindgen]
@@ -353,12 +353,12 @@ pub fn optional_i64_neg_one() -> Option<i64> {
353353

354354
#[wasm_bindgen]
355355
pub fn optional_i64_min() -> Option<i64> {
356-
Some(i64::min_value())
356+
Some(i64::MIN)
357357
}
358358

359359
#[wasm_bindgen]
360360
pub fn optional_i64_max() -> Option<i64> {
361-
Some(i64::max_value())
361+
Some(i64::MAX)
362362
}
363363

364364
#[wasm_bindgen]
@@ -383,12 +383,12 @@ pub fn optional_u64_one() -> Option<u64> {
383383

384384
#[wasm_bindgen]
385385
pub fn optional_u64_min() -> Option<u64> {
386-
Some(u64::min_value())
386+
Some(u64::MIN)
387387
}
388388

389389
#[wasm_bindgen]
390390
pub fn optional_u64_max() -> Option<u64> {
391-
Some(u64::max_value())
391+
Some(u64::MAX)
392392
}
393393

394394
#[wasm_bindgen]

tests/wasm/usize.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ pub fn isize_neg_one() -> isize {
2525

2626
#[wasm_bindgen]
2727
pub fn isize_i32_min() -> isize {
28-
i32::min_value() as isize
28+
i32::MIN as isize
2929
}
3030

3131
#[wasm_bindgen]
3232
pub fn usize_u32_max() -> usize {
33-
u32::max_value() as usize
33+
u32::MAX as usize
3434
}
3535

3636
#[wasm_bindgen]
3737
pub fn isize_min() -> isize {
38-
isize::min_value()
38+
isize::MIN
3939
}
4040

4141
#[wasm_bindgen]
4242
pub fn usize_max() -> usize {
43-
usize::max_value()
43+
usize::MAX
4444
}
4545

4646
#[wasm_bindgen]

0 commit comments

Comments
 (0)