Skip to content

Commit 4e9d8a5

Browse files
committed
chore: fix some nightly clippy warnings
1 parent 051ceb6 commit 4e9d8a5

File tree

8 files changed

+10
-14
lines changed

8 files changed

+10
-14
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ non_ascii_idents = "warn"
2222
unit-bindings = "warn"
2323

2424
[workspace.lints.clippy]
25-
all = { level = "warn" }
25+
all = { level = "warn", priority = -1 }
2626
empty_docs = { level = "allow", priority = 1 } # from `Tsify`
2727
# restriction
2828
dbg_macro = "warn"

crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ fn format_raw(raw: &str) -> Option<(String, bool)> {
8080
let dot_and_fractions = after_parts.next()?;
8181
let after = after_parts.next().unwrap_or("");
8282

83-
let fixed_dot_and_fractions =
84-
dot_and_fractions.trim_end_matches(|c: char| c == '0' || c == '.' || c == '_');
83+
let fixed_dot_and_fractions = dot_and_fractions.trim_end_matches(['0', '.', '_']);
8584
let formatted = format!(
8685
"{}{}{}{}",
8786
if before.is_empty() && fixed_dot_and_fractions.is_empty() { "0" } else { before },

crates/oxc_prettier/src/format/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1334,20 +1334,15 @@ impl<'a> Format<'a> for NumericLiteral<'a> {
13341334
// Remove unnecessary plus and zeroes from scientific notation.
13351335
if let Some((head, tail)) = string.split_once('e') {
13361336
let negative = if tail.starts_with('-') { "-" } else { "" };
1337-
let trimmed =
1338-
tail.trim_start_matches(|c| c == '+' || c == '-').trim_start_matches('0');
1337+
let trimmed = tail.trim_start_matches(['+', '-']).trim_start_matches('0');
13391338
if trimmed.starts_with(|c: char| c.is_ascii_digit()) {
13401339
string = Cow::Owned(std::format!("{head}e{negative}{trimmed}"));
13411340
}
13421341
}
13431342

13441343
// Remove unnecessary scientific notation (1e0).
13451344
if let Some((head, tail)) = string.split_once('e') {
1346-
if tail
1347-
.trim_start_matches(|c| c == '+' || c == '-')
1348-
.trim_start_matches('0')
1349-
.is_empty()
1350-
{
1345+
if tail.trim_start_matches(['+', '-']).trim_start_matches('0').is_empty() {
13511346
string = Cow::Owned(head.to_string());
13521347
}
13531348
}

crates/oxc_prettier/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ pub struct PrettierOptions {
4747
pub trailing_comma: TrailingComma,
4848

4949
/// Print spaces between brackets in object literals.
50+
///
5051
/// * true - Example: `{ foo: bar }`.
5152
/// * false - Example: `{foo: bar}`.
53+
///
5254
/// Default: true
5355
pub bracket_spacing: bool,
5456

crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ impl<'a> JSDocCommentPart<'a> {
6363

6464
let start_trimmed = self.raw.trim_start();
6565
let trimmed_start_offset = base_len - start_trimmed.len();
66-
let trimmed_end_offset =
67-
trimmed_start_offset + start_trimmed.find(|c| c == '\n').unwrap_or(0);
66+
let trimmed_end_offset = trimmed_start_offset + start_trimmed.find('\n').unwrap_or(0);
6867
Span::new(
6968
self.span.start + u32::try_from(trimmed_start_offset).unwrap_or_default(),
7069
self.span.start + u32::try_from(trimmed_end_offset).unwrap_or_default(),

crates/oxc_traverse/src/ancestor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use std::cell::Cell;
1212

1313
use memoffset::offset_of;
14+
1415
use oxc_allocator::{Box, Vec};
1516
#[allow(clippy::wildcard_imports)]
1617
use oxc_ast::ast::*;

tasks/coverage/src/suite.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub trait Suite<T: Case> {
148148

149149
let path = path.strip_prefix(test_root).unwrap().to_owned();
150150
// remove the Byte Order Mark in some of the TypeScript files
151-
let code = code.trim_start_matches(|c| c == '\u{feff}').to_string();
151+
let code = code.trim_start_matches('\u{feff}').to_string();
152152
T::new(path, code)
153153
})
154154
.filter(|case| !case.skip_test_case())

tasks/transform_conformance/src/test_case.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl ExecTestCase {
359359
fn write_to_test_files(&self, content: &str) -> PathBuf {
360360
let allocator = Allocator::default();
361361
let new_file_name: String =
362-
normalize_path(self.path.strip_prefix(&packages_root()).unwrap())
362+
normalize_path(self.path.strip_prefix(packages_root()).unwrap())
363363
.split('/')
364364
.collect::<Vec<&str>>()
365365
.join("-");

0 commit comments

Comments
 (0)