Skip to content

Commit aba8192

Browse files
committed
fix: clippy warnings
1 parent ab02d19 commit aba8192

File tree

13 files changed

+15
-15
lines changed

13 files changed

+15
-15
lines changed

crates/hstr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'de> serde::de::Deserialize<'de> for Atom {
181181
}
182182
const DYNAMIC_TAG: u8 = 0b_00;
183183
const INLINE_TAG: u8 = 0b_01; // len in upper nybble
184-
const INLINE_TAG_INIT: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(INLINE_TAG) };
184+
const INLINE_TAG_INIT: NonZeroU8 = NonZeroU8::new(INLINE_TAG).unwrap();
185185
const TAG_MASK: u8 = 0b_11;
186186
const LEN_OFFSET: usize = 4;
187187
const LEN_MASK: u8 = 0xf0;

crates/preset_env_base/src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn should_enable(target: &Versions, feature: &Versions, default: bool) -> bo
179179
_ => None,
180180
});
181181

182-
feature_or_fallback_version.map_or(true, |v| v > target_version)
182+
feature_or_fallback_version.is_none_or(|v| v > target_version)
183183
})
184184
},
185185
)

crates/swc_bundler/src/modules/sort/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::VecDeque, iter::repeat};
1+
use std::collections::VecDeque;
22

33
use petgraph::{
44
prelude::GraphMap,
@@ -68,7 +68,7 @@ impl StmtDepGraph {
6868
fn insert_transitives(&mut self, from: usize, to: usize) {
6969
if self.paths.len() <= from {
7070
self.paths
71-
.extend(repeat(Default::default()).take(from + 1 - self.paths.len()))
71+
.extend(std::iter::repeat_n(Default::default(), from + 1 - self.paths.len()))
7272
}
7373
if !self.paths[from].insert(to) {
7474
return;

crates/swc_css_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl Take for Token {
170170
}
171171

172172
#[allow(clippy::derived_hash_with_manual_eq)]
173-
#[allow(clippy::transmute_float_to_int)]
173+
#[allow(unnecessary_transmutes)]
174174
impl Hash for Token {
175175
fn hash<H: Hasher>(&self, state: &mut H) {
176176
fn integer_decode(val: f64) -> (u64, i16, i8) {

crates/swc_css_ast/src/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ pub struct Number {
352352
impl Eq for Number {}
353353

354354
#[allow(clippy::derived_hash_with_manual_eq)]
355-
#[allow(clippy::transmute_float_to_int)]
355+
#[allow(unnecessary_transmutes)]
356356
impl Hash for Number {
357357
fn hash<H: Hasher>(&self, state: &mut H) {
358358
fn integer_decode(val: f64) -> (u64, i16, i8) {

crates/swc_ecma_ast/src/lit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl EqIgnoreSpan for Number {
410410
}
411411

412412
#[allow(clippy::derived_hash_with_manual_eq)]
413-
#[allow(clippy::transmute_float_to_int)]
413+
#[allow(unnecessary_transmutes)]
414414
impl Hash for Number {
415415
fn hash<H: Hasher>(&self, state: &mut H) {
416416
fn integer_decode(val: f64) -> (u64, i16, i8) {

crates/swc_ecma_codegen/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ fn require_space_before_rhs(rhs: &Expr, op: &BinaryOp) -> bool {
13761376
}
13771377

13781378
fn is_empty_comments(span: &Span, comments: &Option<&dyn Comments>) -> bool {
1379-
span.is_dummy() || comments.map_or(true, |c| !c.has_leading(span.span_hi() - BytePos(1)))
1379+
span.is_dummy() || comments.is_none_or(|c| !c.has_leading(span.span_hi() - BytePos(1)))
13801380
}
13811381

13821382
fn span_has_leading_comment(cmt: &dyn Comments, span: Span) -> bool {

crates/swc_ecma_lexer/src/lexer/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl State {
149149
} else if next.is_rparen() || next.is_rbrace() {
150150
// TODO: Verify
151151
if context.len() == 1 {
152-
return true;
152+
true
153153
} else {
154154
let out = context.pop().unwrap();
155155
// let a = function(){}

crates/swc_ecma_minifier/src/compress/optimize/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl Optimizer<'_> {
296296
|| usage.flags.contains(VarUsageInfoFlags::USED_AS_ARG)
297297
&& ref_count > 1
298298
|| ref_count > usage.callee_count
299-
|| !is_arrow_simple_enough_for_copy(arr).is_some_and(|cost| cost <= 8))
299+
|| is_arrow_simple_enough_for_copy(arr).is_none_or(|cost| cost > 8))
300300
}
301301
_ => false,
302302
}

crates/swc_ecma_regexp/src/parser/reader/string_literal_parser/parser_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl Parser {
213213
if let Some(cp) = self.parse_character_escape_sequence() {
214214
return Ok(Some(cp));
215215
}
216-
if self.peek() == Some('0') && self.peek2().map_or(true, |ch| !ch.is_ascii_digit()) {
216+
if self.peek() == Some('0') && self.peek2().is_none_or(|ch| !ch.is_ascii_digit()) {
217217
self.advance();
218218
return Ok(Some(0x00));
219219
}

0 commit comments

Comments
 (0)