Skip to content

Commit 64f9b1a

Browse files
committed
Apply rustc 1.85 lints
1 parent aef159e commit 64f9b1a

File tree

16 files changed

+44
-67
lines changed

16 files changed

+44
-67
lines changed

core/engine/src/builtins/temporal/instant/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ impl Instant {
153153
None,
154154
context,
155155
)
156-
.map(Into::into)
157156
}
158157

159158
pub(crate) fn from_epoch_milliseconds(
@@ -172,7 +171,6 @@ impl Instant {
172171
None,
173172
context,
174173
)
175-
.map(Into::into)
176174
}
177175

178176
pub(crate) fn from_epoch_nanoseconds(
@@ -190,7 +188,6 @@ impl Instant {
190188
None,
191189
context,
192190
)
193-
.map(Into::into)
194191
}
195192

196193
pub(crate) fn compare(

core/engine/src/builtins/temporal/now.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Now {
7070
/// 2.2.2 `Temporal.Now.instant()`
7171
fn instant(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
7272
let epoch_nanos = system_nanoseconds(context)?;
73-
create_temporal_instant(Instant::from(epoch_nanos), None, context).map(Into::into)
73+
create_temporal_instant(Instant::from(epoch_nanos), None, context)
7474
}
7575

7676
/// 2.2.3 `Temporal.Now.plainDateTimeISO ( [ temporalTimeZoneLike ] )`

core/engine/src/builtins/temporal/plain_date_time/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,7 @@ fn to_partial_datetime(
12181218
let finite = v.to_finitef64(context)?;
12191219
Ok::<u8, JsError>(finite.as_integer_with_truncation::<u8>())
12201220
})
1221-
.transpose()?
1222-
.map(Into::into);
1221+
.transpose()?;
12231222
// TODO: `temporal_rs` needs a `has_era` method
12241223
let (era, era_year) = if calendar == Calendar::default() {
12251224
(None, None)
@@ -1254,26 +1253,23 @@ fn to_partial_datetime(
12541253
let finite = v.to_finitef64(context)?;
12551254
Ok::<u16, JsError>(finite.as_integer_with_truncation::<u16>())
12561255
})
1257-
.transpose()?
1258-
.map(Into::into);
1256+
.transpose()?;
12591257

12601258
let millisecond = partial_object
12611259
.get(js_string!("millisecond"), context)?
12621260
.map(|v| {
12631261
let finite = v.to_finitef64(context)?;
12641262
Ok::<u16, JsError>(finite.as_integer_with_truncation::<u16>())
12651263
})
1266-
.transpose()?
1267-
.map(Into::into);
1264+
.transpose()?;
12681265

12691266
let minute = partial_object
12701267
.get(js_string!("minute"), context)?
12711268
.map(|v| {
12721269
let finite = v.to_finitef64(context)?;
12731270
Ok::<u8, JsError>(finite.as_integer_with_truncation::<u8>())
12741271
})
1275-
.transpose()?
1276-
.map(Into::into);
1272+
.transpose()?;
12771273

12781274
let month = partial_object
12791275
.get(js_string!("month"), context)?
@@ -1305,17 +1301,15 @@ fn to_partial_datetime(
13051301
let finite = v.to_finitef64(context)?;
13061302
Ok::<u16, JsError>(finite.as_integer_with_truncation::<u16>())
13071303
})
1308-
.transpose()?
1309-
.map(Into::into);
1304+
.transpose()?;
13101305

13111306
let second = partial_object
13121307
.get(js_string!("second"), context)?
13131308
.map(|v| {
13141309
let finite = v.to_finitef64(context)?;
13151310
Ok::<u8, JsError>(finite.as_integer_with_truncation::<u8>())
13161311
})
1317-
.transpose()?
1318-
.map(Into::into);
1312+
.transpose()?;
13191313

13201314
let year = partial_object
13211315
.get(js_string!("year"), context)?

core/engine/src/builtins/temporal/plain_time/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -722,53 +722,47 @@ pub(crate) fn to_partial_time_record(
722722
let finite = v.to_finitef64(context)?;
723723
Ok::<u8, JsError>(finite.as_integer_with_truncation::<u8>())
724724
})
725-
.transpose()?
726-
.map(Into::into);
725+
.transpose()?;
727726

728727
let microsecond = partial_object
729728
.get(js_string!("microsecond"), context)?
730729
.map(|v| {
731730
let finite = v.to_finitef64(context)?;
732731
Ok::<u16, JsError>(finite.as_integer_with_truncation::<u16>())
733732
})
734-
.transpose()?
735-
.map(Into::into);
733+
.transpose()?;
736734

737735
let millisecond = partial_object
738736
.get(js_string!("millisecond"), context)?
739737
.map(|v| {
740738
let finite = v.to_finitef64(context)?;
741739
Ok::<u16, JsError>(finite.as_integer_with_truncation::<u16>())
742740
})
743-
.transpose()?
744-
.map(Into::into);
741+
.transpose()?;
745742

746743
let minute = partial_object
747744
.get(js_string!("minute"), context)?
748745
.map(|v| {
749746
let finite = v.to_finitef64(context)?;
750747
Ok::<u8, JsError>(finite.as_integer_with_truncation::<u8>())
751748
})
752-
.transpose()?
753-
.map(Into::into);
749+
.transpose()?;
754750

755751
let nanosecond = partial_object
756752
.get(js_string!("nanosecond"), context)?
757753
.map(|v| {
758754
let finite = v.to_finitef64(context)?;
759755
Ok::<u16, JsError>(finite.as_integer_with_truncation::<u16>())
760756
})
761-
.transpose()?
762-
.map(Into::into);
757+
.transpose()?;
763758

764759
let second = partial_object
765760
.get(js_string!("second"), context)?
766761
.map(|v| {
767762
let finite = v.to_finitef64(context)?;
768763
Ok::<u8, JsError>(finite.as_integer_with_truncation::<u8>())
769764
})
770-
.transpose()?
771-
.map(Into::into);
765+
.transpose()?;
772766

773767
Ok(PartialTime {
774768
hour,

core/engine/src/builtins/temporal/plain_year_month/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,8 @@ impl BuiltInConstructor for PlainYearMonth {
214214
.transpose()?;
215215

216216
// 7. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget).
217-
let inner = InnerYearMonth::new_with_overflow(
218-
y,
219-
m,
220-
ref_day.map(Into::into),
221-
calendar,
222-
ArithmeticOverflow::Reject,
223-
)?;
217+
let inner =
218+
InnerYearMonth::new_with_overflow(y, m, ref_day, calendar, ArithmeticOverflow::Reject)?;
224219

225220
create_temporal_year_month(inner, Some(new_target), context)
226221
}

core/engine/src/builtins/temporal/zoneddatetime/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ impl ZonedDateTime {
11331133
JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.")
11341134
})?;
11351135

1136-
create_temporal_instant(zdt.inner.to_instant(), None, context).map(Into::into)
1136+
create_temporal_instant(zdt.inner.to_instant(), None, context)
11371137
}
11381138

11391139
/// 6.3.48 `Temporal.ZonedDateTime.prototype.toPlainDate ( )`

core/engine/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl JsError {
619619
/// Is the [`JsError`] catchable in JavaScript.
620620
#[inline]
621621
pub(crate) fn is_catchable(&self) -> bool {
622-
self.as_native().map_or(true, JsNativeError::is_catchable)
622+
self.as_native().is_none_or(JsNativeError::is_catchable)
623623
}
624624
}
625625

core/engine/src/module/namespace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn module_namespace_exotic_define_own_property(
213213

214214
// 8. If Desc has a [[Value]] field, return SameValue(Desc.[[Value]], current.[[Value]]).
215215
// 9. Return true.
216-
Ok(desc.value().map_or(true, |v| v == current.expect_value()))
216+
Ok(desc.value().is_none_or(|v| v == current.expect_value()))
217217
}
218218

219219
/// [`[[HasProperty]] ( P )`][spec]

core/engine/src/object/jsobject.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl JsObject {
408408
let get = if let Some(getter) = self.try_get(js_string!("get"), context)? {
409409
// b. If IsCallable(getter) is false and getter is not undefined, throw a TypeError exception.
410410
// todo: extract IsCallable to be callable from Value
411-
if !getter.is_undefined() && getter.as_object().map_or(true, |o| !o.is_callable()) {
411+
if !getter.is_undefined() && getter.as_object().is_none_or(|o| !o.is_callable()) {
412412
return Err(JsNativeError::typ()
413413
.with_message("Property descriptor getter must be callable")
414414
.into());
@@ -425,7 +425,7 @@ impl JsObject {
425425
let set = if let Some(setter) = self.try_get(js_string!("set"), context)? {
426426
// 14.b. If IsCallable(setter) is false and setter is not undefined, throw a TypeError exception.
427427
// todo: extract IsCallable to be callable from Value
428-
if !setter.is_undefined() && setter.as_object().map_or(true, |o| !o.is_callable()) {
428+
if !setter.is_undefined() && setter.as_object().is_none_or(|o| !o.is_callable()) {
429429
return Err(JsNativeError::typ()
430430
.with_message("Property descriptor setter must be callable")
431431
.into());
@@ -748,6 +748,10 @@ impl<T: NativeObject + ?Sized> JsObject<T> {
748748
/// [spec]: https://tc39.es/ecma262/#sec-iscallable
749749
#[inline]
750750
#[must_use]
751+
#[expect(
752+
unpredictable_function_pointer_comparisons,
753+
reason = "can only use `ptr::fn_addr_eq` on rustc 1.85"
754+
)]
751755
pub fn is_callable(&self) -> bool {
752756
self.inner.vtable.__call__ != ORDINARY_INTERNAL_METHODS.__call__
753757
}
@@ -760,6 +764,10 @@ impl<T: NativeObject + ?Sized> JsObject<T> {
760764
/// [spec]: https://tc39.es/ecma262/#sec-isconstructor
761765
#[inline]
762766
#[must_use]
767+
#[expect(
768+
unpredictable_function_pointer_comparisons,
769+
reason = "can only use `ptr::fn_addr_eq` on rustc 1.85"
770+
)]
763771
pub fn is_constructor(&self) -> bool {
764772
self.inner.vtable.__construct__ != ORDINARY_INTERNAL_METHODS.__construct__
765773
}

core/engine/src/vm/opcode/concat/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ impl ConcatToString {
2222
let val = registers.get(*value);
2323
strings.push(val.to_string(context)?);
2424
}
25-
let s = JsString::concat_array(
26-
&strings
27-
.iter()
28-
.map(JsString::as_str)
29-
.map(Into::into)
30-
.collect::<Vec<_>>(),
31-
);
25+
let s = JsString::concat_array(&strings.iter().map(JsString::as_str).collect::<Vec<_>>());
3226
registers.set(string, s.into());
3327
Ok(CompletionType::Normal)
3428
}

0 commit comments

Comments
 (0)