mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
chore(deps): update dependency rust to v1.99.0 (#27257)
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [rust](https://redirect.github.com/rust-lang/rust) | minor | `1.98.1` → `1.99.0` | --- ### Release Notes <details> <summary>rust-lang/rust (rust)</summary> ### [`v1.99.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1990-2026-10-01) [Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.98.1...1.99.0) \========================== <a id="1.99.0-Language"></a> ## Language - [Add allow-by-default `raw_borrows_via_references` lint that checks for references that decay immediately into raw borrows](https://redirect.github.com/rust-lang/rust/pull/138230) - [Extend `unconditional_panic` lint to function calls that panic when the chunks/windows size is zero](https://redirect.github.com/rust-lang/rust/pull/153563) - [Stabilize C-variadic function definitions](https://redirect.github.com/rust-lang/rust/pull/155697) - [Stabilize the ability to use `#[unsafe(naked)]` functions to define C-variadic functions (`#![feature(c_variadic_naked_functions)]`).](https://redirect.github.com/rust-lang/rust/pull/159746) - [Trait methods are now resolved on an adjusted never type (producing a FCW)](https://redirect.github.com/rust-lang/rust/pull/156047) - [Coerce from inference variables to trait objects if the inference variable is related via subtyping to a type that is known to be `Sized`](https://redirect.github.com/rust-lang/rust/pull/157820) - [Stabilize `#[my_macro] mod foo;`](https://redirect.github.com/rust-lang/rust/pull/157857). This allows outlined modules (`mod foo;`) anywhere in the body of a custom attribute or derive macro. - [Fix the `overflowing_literals` lint with repeated negation](https://redirect.github.com/rust-lang/rust/pull/158302). For instance, it will now no longer lint on `--128_i8`, which is already detected by the `arithmetic_overflow` lint. - [Add POSIX symbols to the `invalid_runtime_symbol_definitions` and `suspicious_runtime_symbol_definitions` lints](https://redirect.github.com/rust-lang/rust/pull/158522) - [Lint unused `#[path]` attributes on inline modules](https://redirect.github.com/rust-lang/rust/pull/158835) - [Enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group](https://redirect.github.com/rust-lang/rust/pull/159179) - [Stabilize passing 128-bit integers via vector registers with `asm!` on x86](https://redirect.github.com/rust-lang/rust/pull/159525) - [Explicitly document that some allocations are allowed to grow in-place (but none are allowed to shrink)](https://redirect.github.com/rust-lang/rust/pull/159729) - We now [guarantee](https://redirect.github.com/rust-lang/rust/pull/159730) that the contents of an `UnsafeCell` can be accessed without going through `get` - [The `invalid_reference_casting` lint was adjusted accordingly](https://redirect.github.com/rust-lang/rust/pull/159960) - [Account for globally enabled target features in `global_asm!`](https://redirect.github.com/rust-lang/rust/pull/160594) - [Warn if an invalid `doc` attribute is used on a macro invocation](https://redirect.github.com/rust-lang/rust/pull/161003) <a id="1.99.0-Compiler"></a> ## Compiler - [Convert `-Ctarget-cpu` into a target-modifier for AVR, AMDGCN and NVPTX](https://redirect.github.com/rust-lang/rust/pull/150732) - [Enable `static_position_independent_executables` on all gnu targets](https://redirect.github.com/rust-lang/rust/pull/158510) - When providing a suggestion about a missing method, rustc now prefers an exactly matching name from a [doc alias attribute](https://doc.rust-lang.org/rustdoc/advanced-features.html#add-aliases-for-an-item-in-documentation-search) over a similarity search from other method names. If your new users sometimes expect a method under a different name, adding a doc alias will now help them find it via rustc suggestions, in addition to helping them find it via rustdoc search: [When suggesting method names, prefer *exact* doc aliases over similar names](https://redirect.github.com/rust-lang/rust/pull/160369) <a id="1.99.0-Platform-Support"></a> ## Platform Support - [Promote `riscv64-unknown-linux-musl` to Tier 2 with host tools](https://redirect.github.com/rust-lang/rust/pull/158766) Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support. [platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html <a id="1.99.0-Libraries"></a> ## Libraries - Iteration on `RangeInclusive` (`a..=b` ranges) is now [optimized better in some circumstances](https://redirect.github.com/rust-lang/rust/pull/155114). As a side effect of this, the behavior of `RangeInclusive` values that has already been exhausted (as an iterator) has changed. For example, the return values of `start()` and `end()` on such ranges may return different values, and using such ranges as slice indexes may have different behavior. These behaviors were not guaranteed to be stable, so these changes are considered to not be breaking changes. - [Relax `transmute_copy` to accept `?Sized` types](https://redirect.github.com/rust-lang/rust/pull/155989) - [Update `transmute_copy` to use a non-unwinding panic](https://redirect.github.com/rust-lang/rust/pull/155989) - [Don't escape U+FF9E and U+FF9F in `escape_debug_ext`](https://redirect.github.com/rust-lang/rust/pull/158057) - [Re-export `core::fmt::NumBuffer` in `alloc` (and `std`)](https://redirect.github.com/rust-lang/rust/pull/161430) <a id="1.99.0-Stabilized-APIs"></a> ## Stabilized APIs - [`IntoIterator` for `Box<[T; N]>`](https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html#impl-IntoIterator-for-Box%3C%5BT;+N%5D,+A%3E) - [`IntoIterator` for `&Box<[T; N]>`](https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html#impl-IntoIterator-for-%26Box%3C%5BT;+N%5D,+A%3E) - [`IntoIterator` for `&mut Box<[T; N]>`](https://doc.rust-lang.org/stable/std/iter/trait.IntoIterator.html#impl-IntoIterator-for-%26mut+Box%3C%5BT;+N%5D,+A%3E) - [`VecDeque::retain_back`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.retain_back) - [`core::ffi::VaList`](https://doc.rust-lang.org/stable/core/ffi/struct.VaList.html) - [`Box::into_non_null`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.into_non_null) - [`Box::from_non_null`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.from_non_null) - [`Vec::into_parts`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.into_parts) - [`Vec::from_parts`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.from_parts) - [`core::mem::size_of_val_raw`](https://doc.rust-lang.org/stable/core/mem/fn.size_of_val_raw.html) - [`core::mem::align_of_val_raw`](https://doc.rust-lang.org/stable/core/mem/fn.align_of_val_raw.html) - [`core::alloc::Layout::for_value_raw`](https://doc.rust-lang.org/stable/core/alloc/struct.Layout.html#method.for_value_raw) - [`String::from_utf8_lossy_owned`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf8_lossy_owned) - [`string::FromUtf8Error::into_utf8_lossy`](https://doc.rust-lang.org/stable/std/string/struct.FromUtf8Error.html#method.into_utf8_lossy) - [`FusedIterator for StepBy<I>`](https://doc.rust-lang.org/stable/std/iter/struct.StepBy.html#impl-FusedIterator-for-StepBy%3CI%3E) - [`std::fs::set_times`](https://doc.rust-lang.org/stable/std/fs/fn.set_times.html) - [`std::fs::set_times_nofollow`](https://doc.rust-lang.org/stable/std/fs/fn.set_times_nofollow.html) <a id="1.99.0-Cargo"></a> ## Cargo - Add a new built-in profile `debug`. This is a preparation for transitioning the `dev` profile away from debugging to give a saner default for faster development iterations. Currently there is no difference between `dev` and `debug` profiles. [docs](https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#debug-1) [#​17214](https://redirect.github.com/rust-lang/cargo/pull/17214) - Workspace members on edition 2024 or later can now override an inherited workspace dependency's `default-features` field. For example, `serde = { workspace = true, default-features = false }` now turns off default features even when the workspace definition enables them. On earlier editions, `default-features = false` is ignored with a warning. ([RFC 3945](https://redirect.github.com/rust-lang/rfcs/pull/3945)) [#​17126](https://redirect.github.com/rust-lang/cargo/pull/17126) See also the [full Cargo changelog](https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-199-2026-10-01) <a id="1.99.0-Rustdoc"></a> ## Rustdoc - [Add new `unused_footnote_definition` rustdoc lint](https://redirect.github.com/rust-lang/rust/pull/137858) - Smarter filtering of trait impls yields performance improvements of 20% on average and up to 40% on some real-world crates. ([1](https://redirect.github.com/rust-lang/rust/pull/159623), [2](https://redirect.github.com/rust-lang/rust/pull/159721), [3](https://redirect.github.com/rust-lang/rust/pull/159779), [4](https://redirect.github.com/rust-lang/rust/pull/159854), [5](https://redirect.github.com/rust-lang/rust/pull/159091)) <a id="1.99.0-Compatibility-Notes"></a> ## Compatibility Notes - [Fully deprecate the legacy integral modules](https://redirect.github.com/rust-lang/rust/pull/146882). For example, `std::i32::MAX` should be accessed via `i32::MAX` instead. - [Upgrade `no_mangle_generic_items` into hard error](https://redirect.github.com/rust-lang/rust/pull/154585) - [The `Pin::new_unchecked` has had its safety invariants changed slightly](https://redirect.github.com/rust-lang/rust/pull/156935) - [Do not promote references to extern statics](https://redirect.github.com/rust-lang/rust/pull/157641) - [Ensure that the inferred types of `let` patterns typecheck](https://redirect.github.com/rust-lang/rust/pull/157841) - [hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`](https://redirect.github.com/rust-lang/rust/pull/158247) - [Fixed a bug where `#[repr(simd)]` was accidentally allowed on macro invocations on stable Rust](https://redirect.github.com/rust-lang/rust/pull/158523) - [Abort const-eval when there are generics in the type of the value being produced](https://redirect.github.com/rust-lang/rust/pull/159504) - [Attributes not applying to anything are now an error in code blocks in doc comments](https://redirect.github.com/rust-lang/rust/pull/159849) - [`Box::leak`: tell people to avoid unleaking](https://redirect.github.com/rust-lang/rust/pull/160323) - [PowerPC inline ASM: Fix scalar floats being in the wrong vector lane on little endian](https://redirect.github.com/rust-lang/rust/pull/160441) - [Do not take `doc(cfg())` into account when filtering doctests](https://redirect.github.com/rust-lang/rust/pull/159014) - [Infer anonymous lifetimes in the types of associated consts as `'static`](https://redirect.github.com/rust-lang/rust/pull/156508) - Macros that expand to a semicolon now produce a warning lint (`semicolon_in_expressions_from_non_local_macros`) even when the macro comes from another crate. Previously, such warnings only appeared for macros from the same crate, to avoid showing warnings that can't be fixed locally; however, this masked problems, as integration tests from the crate providing the macro get compiled as a separate crate, so tests often wouldn't reveal this issue. If you encounter a lint like this, please make sure to report it to the crate providing the macro so they can fix it; don't just silence it in your own crate. - [`semicolon_in_expressions_from_macros`: Lint on non-local macros too](https://redirect.github.com/rust-lang/rust/pull/159222) - [Split non-local `semicolon_in_expressions_from_macros` into a separate lint](https://redirect.github.com/rust-lang/rust/pull/159700) - In Cargo, incremental compilation is now disabled by default when running in CI. CI is detected via the `CI` environment variable. [#​17220](https://redirect.github.com/rust-lang/cargo/pull/17220) <a id="1.99.0-Internal-Changes"></a> ## Internal Changes These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools. - [Update to LLVM 23](https://redirect.github.com/rust-lang/rust/pull/158734) </details> --- ### Configuration 📅 **Schedule**: (in timezone Asia/Shanghai) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMjUuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjEyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cameron Clark <cameron.clark@hey.com>
This commit is contained in:
1 parent
c399fb24f9
commit
21c25dc931
26 files changed
+93
-95
No files matched your search
@@ -44,7 +44,7 @@ mod ignore_options {
|
||||
let options = get_ignore_options(".");
|
||||
assert_eq!(options.ignore_path, OsString::from(".eslintignore"));
|
||||
assert!(!options.no_ignore);
|
||||
assert!(options.ignore_pattern.is_empty());
|
||||
assert_eq!(options.ignore_pattern.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -711,7 +711,7 @@ mod lint_options {
|
||||
fn format() {
|
||||
let options = get_lint_options("-f json");
|
||||
assert_eq!(options.output_options.format, OutputFormat::Json);
|
||||
assert!(options.paths.is_empty());
|
||||
assert_eq!(options.paths.len(), 0);
|
||||
|
||||
let options = get_lint_options("-f agent");
|
||||
assert_eq!(options.output_options.format, OutputFormat::Agent);
|
||||
|
||||
@@ -980,14 +980,14 @@ mod tests {
|
||||
|
||||
stack.pop();
|
||||
assert_eq!(drops(), &[30]);
|
||||
assert!(drops().is_empty());
|
||||
assert_eq!(drops(), []);
|
||||
|
||||
stack.push(Droppy(31));
|
||||
stack.push(Droppy(40));
|
||||
stack.push(Droppy(50));
|
||||
assert_eq!(stack.len(), 5);
|
||||
assert_eq!(stack.capacity(), 8);
|
||||
assert!(drops().is_empty());
|
||||
assert_eq!(drops(), []);
|
||||
}
|
||||
|
||||
assert_eq!(drops(), &[10, 20, 31, 40, 50]);
|
||||
|
||||
@@ -833,14 +833,14 @@ mod tests {
|
||||
|
||||
stack.pop();
|
||||
assert_eq!(drops(), &[30]);
|
||||
assert!(drops().is_empty());
|
||||
assert_eq!(drops(), []);
|
||||
|
||||
stack.push(Droppy(31));
|
||||
stack.push(Droppy(40));
|
||||
stack.push(Droppy(50));
|
||||
assert_eq!(stack.len(), 5);
|
||||
assert_eq!(stack.capacity(), 8);
|
||||
assert!(drops().is_empty());
|
||||
assert_eq!(drops(), []);
|
||||
}
|
||||
|
||||
assert_eq!(drops(), &[10, 20, 31, 40, 50]);
|
||||
|
||||
@@ -79,7 +79,6 @@ fn is_str_white_space_char(c: char) -> bool {
|
||||
mod tests {
|
||||
use super::StringToNumber;
|
||||
|
||||
#[expect(clippy::float_cmp)]
|
||||
#[test]
|
||||
fn trims_ecmascript_whitespace_from_both_ends() {
|
||||
const WHITESPACE: &str = "\u{0009}\u{000B}\u{000C}\u{0020}\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{202F}\u{205F}\u{3000}\u{FEFF}\u{000A}\u{000D}\u{2028}\u{2029}";
|
||||
|
||||
@@ -48,7 +48,6 @@ pub enum ToIntegerOrInfinityResult {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[expect(clippy::float_cmp)]
|
||||
#[test]
|
||||
fn test_to_integer_or_infinity() {
|
||||
assert_eq!(f64::NAN.to_integer_or_infinity(), 0.0);
|
||||
|
||||
@@ -64,6 +64,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::mut_mut)]
|
||||
#[test]
|
||||
fn serialize_mut_ref() {
|
||||
let cases = [(&mut "foo", r#""foo""#), (&mut &mut "bar", r#""bar""#)];
|
||||
|
||||
@@ -558,7 +558,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_wrap_empty_text() {
|
||||
let result = wrap_text("", 80, 0, false);
|
||||
assert!(result.is_empty());
|
||||
assert_eq!(result, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1120,11 +1120,11 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> {
|
||||
let saved_indent_stack = std::mem::take(&mut printer.state.fits_indent_stack);
|
||||
let saved_stack_tem_indent = std::mem::take(&mut printer.state.fits_stack_tem_indent);
|
||||
let saved_root_indent_stack = std::mem::take(&mut printer.state.fits_root_indent_stack);
|
||||
debug_assert!(saved_stack.is_empty());
|
||||
debug_assert!(saved_queue.is_empty());
|
||||
debug_assert!(saved_indent_stack.is_empty());
|
||||
debug_assert!(saved_stack_tem_indent.is_empty());
|
||||
debug_assert!(saved_root_indent_stack.is_empty());
|
||||
debug_assert_eq!(saved_stack.len(), 0);
|
||||
debug_assert_eq!(saved_queue.len(), 0);
|
||||
debug_assert_eq!(saved_indent_stack.len(), 0);
|
||||
debug_assert_eq!(saved_stack_tem_indent.len(), 0);
|
||||
debug_assert_eq!(saved_root_indent_stack.len(), 0);
|
||||
|
||||
let fits_queue = FitsQueue::new(print_queue, saved_queue);
|
||||
let fits_stack = FitsCallStack::new(print_stack, saved_stack);
|
||||
|
||||
@@ -99,10 +99,10 @@ fn cook_block_string_lines(value: &str) -> Vec<&str> {
|
||||
|
||||
// Strip leading/trailing blank lines.
|
||||
let is_blank = |line: &&str| line.bytes().all(|b| b == b' ' || b == b'\t');
|
||||
while lines.first().is_some_and(&is_blank) {
|
||||
while lines.first().is_some_and(is_blank) {
|
||||
lines.remove(0);
|
||||
}
|
||||
while lines.last().is_some_and(&is_blank) {
|
||||
while lines.last().is_some_and(is_blank) {
|
||||
lines.pop();
|
||||
}
|
||||
lines
|
||||
|
||||
@@ -417,7 +417,7 @@ impl TestServer {
|
||||
let params: PublishDiagnosticsParams =
|
||||
serde_json::from_value(publish_diagnostics.params().unwrap().clone()).unwrap();
|
||||
assert_eq!(params.uri, uri);
|
||||
assert!(params.diagnostics.is_empty());
|
||||
assert_eq!(params.diagnostics, []);
|
||||
}
|
||||
|
||||
let shutdown_result = self.recv_response().await;
|
||||
|
||||
@@ -843,7 +843,7 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(no_diagnostics.is_empty());
|
||||
assert_eq!(no_diagnostics, []);
|
||||
|
||||
let error = worker
|
||||
.run_diagnostic(TextDocument::new(
|
||||
@@ -907,7 +907,7 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(no_diagnostics.is_empty());
|
||||
assert_eq!(no_diagnostics, []);
|
||||
|
||||
let error = worker
|
||||
.run_diagnostic_on_change(TextDocument::new(
|
||||
@@ -970,7 +970,7 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(no_diagnostics.is_empty());
|
||||
assert_eq!(no_diagnostics, []);
|
||||
|
||||
let error = worker
|
||||
.run_diagnostic_on_save(TextDocument::new(
|
||||
|
||||
@@ -57,7 +57,7 @@ fn unterminated_template() {
|
||||
assert_eq!(codes("x = `a${b}c"), [DiagCode::UnterminatedTemplate]);
|
||||
// An open substitution at EOF is a parser-level error; oxc_parser's
|
||||
// lexer is also silent here.
|
||||
assert!(codes("x = `a${b").is_empty());
|
||||
assert_eq!(codes("x = `a${b"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -77,7 +77,7 @@ fn unterminated_in_jsx_path() {
|
||||
assert_eq!(codes_jsx("const x = `abc"), [DiagCode::UnterminatedTemplate]);
|
||||
assert_eq!(codes_jsx("const x = 1 /* abc"), [DiagCode::UnterminatedBlockComment]);
|
||||
assert_eq!(codes_jsx("const x = /abc"), [DiagCode::UnterminatedRegexp]);
|
||||
assert!(codes_jsx("const el = <div className='x'>hi</div>;").is_empty());
|
||||
assert_eq!(codes_jsx("const el = <div className='x'>hi</div>;"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -199,20 +199,20 @@ fn valid_numeric_adjacency_never_flagged() {
|
||||
assert!(codes(src).is_empty(), "false positive on `{src}`");
|
||||
}
|
||||
// JSX text and expression containers must not glue text as numbers.
|
||||
assert!(codes_jsx("const el = <div>1.5n</div>;").is_empty());
|
||||
assert!(codes_jsx("const el = <div a=\"3in\">{1.5}</div>;").is_empty());
|
||||
assert_eq!(codes_jsx("const el = <div>1.5n</div>;"), []);
|
||||
assert_eq!(codes_jsx("const el = <div a=\"3in\">{1.5}</div>;"), []);
|
||||
// The content-blind TSX type-arg skip must not leak numeric diagnostics
|
||||
// from digit-letter adjacency inside a string type-arg.
|
||||
assert!(codes_tsx("const el = <Foo<\"3px\"> x={1}/>;").is_empty());
|
||||
assert!(codes_tsx("const el = <Foo<1.5, \"2xl\"> y/>;").is_empty());
|
||||
assert_eq!(codes_tsx("const el = <Foo<\"3px\"> x={1}/>;"), []);
|
||||
assert_eq!(codes_tsx("const el = <Foo<1.5, \"2xl\"> y/>;"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regex_flags() {
|
||||
assert_eq!(codes("r = /x/q;"), [DiagCode::InvalidRegexpFlag]); // unknown flag
|
||||
assert_eq!(codes("r = /x/gg;"), [DiagCode::DuplicateRegexpFlag]); // duplicate
|
||||
assert!(codes("r = /x/gimsuydv;").is_empty()); // all valid flags, once each
|
||||
assert!(codes("r = /x/;").is_empty()); // no flags
|
||||
assert_eq!(codes("r = /x/gimsuydv;"), []); // all valid flags, once each
|
||||
assert_eq!(codes("r = /x/;"), []); // no flags
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -227,9 +227,9 @@ fn line_terminator_in_string() {
|
||||
assert_eq!(codes("x = 'a\nb';"), [DiagCode::LineTerminatorInString]);
|
||||
assert_eq!(codes("x = 'a\r\nb';"), [DiagCode::LineTerminatorInString]);
|
||||
// escaped line terminators are legal continuations, CRLF as one sequence
|
||||
assert!(codes("x = 'a\\\nb';").is_empty());
|
||||
assert!(codes("x = 'a\\\rb';").is_empty());
|
||||
assert!(codes("x = 'a\\\r\nb';").is_empty());
|
||||
assert_eq!(codes("x = 'a\\\nb';"), []);
|
||||
assert_eq!(codes("x = 'a\\\rb';"), []);
|
||||
assert_eq!(codes("x = 'a\\\r\nb';"), []);
|
||||
// escaped backslash followed by a raw terminator is invalid
|
||||
assert_eq!(codes("x = 'a\\\\\r\nb';"), [DiagCode::LineTerminatorInString]);
|
||||
|
||||
@@ -265,9 +265,9 @@ fn line_terminator_in_regexp() {
|
||||
// newline then EOF: the parser stops at the terminator first
|
||||
assert_eq!(codes("x = /abc\n"), [DiagCode::LineTerminatorInRegexp]);
|
||||
assert_eq!(codes_jsx("x = /a\nb/;"), [DiagCode::LineTerminatorInRegexp]);
|
||||
assert!(codes("x = /a\\nb/g;").is_empty()); // `\n` as two chars
|
||||
assert!(codes("x = a / b\nc / d;").is_empty()); // division across lines
|
||||
assert!(codes("x = /a[b-z]+/;").is_empty());
|
||||
assert_eq!(codes("x = /a\\nb/g;"), []); // `\n` as two chars
|
||||
assert_eq!(codes("x = a / b\nc / d;"), []); // division across lines
|
||||
assert_eq!(codes("x = /a[b-z]+/;"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -327,33 +327,33 @@ fn valid_escapes_never_flagged() {
|
||||
] {
|
||||
assert!(codes(&format!("x = {s};")).is_empty(), "false positive on `{s}`");
|
||||
}
|
||||
assert!(codes("x = 'a\\\nb';").is_empty()); // LF line continuation
|
||||
assert!(codes("x = 'a\\\r\nb';").is_empty()); // CRLF line continuation
|
||||
assert_eq!(codes("x = 'a\\\nb';"), []); // LF line continuation
|
||||
assert_eq!(codes("x = 'a\\\r\nb';"), []); // CRLF line continuation
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn template_invalid_escapes_stay_silent() {
|
||||
// An invalid escape in a tagged template is legal, and tagged-ness is
|
||||
// parser context; oxc_parser's lexer is also silent here.
|
||||
assert!(codes(r"t = `\uZZZZ`;").is_empty());
|
||||
assert!(codes(r"t = `\u{110000}`;").is_empty());
|
||||
assert!(codes(r"t = `\xGG`;").is_empty());
|
||||
assert!(codes(r"t = tag`\uZZ`;").is_empty());
|
||||
assert!(codes(r"t = `a${b}\uZZ`;").is_empty()); // middle/tail segments
|
||||
assert_eq!(codes(r"t = `\uZZZZ`;"), []);
|
||||
assert_eq!(codes(r"t = `\u{110000}`;"), []);
|
||||
assert_eq!(codes(r"t = `\xGG`;"), []);
|
||||
assert_eq!(codes(r"t = tag`\uZZ`;"), []);
|
||||
assert_eq!(codes(r"t = `a${b}\uZZ`;"), []); // middle/tail segments
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_unicode_escape_jsx_path() {
|
||||
assert_eq!(codes_jsx(r#"const x = "\uZZZZ";"#), [DiagCode::InvalidUnicodeEscape]);
|
||||
// JSX attribute strings have no escapes - the value is verbatim source.
|
||||
assert!(codes_jsx(r#"const el = <div a="\uZZ">x</div>;"#).is_empty());
|
||||
assert_eq!(codes_jsx(r#"const el = <div a="\uZZ">x</div>;"#), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_input_emits_nothing() {
|
||||
assert!(codes("let x = 'abc';").is_empty());
|
||||
assert!(codes("const t = `a${b}c`; /* ok */ // ok\nlet r = /x/g;").is_empty());
|
||||
assert!(codes("function f(){ return 1 / 2; }").is_empty());
|
||||
assert_eq!(codes("let x = 'abc';"), []);
|
||||
assert_eq!(codes("const t = `a${b}c`; /* ok */ // ok\nlet r = /x/g;"), []);
|
||||
assert_eq!(codes("function f(){ return 1 / 2; }"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -523,7 +523,7 @@ fn invalid_identifier_escape_payload() {
|
||||
#[test]
|
||||
fn invalid_identifier_escape_jsx_path() {
|
||||
assert!(codes_jsx(r"const \u{110000} = 1").contains(&DiagCode::InvalidIdentifierEscape));
|
||||
assert!(codes_jsx(r"const el = <div>a\b</div>;").is_empty()); // JSX text
|
||||
assert_eq!(codes_jsx(r"const el = <div>a\b</div>;"), []); // JSX text
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -580,8 +580,8 @@ fn unicode_ident_after_number() {
|
||||
assert_eq!((d[0].off, d[0].len), (7, 5)); // `abc` + 2-byte pi
|
||||
assert_eq!(codes("x = 1.5π;"), [DiagCode::InvalidNumericLiteral]);
|
||||
// unicode whitespace after a number stays clean
|
||||
assert!(codes("x = 1\u{a0}+ 2;").is_empty());
|
||||
assert!(codes("x = 1\u{2028}y = 2;").is_empty());
|
||||
assert_eq!(codes("x = 1\u{a0}+ 2;"), []);
|
||||
assert_eq!(codes("x = 1\u{2028}y = 2;"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -594,7 +594,7 @@ fn escaped_char_not_identifier() {
|
||||
let d = diags(r"var \u{30}x = 1");
|
||||
assert_eq!((d[0].off, d[0].len, d[0].code), (10, 0, DiagCode::UnexpectedCharacter));
|
||||
// mid-identifier escapes use is_identifier_part: digits fine there,
|
||||
assert!(codes(r"let a\u{30}b = 1;").is_empty());
|
||||
assert_eq!(codes(r"let a\u{30}b = 1;"), []);
|
||||
// whitespace not
|
||||
assert_eq!(codes(r"let a\u0020b = 1;"), [DiagCode::UnexpectedCharacter]);
|
||||
for src in [r"let \u0041 = 1;", r"let \u{24} = 1;", r"let a\u{5F}b = 1;"] {
|
||||
@@ -613,11 +613,11 @@ fn line_separator_in_regexp() {
|
||||
let d = diags("x = /a\\\u{2028}b/;"); // escaped LS: still invalid
|
||||
assert_eq!(d.len(), 1);
|
||||
assert_eq!((d[0].off, d[0].len), (4, 6));
|
||||
assert!(codes("x = /a\u{2014}b/;").is_empty()); // other E2-led chars are fine
|
||||
assert!(codes("x = /a\u{2713}b/u;").is_empty());
|
||||
assert!(codes(r"x = /a\u2028b/;").is_empty()); // escape text, no raw LS
|
||||
assert!(codes("s = '\u{2028}';").is_empty()); // legal in strings/templates
|
||||
assert!(codes("t = `\u{2028}`;").is_empty());
|
||||
assert_eq!(codes("x = /a\u{2014}b/;"), []); // other E2-led chars are fine
|
||||
assert_eq!(codes("x = /a\u{2713}b/u;"), []);
|
||||
assert_eq!(codes(r"x = /a\u2028b/;"), []); // escape text, no raw LS
|
||||
assert_eq!(codes("s = '\u{2028}';"), []); // legal in strings/templates
|
||||
assert_eq!(codes("t = `\u{2028}`;"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -632,8 +632,8 @@ fn misplaced_hash() {
|
||||
assert_eq!((d[0].off, d[0].len, d[0].code), (5, 1, DiagCode::UnexpectedCharacter));
|
||||
let d = diags("x = #"); // `#` at EOF: empty span at n
|
||||
assert_eq!((d[0].off, d[0].len), (5, 0));
|
||||
assert!(codes("#!/usr/bin/env node\nlet x = 1;").is_empty());
|
||||
assert!(codes("class A { #x = 1; m() { return this.#x; } }").is_empty());
|
||||
assert_eq!(codes("#!/usr/bin/env node\nlet x = 1;"), []);
|
||||
assert_eq!(codes("class A { #x = 1; m() { return this.#x; } }"), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -657,10 +657,10 @@ fn template_cooked_invalid_marker() {
|
||||
assert_eq!(get("t = `abc`;"), [false]); // no escapes
|
||||
assert_eq!(get(r"t = `a${b}c`;"), [false, false]); // head + tail
|
||||
// still zero diagnostics, matching oxc_parser's silent lexer
|
||||
assert!(codes(r"t = `\101`;").is_empty());
|
||||
assert!(codes(r"t = `\uZZ`;").is_empty());
|
||||
assert_eq!(codes(r"t = `\101`;"), []);
|
||||
assert_eq!(codes(r"t = `\uZZ`;"), []);
|
||||
// strings are untouched by the marker path
|
||||
assert!(codes(r#"s = "\8";"#).is_empty());
|
||||
assert_eq!(codes(r#"s = "\8";"#), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -35,7 +35,7 @@ fn script_html_open_comment_anywhere() {
|
||||
!ks.contains(&TokenKind::Lt) && !ks.contains(&TokenKind::Bang),
|
||||
"script comment: {ks:?}"
|
||||
);
|
||||
assert!(diag_codes("x <!-- y\nz;", false).is_empty());
|
||||
assert_eq!(diag_codes("x <!-- y\nz;", false), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -60,7 +60,7 @@ fn module_html_open_comment_mid_expression_is_lt() {
|
||||
assert!(ks.contains(&TokenKind::Lt), "expected `<` operator: {ks:?}");
|
||||
assert!(ks.contains(&TokenKind::Bang), "expected `!` operator: {ks:?}");
|
||||
assert!(ks.contains(&TokenKind::MinusMinus), "expected `--` operator: {ks:?}");
|
||||
assert!(diag_codes("x <!-- y;", true).is_empty());
|
||||
assert_eq!(diag_codes("x <!-- y;", true), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -82,7 +82,7 @@ fn module_html_close_comment_is_operators() {
|
||||
let module = kinds_of(src, true);
|
||||
assert!(module.contains(&TokenKind::MinusMinus), "expected `--`: {module:?}");
|
||||
assert!(module.contains(&TokenKind::Gt), "expected `>`: {module:?}");
|
||||
assert!(diag_codes(src, true).is_empty());
|
||||
assert_eq!(diag_codes(src, true), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1584,7 +1584,7 @@ mod tests {
|
||||
|
||||
let unused = directives.unused_enable_comments();
|
||||
|
||||
assert!(unused.is_empty());
|
||||
assert_eq!(unused, []);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1611,7 +1611,7 @@ mod tests {
|
||||
|
||||
assert!(!directives.contains("no-console", Span::sized(console_start, 11)));
|
||||
assert!(directives.contains("no-debugger", Span::sized(debugger_start, 8)));
|
||||
assert!(directives.unused_enable_comments().is_empty());
|
||||
assert_eq!(directives.unused_enable_comments(), []);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1734,7 +1734,7 @@ mod tests {
|
||||
is_next_line: false,
|
||||
});
|
||||
|
||||
assert!(directives.collect_unused_disable_comments().is_empty());
|
||||
assert_eq!(directives.collect_unused_disable_comments(), []);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ struct RuleBuckets {
|
||||
|
||||
impl RuleBuckets {
|
||||
fn clear(&mut self) {
|
||||
for bucket in self.by_type.iter_mut() {
|
||||
for bucket in &mut self.by_type {
|
||||
bucket.clear();
|
||||
}
|
||||
self.any_type.clear();
|
||||
|
||||
@@ -222,7 +222,7 @@ mod test {
|
||||
|
||||
let sources = parse_astro(source_text);
|
||||
assert_eq!(sources.len(), 2);
|
||||
assert!(sources[0].source_text.is_empty());
|
||||
assert_eq!(sources[0].source_text, "");
|
||||
assert_eq!(sources[0].start, 102);
|
||||
assert_eq!(sources[1].source_text.trim(), r#"console.log("Hi");"#);
|
||||
assert_eq!(sources[1].start, 129);
|
||||
@@ -256,7 +256,7 @@ mod test {
|
||||
|
||||
let sources = parse_astro(source_text);
|
||||
assert_eq!(sources.len(), 2);
|
||||
assert!(sources[0].source_text.is_empty());
|
||||
assert_eq!(sources[0].source_text, "");
|
||||
assert_eq!(sources[0].start, 104);
|
||||
assert_eq!(sources[1].source_text.trim(), r#"console.log("Hi");"#);
|
||||
assert_eq!(sources[1].start, 122);
|
||||
@@ -276,7 +276,7 @@ mod test {
|
||||
|
||||
let sources = parse_astro(source_text);
|
||||
assert_eq!(sources.len(), 2);
|
||||
assert!(sources[0].source_text.is_empty());
|
||||
assert_eq!(sources[0].source_text, "");
|
||||
assert_eq!(sources[1].source_text.trim(), r#"console.log("Hi");"#);
|
||||
}
|
||||
|
||||
|
||||
@@ -686,7 +686,7 @@ mod test {
|
||||
);
|
||||
// will panic if provided invalid markdown
|
||||
let html = to_html_with_options(rule.documentation().unwrap(), &options).unwrap();
|
||||
assert!(!html.is_empty());
|
||||
assert_ne!(html, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ impl Rule for NoEmptyFunction {
|
||||
struct ViolationInfo<'a>(pub Option<(&'static str, Option<Cow<'a, str>>)>);
|
||||
impl<'a> From<(&'static str, Option<Cow<'a, str>>)> for ViolationInfo<'a> {
|
||||
fn from(value: (&'static str, Option<Cow<'a, str>>)) -> Self {
|
||||
debug_assert!(!value.0.is_empty());
|
||||
debug_assert_ne!(value.0, "");
|
||||
Self(Some(value))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,14 +563,13 @@ impl<'a, 'c> ExplicitTypesChecker<'a, 'c> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
walk_js::walk_arrow_function_body(self, &arrow.body);
|
||||
}
|
||||
walk_js::walk_arrow_function_body(self, &arrow.body);
|
||||
|
||||
// AST is immutable in linter, so `unstable_address` produces stable `Address`es
|
||||
let is_hof = self.is_higher_order_function(arrow.unstable_address());
|
||||
if !is_hof && !is_allowed() {
|
||||
self.ctx.diagnostic(func_missing_return_type(span));
|
||||
}
|
||||
// AST is immutable in linter, so `unstable_address` produces stable `Address`es
|
||||
let is_hof = self.is_higher_order_function(arrow.unstable_address());
|
||||
if !is_hof && !is_allowed() {
|
||||
self.ctx.diagnostic(func_missing_return_type(span));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,11 +255,11 @@ mod test {
|
||||
let options = Options::gfm();
|
||||
for section in &table().sections {
|
||||
let rendered_table = section.render_markdown_table();
|
||||
assert!(!rendered_table.is_empty());
|
||||
assert_ne!(rendered_table, "");
|
||||
assert_eq!(rendered_table.split('\n').count(), 5 + section.rows.len());
|
||||
|
||||
let html = to_html_with_options(&rendered_table, &options).unwrap();
|
||||
assert!(!html.is_empty());
|
||||
assert_ne!(html, "");
|
||||
assert!(html.contains("<table>"));
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ mod test {
|
||||
}
|
||||
|
||||
let rendered_table = section.render_markdown_table_cli(&enabled);
|
||||
assert!(!rendered_table.is_empty());
|
||||
assert_ne!(rendered_table, "");
|
||||
// same number of lines as other renderer (header + desc + separator + rows + trailing newline)
|
||||
assert_eq!(rendered_table.split('\n').count(), 5 + section.rows.len());
|
||||
assert!(rendered_table.contains("Enabled?"));
|
||||
|
||||
@@ -1564,7 +1564,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
}
|
||||
|
||||
fn set_pure_on_call_or_new_expr(expr: &mut Expression<'a>) -> bool {
|
||||
match &mut expr.get_inner_expression_mut() {
|
||||
match expr.get_inner_expression_mut() {
|
||||
Expression::CallExpression(call_expr) => {
|
||||
call_expr.pure = true;
|
||||
true
|
||||
|
||||
@@ -69,7 +69,7 @@ fn parse_decimal(s: &str) -> f64 {
|
||||
/// `u64::MAX + 1` in decimal is 18446744073709551616 (20 chars).
|
||||
const MAX_FAST_DECIMAL_LEN: usize = 19;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
if s.len() > MAX_FAST_DECIMAL_LEN {
|
||||
return parse_decimal_slow(s);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ fn parse_decimal_with_underscores(s: &str) -> f64 {
|
||||
/// `u64::MAX + 1` in decimal is 18446744073709551616 (20 chars).
|
||||
const MAX_FAST_DECIMAL_LEN: usize = 19;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
if s.len() > MAX_FAST_DECIMAL_LEN {
|
||||
return parse_decimal_slow(&s.cow_replace('_', ""));
|
||||
}
|
||||
@@ -150,7 +150,7 @@ fn parse_binary(s: &str) -> f64 {
|
||||
/// overflow a u64, forcing us to take the slow path.
|
||||
const MAX_FAST_BINARY_LEN: usize = 64;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
debug_assert!(!s.starts_with("0b") && !s.starts_with("0B"));
|
||||
|
||||
if s.len() > MAX_FAST_BINARY_LEN {
|
||||
@@ -177,7 +177,7 @@ fn parse_binary_with_underscores(s: &str) -> f64 {
|
||||
/// overflow a u64, forcing us to take the slow path.
|
||||
const MAX_FAST_BINARY_LEN: usize = 64;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
debug_assert!(!s.starts_with("0b") && !s.starts_with("0B"));
|
||||
|
||||
if s.len() > MAX_FAST_BINARY_LEN {
|
||||
@@ -219,7 +219,7 @@ fn parse_octal(s: &str) -> f64 {
|
||||
/// Numeric strings longer than this have the chance to overflow u64.
|
||||
const MAX_FAST_OCTAL_LEN: usize = 21;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
debug_assert!(!s.starts_with("0o") && !s.starts_with("0O"));
|
||||
if s.len() > MAX_FAST_OCTAL_LEN {
|
||||
return parse_octal_slow(s);
|
||||
@@ -245,7 +245,7 @@ fn parse_octal_with_underscores(s: &str) -> f64 {
|
||||
/// Numeric strings longer than this have the chance to overflow u64.
|
||||
const MAX_FAST_OCTAL_LEN: usize = 21;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
debug_assert!(!s.starts_with("0o") && !s.starts_with("0O"));
|
||||
if s.len() > MAX_FAST_OCTAL_LEN {
|
||||
return parse_octal_with_underscores_slow(s);
|
||||
@@ -298,7 +298,7 @@ fn parse_hex(s: &str) -> f64 {
|
||||
/// Hex strings longer than this have the chance to overflow u64.
|
||||
const MAX_FAST_HEX_LEN: usize = 16;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
debug_assert!(!s.starts_with("0x"));
|
||||
|
||||
if s.len() > MAX_FAST_HEX_LEN {
|
||||
@@ -325,7 +325,7 @@ fn parse_hex_with_underscores(s: &str) -> f64 {
|
||||
/// Hex strings longer than this have the chance to overflow u64.
|
||||
const MAX_FAST_HEX_LEN: usize = 16;
|
||||
|
||||
debug_assert!(!s.is_empty());
|
||||
debug_assert_ne!(s, "");
|
||||
debug_assert!(!s.starts_with("0x"));
|
||||
|
||||
if s.len() > MAX_FAST_HEX_LEN {
|
||||
|
||||
@@ -233,7 +233,7 @@ impl ReplaceGlobalDefinesConfig {
|
||||
|
||||
let parts: Vec<&str> = key.split('.').collect();
|
||||
|
||||
assert!(!parts.is_empty());
|
||||
assert_ne!(parts.len(), 0);
|
||||
|
||||
if parts.len() == 1 {
|
||||
if !is_identifier_name(parts[0]) {
|
||||
@@ -781,7 +781,7 @@ impl<'a> ReplaceGlobalDefines<'a> {
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
debug_assert!(!meta_define.parts.is_empty());
|
||||
debug_assert_ne!(meta_define.parts.len(), 0);
|
||||
|
||||
let mut current_part_member_expression = Some(member);
|
||||
let mut cur_part_name: &str = &member.property.name;
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.98.1"
|
||||
channel = "1.99.0"
|
||||
profile = "default"
|
||||
@@ -2016,7 +2016,7 @@ mod tests {
|
||||
assert!(res.is_some());
|
||||
let (key, reason) = res.unwrap();
|
||||
assert_eq!(key, "eslint/no-dupe-args");
|
||||
assert!(!reason.is_empty());
|
||||
assert_ne!(reason, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2032,7 +2032,7 @@ mod tests {
|
||||
assert!(res.is_some());
|
||||
let (key, reason) = res.unwrap();
|
||||
assert_eq!(key, "n/no-hide-core-modules");
|
||||
assert!(!reason.is_empty());
|
||||
assert_ne!(reason, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user