Skip to content

Commit 1d81ada

Browse files
Rust Edition 2024 (#9289)
closes #9271 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 414ce78 commit 1d81ada

File tree

810 files changed

+3452
-3984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

810 files changed

+3452
-3984
lines changed

.cargo/config.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ rule = "run -p rulegen"
1111
# Build oxlint in release mode
1212
oxlint = "build --release --bin oxlint --features allocator"
1313

14-
[resolver]
15-
incompatible-rust-versions = "fallback"
16-
1714
# Fix napi breaking in test environment <https://github.com/napi-rs/napi-rs/issues/1005#issuecomment-1011034770>
1815
# To be able to run unit tests on macOS, support compilation to 'x86_64-apple-darwin'.
1916
[target.'cfg(target_vendor = "apple")']

.rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
style_edition = "2024"
12
# Make Rust more readable given most people have wide screens nowadays.
23
# This is also the setting used by [rustc](https://github.com/rust-lang/rust/blob/master/rustfmt.toml)
34
use_small_heuristics = "Max"
@@ -9,7 +10,6 @@ reorder_modules = true
910

1011
# All unstable features that we wish for
1112
# unstable_features = true
12-
# style_edition = "2024"
1313
# Provide a cleaner impl order
1414
# reorder_impl_items = true
1515
# Provide a cleaner import sort order

Cargo.lock

+26-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,26 @@ exclude = ["tasks/lint_rules", "tasks/e2e"]
66
[workspace.package]
77
authors = ["Boshen <[email protected]>", "Oxc contributors"]
88
categories = ["compilers", "development-tools", "web-programming"]
9-
edition = "2021"
109
homepage = "https://oxc.rs"
1110
keywords = ["JavaScript", "TypeScript", "linter", "minifier", "parser"]
1211
license = "MIT"
1312
repository = "https://github.com/oxc-project/oxc"
14-
rust-version = "1.82.0" # Support last 4 minor versions. (NOTE: bump to `edition = "2024"` when 1.85.0.
1513
description = "A collection of JavaScript tools written in Rust."
1614

15+
edition = "2024"
16+
# MSRV Policy N-2 (12 weeks) starting from v1.87.0
17+
# Balance between the core contributors enjoying the latest version of rustc, while waiting for dependents to catch up.
18+
rust-version = "1.85.0"
19+
1720
# <https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html>
1821
[workspace.lints.rust]
1922
absolute_paths_not_starting_with_crate = "warn"
2023
non_ascii_idents = "warn"
2124
unit-bindings = "warn"
2225
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)', 'cfg(coverage_nightly)'] }
26+
tail_expr_drop_order = "allow" # FIXME
27+
unsafe_op_in_unsafe_fn = "allow" # FIXME
28+
unused_unsafe = "allow"
2329

2430
[workspace.lints.clippy]
2531
all = { level = "warn", priority = -1 }
@@ -45,7 +51,7 @@ rc_buffer = "warn"
4551
rc_mutex = "warn"
4652
rest_pat_in_fully_bound_structs = "warn"
4753
unnecessary_safety_comment = "warn"
48-
undocumented_unsafe_blocks = "warn"
54+
undocumented_unsafe_blocks = "allow" # FIXME
4955
infinite_loop = "warn"
5056
map_with_unused_argument_over_ranges = "warn"
5157
unused_result_ok = "warn"

apps/oxlint/src/command/ignore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::ffi::OsString;
22

3-
use bpaf::{doc::Style, Bpaf};
3+
use bpaf::{Bpaf, doc::Style};
44

55
pub const NO_IGNORE_HELP: &[(&str, Style)] = &[
66
("Disables excluding of files from .eslintignore files, ", Style::Text),

apps/oxlint/src/command/lint.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use oxc_linter::{AllowWarnDeny, FixKind, LintPlugins};
66
use crate::output_formatter::OutputFormat;
77

88
use super::{
9-
ignore::{ignore_options, IgnoreOptions},
10-
misc_options, validate_paths, MiscOptions, PATHS_ERROR_MESSAGE, VERSION,
9+
MiscOptions, PATHS_ERROR_MESSAGE, VERSION,
10+
ignore::{IgnoreOptions, ignore_options},
11+
misc_options, validate_paths,
1112
};
1213

1314
#[derive(Debug, Clone, Bpaf)]
@@ -392,7 +393,7 @@ mod plugins {
392393

393394
#[cfg(test)]
394395
mod warning_options {
395-
use super::{lint_command, WarningOptions};
396+
use super::{WarningOptions, lint_command};
396397

397398
fn get_warning_options(arg: &str) -> WarningOptions {
398399
let args = arg.split(' ').map(std::string::ToString::to_string).collect::<Vec<_>>();
@@ -425,7 +426,7 @@ mod lint_options {
425426

426427
use oxc_linter::AllowWarnDeny;
427428

428-
use super::{lint_command, LintCommand, OutputFormat};
429+
use super::{LintCommand, OutputFormat, lint_command};
429430

430431
fn get_lint_options(arg: &str) -> LintCommand {
431432
let args = arg.split(' ').map(std::string::ToString::to_string).collect::<Vec<_>>();

apps/oxlint/src/command/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bpaf::Bpaf;
77

88
pub use self::{
99
ignore::IgnoreOptions,
10-
lint::{lint_command, LintCommand, OutputOptions, WarningOptions},
10+
lint::{LintCommand, OutputOptions, WarningOptions, lint_command},
1111
};
1212

1313
const VERSION: &str = match option_env!("OXC_VERSION") {
@@ -45,7 +45,7 @@ const PATHS_ERROR_MESSAGE: &str = "PATH must not contain \"..\"";
4545

4646
#[cfg(test)]
4747
mod misc_options {
48-
use super::{lint::lint_command, MiscOptions};
48+
use super::{MiscOptions, lint::lint_command};
4949

5050
fn get_misc_options(arg: &str) -> MiscOptions {
5151
let args = arg.split(' ').map(std::string::ToString::to_string).collect::<Vec<_>>();

apps/oxlint/src/lint.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use cow_utils::CowUtils;
99
use ignore::{gitignore::Gitignore, overrides::OverrideBuilder};
1010
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler};
1111
use oxc_linter::{
12-
loader::LINT_PARTIAL_LOADER_EXT, AllowWarnDeny, ConfigStoreBuilder, InvalidFilterKind,
13-
LintFilter, LintOptions, LintService, LintServiceOptions, Linter, Oxlintrc,
12+
AllowWarnDeny, ConfigStoreBuilder, InvalidFilterKind, LintFilter, LintOptions, LintService,
13+
LintServiceOptions, Linter, Oxlintrc, loader::LINT_PARTIAL_LOADER_EXT,
1414
};
1515
use oxc_span::VALID_EXTENSIONS;
1616
use serde_json::Value;
@@ -340,13 +340,17 @@ impl LintRunner {
340340
));
341341
}
342342
Err(InvalidFilterKind::PluginMissing(filter)) => {
343-
return Err((CliRunResult::InvalidOptionSeverityWithoutPluginName, format!(
343+
return Err((
344+
CliRunResult::InvalidOptionSeverityWithoutPluginName,
345+
format!(
344346
"Failed to {severity} filter {filter}: Plugin name is missing. Expected <plugin>/<rule>\n"
345347
),
346348
));
347349
}
348350
Err(InvalidFilterKind::RuleMissing(filter)) => {
349-
return Err((CliRunResult::InvalidOptionSeverityWithoutRuleName, format!(
351+
return Err((
352+
CliRunResult::InvalidOptionSeverityWithoutRuleName,
353+
format!(
350354
"Failed to {severity} filter {filter}: Rule name is missing. Expected <plugin>/<rule>\n"
351355
),
352356
));

apps/oxlint/src/output_formatter/checkstyle.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use std::borrow::Cow;
33
use rustc_hash::FxHashMap;
44

55
use oxc_diagnostics::{
6-
reporter::{DiagnosticReporter, DiagnosticResult, Info},
76
Error, Severity,
7+
reporter::{DiagnosticReporter, DiagnosticResult, Info},
88
};
99

10-
use crate::output_formatter::{xml_utils::xml_escape, InternalFormatter};
10+
use crate::output_formatter::{InternalFormatter, xml_utils::xml_escape};
1111

1212
#[derive(Debug, Default)]
1313
pub struct CheckStyleOutputFormatter;
@@ -69,8 +69,8 @@ fn format_checkstyle(diagnostics: &[Error]) -> String {
6969
#[cfg(test)]
7070
mod test {
7171
use oxc_diagnostics::{
72-
reporter::{DiagnosticReporter, DiagnosticResult},
7372
NamedSource, OxcDiagnostic,
73+
reporter::{DiagnosticReporter, DiagnosticResult},
7474
};
7575
use oxc_span::Span;
7676

@@ -93,6 +93,9 @@ mod test {
9393
let second_result = reporter.finish(&DiagnosticResult::default());
9494

9595
assert!(second_result.is_some());
96-
assert_eq!(second_result.unwrap(), "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle version=\"4.3\"><file name=\"file://test.ts\"><error line=\"1\" column=\"1\" severity=\"warning\" message=\"error message\" source=\"\" /></file></checkstyle>\n");
96+
assert_eq!(
97+
second_result.unwrap(),
98+
"<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle version=\"4.3\"><file name=\"file://test.ts\"><error line=\"1\" column=\"1\" severity=\"warning\" message=\"error message\" source=\"\" /></file></checkstyle>\n"
99+
);
97100
}
98101
}

apps/oxlint/src/output_formatter/default.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::time::Duration;
22

33
use crate::output_formatter::InternalFormatter;
44
use oxc_diagnostics::{
5-
reporter::{DiagnosticReporter, DiagnosticResult},
65
Error, GraphicalReportHandler,
6+
reporter::{DiagnosticReporter, DiagnosticResult},
77
};
88
use oxc_linter::table::RuleTable;
99

@@ -51,11 +51,7 @@ impl InternalFormatter for DefaultOutputFormatter {
5151
impl DefaultOutputFormatter {
5252
fn get_execution_time(duration: &Duration) -> String {
5353
let ms = duration.as_millis();
54-
if ms < 1000 {
55-
format!("{ms}ms")
56-
} else {
57-
format!("{:.1}s", duration.as_secs_f64())
58-
}
54+
if ms < 1000 { format!("{ms}ms") } else { format!("{:.1}s", duration.as_secs_f64()) }
5955
}
6056
}
6157

@@ -115,8 +111,8 @@ fn get_diagnostic_result_output(result: &DiagnosticResult) -> String {
115111
#[cfg(test)]
116112
mod test_implementation {
117113
use oxc_diagnostics::{
118-
reporter::{DiagnosticReporter, DiagnosticResult, Info},
119114
Error, GraphicalReportHandler, GraphicalTheme,
115+
reporter::{DiagnosticReporter, DiagnosticResult, Info},
120116
};
121117

122118
use crate::output_formatter::default::get_diagnostic_result_output;
@@ -155,8 +151,8 @@ mod test {
155151
use std::time::Duration;
156152

157153
use crate::output_formatter::{
158-
default::{DefaultOutputFormatter, GraphicalReporter},
159154
InternalFormatter, LintCommandInfo,
155+
default::{DefaultOutputFormatter, GraphicalReporter},
160156
};
161157
use oxc_diagnostics::reporter::{DiagnosticReporter, DiagnosticResult};
162158

0 commit comments

Comments
 (0)