Commit Graph

124 Commits

Author SHA1 Message Date
Dunqing c3dedc9b0c fix(semantic): skip function body bindings in parameters (#26099)
Function parameters, TypeScript signatures, and function bodies currently share one Oxc semantic scope. A reference in a parameter can therefore bind to a declaration inside the body, even though JavaScript does not make body declarations visible there. Rolldown may then treat a global as local, skip a configured define, or remove live code.

## Example

```js
export function load(value = typeof window !== "undefined") {
  var window;
  return value;
}
```

The body `var window` is not visible to the default value. Before this change, Oxc resolved `window` in the default value to that body declaration. It should remain a global reference.

The workaround resolves parameter and signature references before visiting the body, while only parameter bindings are present. If a reference is still unresolved, its `lookup_scope_id` advances to the function's parent. Final resolution resumes there, so declarations added while visiting the body are skipped. References created in the body still begin at the function scope and resolve normally.

```text
Before: parameter reference -> completed function scope -> body binding (wrong)

After:  parameter reference -> parameter bindings -> parent scopes
        body reference      -> completed function scope -> parent scopes
```

Parameter decorators already begin in the enclosing class scope, so they are left for normal final resolution. This emulates separate parameter and body scopes until https://github.com/oxc-project/backlog/issues/176 is implemented.

The corrected semantic data also exposes the transformer case covered by #26105.

Verified with semantic and transformer-plugin tests, Clippy, coverage, allocation snapshots, and diff checks. `just ready` completed workspace checks but stopped at a codegen snapshot recorded with Node.js v26.5.0; the local version is v25.8.1.

Closes #20427
Closes #22783

Downstream reports:

- https://github.com/rolldown/rolldown/issues/10722
- https://github.com/rolldown/rolldown/issues/10779

AI assistance: OpenAI Codex was used to investigate, implement, and test this change. The contributor is responsible for the submitted change.
2026-08-27 17:23:18 +00:00
camc314 059784d96b fix(semantic): respect shadowed Infinity and NaN in enum evaluation (#25604)
## Summary

Fix enum evaluation to resolve identifiers before treating `Infinity` and `NaN` as unbound globals.
2026-08-14 02:36:24 +00:00
camc314 0c9b980cb1 fix(semantic): report module declaration diagnostics (#25285)
## Summary

- report TS1234 for function-local ambient module declarations
- preserve TS1235 for function-local namespace and internal module declarations
- report TS2435 for ambient modules nested in namespaces while allowing module augmentation inside ambient external modules

## Babel Conformance Snapshot Parse Failure

This intentionally introduces one known Babel conformance false positive: `typescript/scope/redeclaration-in-nested-module/input.ts`. The Babel harness supplies `sourceType: "module"`, so Oxc reports TS2435 for its nested ambient module. This affects one unique fixture in both the parser and semantic Babel summaries. This change aligns with TS, and TS expects this error.
2026-08-04 15:06:10 +00:00
camc314 c917f204a7 feat(ast)!: introduce ArrowFunctionBody enum (#24987)
## Summary

- Introduces `ArrowFunctionBody` to represent concise expression and block bodies explicitly.
- Removes the `ArrowFunctionExpression::expression` boolean.
- Makes invalid arrow body combinations unrepresentable.

## Breaking Change

The Rust AST changes from:

```rust
pub struct ArrowFunctionExpression<'a> {
    pub expression: bool,
    pub body: Box<'a, FunctionBody<'a>>,
}
```

to:

```rust
pub enum ArrowFunctionBody<'a> {
    FunctionBody(Box<'a, FunctionBody<'a>>) = 64,
    INHERIT(Expression<'a>),
}

pub struct ArrowFunctionExpression<'a> {
    pub body: ArrowFunctionBody<'a>,
}
```

Concise arrow bodies are now stored directly as expressions instead of synthetic `FunctionBody` and `ExpressionStatement` nodes. Block bodies continue to use `FunctionBody`.

## Why?

The previous representation required consumers to maintain this implicit invariant:

```text
expression == true
→ no directives
→ exactly one statement
→ that statement is an ExpressionStatement
```

Invalid combinations could cause panics, skipped work, or fallback behavior. The enum encodes the grammar directly and makes those invalid states unrepresentable.

Concise expressions also now have `ArrowFunctionExpression` as their direct traversal ancestor, without synthetic `FunctionBody` or `ExpressionStatement` nodes.

## How to migrate

Use the arrow body accessors or match on `ArrowFunctionBody` rather than inspecting `expression` and synthetic statements.

Common field migrations:

| Previous representation | New representation |
| --- | --- |
| `arrow.expression` | `arrow.is_expression()` |
| `arrow.get_expression()` | `arrow.get_expression()` |
| `&arrow.body.statements` | `arrow.get_function_body().map(\|body\| &body.statements)` |
| `&mut arrow.body.statements` | `arrow.get_function_body_mut().map(\|body\| &mut body.statements)` |
| Synthetic expression statement in `arrow.body` | Direct `ArrowFunctionBody` expression variant |
| `arrow.body = function_body` | `arrow.body = ArrowFunctionBody::FunctionBody(function_body)` |
| Expression-to-block conversion | Create a `FunctionBody` containing a return statement |
| Block-to-expression conversion | Assign the expression directly to `arrow.body` |
| Builder `(expression, body)` arguments | Pass a single `ArrowFunctionBody` |

closes https://github.com/oxc-project/backlog/issues/211
2026-07-29 13:32:32 +00:00
camc314 869ac200a4 fix(semantic/cfg): connect for update exit to loop test (#23791)
## Summary

Correct the CFG generated for `for` statements whose update expression spans multiple basic blocks, such as conditional or logical expressions.

This addresses the malformed CFG underlying #23789.

## Problem

`update_graph_ix` identifies the entry of the update expression. After visiting the expression, `cfg.current_node_ix` identifies its exit block.

Previously, the loop backedge to the test originated from the update entry. This allowed control flow to bypass the update expression and left its exit block disconnected.

### Before

```mermaid
flowchart LR
    Test["Loop test"] -->|truthy| Body["Loop body"]
    Test -->|falsy| After["After loop"]

    Body -->|backedge| Entry["Update entry"]
    Entry --> Update["Update expression blocks"]
    Update --> Exit["Update exit"]

    Entry -->|backedge| Test
```

### After

```mermaid
flowchart LR
    Test["Loop test"] -->|truthy| Body["Loop body"]
    Test -->|falsy| After["After loop"]

    Body -->|backedge| Entry["Update entry"]
    Entry --> Update["Update expression blocks"]
    Update --> Exit["Update exit"]
    Exit -->|backedge| Test
```

## Implementation

Record `cfg.current_node_ix` after visiting the update expression as `after_update_graph_ix`. The backedge to the loop test now originates from that exit block.

The loop body backedge and `continue` target still point to `update_graph_ix`, ensuring the complete update expression runs before the next test.

A dedicated CFG fixture covers a conditional update expression:

```js
forward ? index++ : index--
```
2026-06-25 17:25:58 +00:00
camc314 d3e92d5258 fix(semantic/cfg): connect while branches from condition exit (#23790)
Correct the CFG generated for `while` statements whose test expression creates multiple basic blocks, such as logical or conditional expressions.

Previously, the loop body and exit edges originated from the test expression's entry block. They now originate from its exit block after the complete expression has been evaluated.

## Before

The body and exit edges could bypass the test expression, leaving its exit block disconnected.

```mermaid
flowchart LR
    Entry["Test entry"] --> Test["Test expression"]
    Test --> Exit["Test exit"]

    Entry -->|true| Body["Loop body"]
    Entry -->|false| After["After while"]
    Body -->|backedge| Entry
```
## After

The complete test expression is evaluated before control branches to the loop body or exit.

```mermaid
flowchart LR
    Entry["Test entry"] --> Test["Test expression"]
    Test --> Exit["Test exit"]

    Exit -->|true| Body["Loop body"]
    Exit -->|false| After["After while"]
    Body -->|backedge| Entry
```

The implementation records cfg.current_node_ix after visiting the test expression as after_test_graph_ix, then uses that block for the body and exit edges. The loop backedge and continue target remain connected to the test entry so each iteration evaluates the expression again.
2026-06-25 17:19:17 +00:00
Boshen 777f02ae10 refactor(diagnostics)!: return a Diagnostics type instead of Vec<OxcDiagnostic> (#23217)
## Summary

Introduces `oxc_diagnostics::Diagnostics` — a `Vec<OxcDiagnostic>` newtype that knows the difference between errors and warnings — and makes it the standard diagnostics return value across oxc.

- **New type**: `Diagnostics` with `has_errors()`, `has_warnings()`, `errors()`, `warnings()`, plus `Vec`-like ergonomics (Deref, `IntoIterator`, `Extend`, `From`/`Into<Vec>`) so most call sites are unchanged.
- **Return types**: `ParserReturn`, `SemanticBuilderReturn`, `IsolatedDeclarationsReturn`, the React Compiler `TransformResult`/`LintResult`, and `TransformerReturn` now expose `diagnostics: Diagnostics` instead of `errors: Vec<OxcDiagnostic>` (the React Compiler's separate `errors`/`warnings` are merged into one severity-tagged list).
- **Behaviour**: a React Compiler **error** now stops the transform (no output), while **warnings** flow through and the transform continues. `compile()` aborts codegen only when `diagnostics.has_errors()` — warnings alone no longer abort (previously any diagnostic did).

## Breaking change

Consumers reading `*.errors` on these return values must read `*.diagnostics`. React Compiler consumers that read `.errors`/`.warnings` separately should use `diagnostics.has_errors()` / `diagnostics.errors()` / `diagnostics.warnings()`.

Parser/semantic/isolated-declarations fatality is otherwise unchanged. Builds on the React Compiler transform feature (#23201).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-06-10 14:46:52 +00:00
Boshen 1260f03b4f refactor(semantic): don't build the AstNodes store by default (#23005)
## What

Make the full `AstNodes` store **opt-in**, so the compiler pipeline (transformer / codegen / minifier) can run semantic analysis without building it at all.

Previously every `SemanticBuilder` run allocated and populated the full `AstNodes` store, even for consumers that only need scoping + the syntax checker. This separates the node-related builder state into three independent pieces:

- a standalone `NodeId` counter — the source of truth for node ids, valid in either mode;
- an **ancestry stack** — an upward-walk-only stack of the current node's ancestors, the only ancestry the syntax checker and binder actually read;
- the full **`AstNodes`** store — random access to every node, needed by the linter and mangler.

## How

- A new `AstNodeStore` (in `crates/oxc_semantic/src/node/store.rs`) bundles the node-id counter, the current-node cursor/flags, and the storage. The storage is an enum (`AstNodeStoreKind`) with two variants — `Full(AstNodes)` and `Ancestry(AncestryStack)` — so the full store and the ancestry stack are **mutually exclusive by construction**; they can never both be maintained at once.
- The checker and binder read ancestry through an `Ancestry` view (`node/ancestry.rs`) that dispatches between the full store (linter / mangler) and the stack (compiler pipeline). They no longer do random `NodeId` access into the store — all ancestry access is upward-walk-only.
- `SemanticBuilder` gains `with_build_nodes(bool)`. The default is **off** (ancestry stack only). `new_linter()` turns it on (the linter needs the full store); `new_compiler()` leaves it off.
- `CompilerInterface::build_semantic_nodes()` lets `oxc::Compiler` consumers opt back in if their `after_semantic` hook reads `Semantic::nodes`.

## Notes

- Behaviour-neutral: semantic conformance snapshots are unchanged.
- Allocation snapshots updated — the default (ancestry) path allocates slightly less (the growing `Stack` trades a couple of fixed allocations for a few reallocs).
- Builds on the already-merged `SymbolFlags`-based redeclaration checks (#23060) and the `new_linter`/`new_compiler` preset adoption (#23057), which removed the last random node reads from the redeclaration path so the checker works without the store.
2026-06-08 16:13:56 +00:00
Boshen d16f456ce9 refactor(semantic): track function kind in SymbolFlags for redeclaration checks (#23060)
Encode whether a function binding is a named function expression or an `async`/generator function as two internal `SymbolFlags` bits (`FunctionExpression`, `AsyncOrGeneratorFunction`), set at bind time.

The redeclaration checks now read these flags instead of the AST node:

- `check_redeclaration` checks `FunctionExpression` rather than fetching the declaration node to ask `Function::is_expression`.
- `check_redeclared_function` (Annex B.3.3) checks `AsyncOrGeneratorFunction` on each previous declaration, replacing the build-only `async_or_generator_function_node_ids` Vec and its linear scan.

The transformer keeps the flags accurate when it rewrites functions, via a new `sync_function_symbol_flags` helper applied at the function-rewriting sites in `async_to_generator` and class private-method extraction.

Behaviour-neutral: semantic conformance snapshots are unchanged.
2026-06-07 08:04:12 +00:00
Boshen 336413bf5d refactor(semantic): use new_linter/new_compiler presets at callsites (#23037)
Replaces ad-hoc `SemanticBuilder::new().with_*()` chains with the `new_linter()` / `new_compiler()` presets where the preset already expands to the exact same option set, so the config lives in one place.

- linter example + linter benchmark → `new_linter()` (cfg + class table + syntax)
- semantic benchmark, cfg example, integration test util → `new_compiler()` (syntax)

Behavior-neutral — each preset matches the options the callsite set by hand. Carved out of the larger store-optional refactor so it can land independently on `main` first.
2026-06-06 19:09:57 +00:00
Dunqing dfa931d3bc fix(semantic): propagate unresolved auto-increment enum value instead of defaulting to 0 (#22646)
## Summary

- When a TypeScript enum member with no initializer follows one whose initializer could not be evaluated to a constant, the auto-increment value previously fell back to `0`. It now propagates "unresolved" (`None`) like the existing `Some(String) => None` arm, matching tsc 6.0.3 (which errors on this construct and emits `void 0`, never `0`).
- The bug surfaced via rolldown's cross-module enum inliner (rolldown/rolldown#9494). Rolldown reads `Scoping::get_enum_member_value` to populate its `enum_member_value_map`; once the wrong `0` landed in the map, every call-site reference to the affected member was inlined to `0`. After this fix the map omits the entry and rolldown leaves the reference alone — matching tsc's call-site behavior.
- Adopts the existing `prev = Some(Number(-1.0))` sentinel pattern from `oxc_isolated_declarations/src/enum.rs` and `oxc_transformer/src/typescript/enum.rs`, so the first-member-defaults-to-0 case still resolves naturally and the auto-increment branch shrinks to two arms.

## Example

Input:

```ts
import { External } from './external'; // External.X = 0, External.Y = 1
enum Local { A = External.X, B = External.Y, C }
```

`Scoping::get_enum_member_value` before:

- A → None, B → None, C → Some(Number(0.0))  (wrong)

After:

- A → None, B → None, C → None

Covered by new test `crates/oxc_semantic/tests/integration/enum_values.rs::auto_increment_after_unresolvable_fails`; existing `auto_increment` (first member defaults to 0) and `auto_increment_after_string_fails` continue to pass.

AI disclosure: drafted with Claude Code, reviewed manually.
2026-05-22 10:02:55 +00:00
Dunqing 75663c077d feat(semantic): add enum member value evaluation for const enum support (#20602)
## Summary

Part of https://github.com/oxc-project/oxc/issues/6073 and #11844

- Add `ConstantValue` type in `oxc_syntax` for representing enum member values (number/string)
- Implement enum member value evaluation in `oxc_semantic` supporting numeric auto-increment, string values, binary/unary expressions, cross-member and cross-enum references, template literals, and merged enum declarations
- Store evaluated enum member values in `Scoping` via `EnumData` struct with getter/setter APIs and enum body scope tracking
- All enum evaluation code is gated behind the `enum_eval` Cargo feature (enabled by `oxc_transformer`)

### Feature gate

The `enum_eval` feature controls:
- `ts_enum` module (evaluator + data types)
- `EnumData` field and enum-related methods on `Scoping`
- `oxc_syntax/to_js_string` dependency

Consumers that don't need enum values (linter, language server) pay zero cost.

### Babel alignment

Unary operators on strings follow Babel's JS-coercion semantics (`+"s"` → `"s"`, `-"s"` → `NaN`, `~"s"` → `-1`), which differs from TypeScript (unevaluated). This is documented in the source.

## Test plan

- [x] Integration tests in `crates/oxc_semantic/tests/integration/enum_values.rs`
- [x] Semantic TypeScript conformance snapshot updated
- [x] `cargo check -p oxc_semantic` passes (without feature)
- [x] `cargo check -p oxc_semantic --features enum_eval` passes (with feature)
- [x] `cargo check -p oxc_transformer` passes (enables feature transitively)
2026-04-07 08:52:19 +00:00
Boshen bfb15a3651 fix(semantic): make multi_index_vec clone panic-safe (#19299)
## Summary
Follow-up to #19138 after merge.

This PR fixes panic-safety in `multi_index_vec!` clone and keeps strict lint clean for `oxc_semantic` tests.

### Changes
- Make macro-generated `Clone` panic-safe by cloning row-by-row through `push`.
  - Avoids setting `len` before all elements are initialized.
  - Prevents dropping uninitialized elements if a field `clone()` panics.
- Add `#[expect(clippy::unused_self)]` to cfg-disabled integration helper methods to keep `cargo clippy -p oxc_semantic --lib --tests -D warnings` green.

## Validation
- `cargo clippy -p oxc_semantic --lib --tests -- -D warnings`
- `just lint`

## AI disclosure
AI-assisted: I used Codex to draft and apply this patch, then ran lint checks and reviewed the result before opening this PR.
2026-02-12 08:54:07 +00:00
Boshen 0f1b50bc4d refactor(semantic): accept Ident instead of &str in binding/symbol APIs (#19089)
## Summary

- Change `Scoping` methods (`get_binding`, `find_binding`,
`scope_has_binding`, `get_root_binding`) to accept `Ident` instead of
`&str`
- Propagate `Ident` through `TraverseScoping`/`TraverseCtx` methods
(`create_reference`, `create_unbound_reference`,
`create_reference_in_current_scope`, `delete_reference`)
- Update all callers across semantic, traverse, transformer, linter,
minifier, and transformer_plugins crates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-02-07 09:25:18 +08:00
Boshen f32ea19e15 fix(semantic): report redeclaration error for import bindings conflicting with value declarations (#19068)
## Summary

- In JavaScript modules, `import { Foo } from './foo.js'; var Foo;` (and `let`, `const`, `class`, `function`) should report `"Identifier 'Foo' has already been declared"` per the [ES spec](https://tc39.es/ecma262/#sec-imports-static-semantics-early-errors)
- The existing excludes-based conflict detection in the binder doesn't catch this because `Import` is not in the `Value` bitset
- Added a checker function that runs at `Program` leave, scanning root scope bindings for symbols with both `Import` and a value flag, and reports a redeclaration error
- TypeScript is excluded since it has its own declaration merging rules

Closes #15961

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-02-06 15:03:47 +00:00
Boshen 3aeba7a7e6 fix(semantic): report redeclaration error for function a() {} var a in module mode (#19041)
## Summary

Fixes #18719.

- In module mode, function declarations are lexically scoped (part of `LexicallyDeclaredNames`), so `function a() {} var a = ''` is a redeclaration error per the ECMAScript spec
- The checker was only reporting the error when the `var` appeared **before** the function (`var a = ''; function a() {}`) but not the other way around, due to AST visit ordering
- `check_variable_declarator_redeclaration` unconditionally skipped the check at `Top | Function` scopes — now it falls through to the redeclaration check when in module mode at the top scope

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-02-06 09:12:12 +00:00
Boshen f53f0f017e refactor(span)!: SourceType::with_module(false) no longer sets script mode (#18861)
## Summary

- Add `SourceType::script()` constructor for creating script source types
- `with_module(bool)` now only sets module mode when `true`, does nothing when `false`
- This aligns with the pattern of other `with_*` methods like `with_script()`, `with_jsx()`, etc.

### Migration

Before:
```rust
// This used to set script mode when is_module is false
let source_type = SourceType::default().with_module(is_module);
```

After:
```rust
// Start from script and upgrade to module when needed
let source_type = SourceType::script().with_module(is_module);
```

🤖 Generated with [Claude Code](https://claude.ai/code)
2026-02-02 17:09:16 +00:00
renovate b67ab40408 chore(deps): update dependency rust to v1.93.0 (#18406)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rust](https://redirect.github.com/rust-lang/rust) | minor | `1.92.0` → `1.93.0` |

---

### Release Notes

<details>
<summary>rust-lang/rust (rust)</summary>

### [`v1.93.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1930-2026-01-22)

[Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.92.0...1.93.0)

\==========================

<a id="1.93.0-Language"></a>

## Language

- [Stabilize several s390x `vector`-related target features and the `is_s390x_feature_detected!` macro](https://redirect.github.com/rust-lang/rust/pull/145656)
- [Stabilize declaration of C-style variadic functions for the `system` ABI](https://redirect.github.com/rust-lang/rust/pull/145954)
- [Emit error when using some keyword as a `cfg` predicate](https://redirect.github.com/rust-lang/rust/pull/146978)
- [Stabilize `asm_cfg`](https://redirect.github.com/rust-lang/rust/pull/147736)
- [During const-evaluation, support copying pointers byte-by-byte](https://redirect.github.com/rust-lang/rust/pull/148259)
- [LUB coercions now correctly handle function item types, and functions with differing safeties](https://redirect.github.com/rust-lang/rust/pull/148602)
- [Allow `const` items that contain mutable references to `static` (which is *very* unsafe, but not *always* UB)](https://redirect.github.com/rust-lang/rust/pull/148746)
- [Add warn-by-default `const_item_interior_mutations` lint to warn against calls which mutate interior mutable `const` items](https://redirect.github.com/rust-lang/rust/pull/148407)
- [Add warn-by-default `function_casts_as_integer` lint](https://redirect.github.com/rust-lang/rust/pull/141470)

<a id="1.93.0-Compiler"></a>

## Compiler

- [Stabilize `-Cjump-tables=bool`](https://redirect.github.com/rust-lang/rust/pull/145974). The flag was previously called `-Zno-jump-tables`.

<a id="1.93.0-Platform-Support"></a>

## Platform Support

- [Promote `riscv64a23-unknown-linux-gnu` to Tier 2 (without host tools)](https://redirect.github.com/rust-lang/rust/pull/148435)

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.93.0-Libraries"></a>

## Libraries

- [Stop internally using `specialization` on the `Copy` trait as it is unsound in the presence of lifetime dependent `Copy` implementations. This may result in some performance regressions as some standard library APIs may now call `Clone::clone` instead of performing bitwise copies](https://redirect.github.com/rust-lang/rust/pull/135634)
- [Allow the global allocator to use thread-local storage and `std::thread::current()`](https://redirect.github.com/rust-lang/rust/pull/144465)
- [Make `BTree::append` not update existing keys when appending an entry which already exists](https://redirect.github.com/rust-lang/rust/pull/145628)
- [Don't require `T: RefUnwindSafe` for `vec::IntoIter<T>: UnwindSafe`](https://redirect.github.com/rust-lang/rust/pull/145665)

<a id="1.93.0-Stabilized-APIs"></a>

## Stabilized APIs

- [`<[MaybeUninit<T>]>::assume_init_drop`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.assume_init_drop)
- [`<[MaybeUninit<T>]>::assume_init_ref`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.assume_init_ref)
- [`<[MaybeUninit<T>]>::assume_init_mut`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.assume_init_mut)
- [`<[MaybeUninit<T>]>::write_copy_of_slice`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.write_copy_of_slice)
- [`<[MaybeUninit<T>]>::write_clone_of_slice`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.write_clone_of_slice)
- [`String::into_raw_parts`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.into_raw_parts)
- [`Vec::into_raw_parts`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.into_raw_parts)
- [`<iN>::unchecked_neg`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unchecked_neg)
- [`<iN>::unchecked_shl`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unchecked_shl)
- [`<iN>::unchecked_shr`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unchecked_shr)
- [`<uN>::unchecked_shl`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unchecked_shl)
- [`<uN>::unchecked_shr`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unchecked_shr)
- [`<[T]>::as_array`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_array)
- [`<[T]>::as_array_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_mut_array)
- [`<*const [T]>::as_array`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_array)
- [`<*mut [T]>::as_array_mut`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_mut_array)
- [`VecDeque::pop_front_if`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.pop_front_if)
- [`VecDeque::pop_back_if`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.pop_back_if)
- [`Duration::from_nanos_u128`](https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_nanos_u128)
- [`char::MAX_LEN_UTF8`](https://doc.rust-lang.org/stable/std/primitive.char.html#associatedconstant.MAX_LEN_UTF8)
- [`char::MAX_LEN_UTF16`](https://doc.rust-lang.org/stable/std/primitive.char.html#associatedconstant.MAX_LEN_UTF16)
- [`std::fmt::from_fn`](https://doc.rust-lang.org/stable/std/fmt/fn.from_fn.html)
- [`std::fmt::FromFn`](https://doc.rust-lang.org/stable/std/fmt/struct.FromFn.html)

<a id="1.93.0-Cargo"></a>

## Cargo

- [Enable CARGO\_CFG\_DEBUG\_ASSERTIONS in build scripts based on profile](https://redirect.github.com/rust-lang/cargo/pull/16160/)
- [In `cargo tree`, support long forms for `--format` variables](https://redirect.github.com/rust-lang/cargo/pull/16204/)
- [Add `--workspace` to `cargo clean`](https://redirect.github.com/rust-lang/cargo/pull/16263/)

<a id="1.93.0-Rustdoc"></a>

## Rustdoc

- [Remove `#![doc(document_private_items)]`](https://redirect.github.com/rust-lang/rust/pull/146495)
- [Include attribute and derive macros in search filters for "macros"](https://redirect.github.com/rust-lang/rust/pull/148176)
- [Include extern crates in search filters for `import`](https://redirect.github.com/rust-lang/rust/pull/148301)
- [Validate usage of crate-level doc attributes](https://redirect.github.com/rust-lang/rust/pull/149197).  This means if any of `html_favicon_url`, `html_logo_url`, `html_playground_url`, `issue_tracker_base_url`, or `html_no_source` either has a missing value, an unexpected value, or a value of the wrong type, rustdoc will emit the deny-by-default lint `rustdoc::invalid_doc_attributes`.

<a id="1.93.0-Compatibility-Notes"></a>

## Compatibility Notes

- [Introduce `pin_v2` into the builtin attributes namespace](https://redirect.github.com/rust-lang/rust/pull/139751)
- [Update bundled musl to 1.2.5](https://redirect.github.com/rust-lang/rust/pull/142682)
- [On Emscripten, the unwinding ABI used when compiling with `panic=unwind` was changed from the JS exception handling ABI to the wasm exception handling ABI.](https://redirect.github.com/rust-lang/rust/pull/147224) If linking C/C++ object files with Rust objects, `-fwasm-exceptions` must be passed to the linker now. On nightly Rust, it is possible to get the old behavior with `-Zwasm-emscripten-eh=false -Zbuild-std`, but it will be removed in a future release.
- The `#[test]` attribute, used to define tests, was previously ignored in various places where it had no meaning (e.g on trait methods or types). Putting the `#[test]` attribute in these places is no longer ignored, and will now result in an error; this may also result in errors when generating rustdoc. [Error when `test` attribute is applied to structs](https://redirect.github.com/rust-lang/rust/pull/147841)
- Cargo now sets the `CARGO_CFG_DEBUG_ASSERTIONS` environment variable in more situations. This will cause crates depending on `static-init` versions 1.0.1 to 1.0.3 to fail compilation with "failed to resolve: use of unresolved module or unlinked crate `parking_lot`". See [the linked issue](https://redirect.github.com/rust-lang/rust/issues/150646#issuecomment-3718964342) for details.
- [User written types in the `offset_of!` macro are now checked to be well formed.](https://redirect.github.com/rust-lang/rust/issues/150465/)
- `cargo publish` no longer emits `.crate` files as a final artifact for user access when the `build.build-dir` config is unset
- [Upgrade the `deref_nullptr` lint from warn-by-default to deny-by-default](https://redirect.github.com/rust-lang/rust/pull/148122)
- [Add future-incompatibility warning for `...` function parameters without a pattern outside of `extern` blocks](https://redirect.github.com/rust-lang/rust/pull/143619)
- [Introduce future-compatibility warning for `repr(C)` enums whose discriminant values do not fit into a `c_int` or `c_uint`](https://redirect.github.com/rust-lang/rust/pull/147017)
- [Introduce future-compatibility warning against ignoring `repr(C)` types as part of `repr(transparent)`](https://redirect.github.com/rust-lang/rust/pull/147185)

</details>

---

### Configuration

📅 **Schedule**: 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:eyJjcmVhdGVkSW5WZXIiOiI0Mi44NS4xIiwidXBkYXRlZEluVmVyIjoiNDIuODUuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
2026-01-22 16:21:00 +00:00
Dunqing 22dec6ace5 feat(semantic)!: remove Scoping::scope_build_child_ids and all related APIs (#18362)
Remove `Scoping::scope_build_child_ids` and all related APIs to make the semantics cleaner. This could also make it easier for us to sync Scoping data since we don't need to worry about child scope IDs.

This is a breaking change, but it is okay because all use of `scope_build_child_ids` in the Oxc and Rolldown has been removed.
2026-01-22 07:46:26 +00:00
Boshen 9135b0b2f3 feat(ast)!: move scope from TSEnumDeclaration to TSEnumBody (#18058)
## Summary

- Move `scope_id: Cell<Option<ScopeId>>` from `TSEnumDeclaration` to `TSEnumBody`
- Since `TSEnumBody` was introduced as a dedicated type in PR #10284, the scope logically belongs on the body rather than on the parent declaration node

Closes #10331

## Test plan

- [x] Unit tests pass (`just test`)
- [x] Conformance tests pass (`just conformance`)
- [x] Updated semantic test snapshots reflect scope now on `TSEnumBody`

🤖 Generated with [Claude Code](https://claude.ai/code)
2026-01-16 13:30:08 +00:00
Boshen eee03429bd chore(ci): test 32-bit (#17385)
closes #16099

---------

Signed-off-by: Boshen <boshenc@gmail.com>
2026-01-14 20:21:14 +08:00
camc314 109f4520de refactor(semantic): eliminate manual current_node_ix manipulation in try statements (#14858)
fixes the `TODO`​ comments left in the code
2025-10-21 16:35:34 +00:00
camc314 cdf2d07e6a fix(semantic): add condition basic blocks to CFG for logical expressions (#14671)
Add explicit condition basic blocks in the control flow graph for logical
expressions and logical assignment operators. This improves CFG accuracy by
representing condition evaluation as distinct nodes.

Changes:
- Create condition basic blocks before evaluating left operands of logical expressions (&&, ||, ??)
- Record and attach AST nodes to condition blocks for better traceability
- Add edges from preceding blocks to condition blocks
- Apply same treatment to logical assignment operators (&&=, ||=, ??=)

This affects CFG generation for:
- LogicalExpression nodes
- AssignmentExpression nodes with logical operators
2025-10-17 10:46:39 +00:00
Boshen be94bfd401 fix(semantic): add scope tracking for with statements (#14652)
Fixes #8365

## Summary

The `with` statement was not creating a scope in the semantic analysis, causing `is_global_reference` to incorrectly return `true` for references inside `with` blocks. This could lead to incorrect minification.

## Problem

According to the ECMAScript specification, `with` statements should create an Object Environment Record that extends the lexical environment. Without proper scope tracking:

- `is_global_reference()` incorrectly returns `true` for identifiers inside `with` blocks
- This can cause minification to incorrectly treat local references as global
- The scope tree doesn't accurately represent the program structure

## Solution

### Changes Made

1. **AST Definition** (`crates/oxc_ast/src/ast/js.rs`):
   - Added `#[scope]` attribute to `WithStatement` struct
   - Added `scope_id: Cell<Option<ScopeId>>` field

2. **Semantic Builder** (`crates/oxc_semantic/src/builder.rs`):
   - Modified `visit_with_statement` to call `enter_scope()` before visiting the body
   - Added `leave_scope()` call after visiting the body
   - Uses `ScopeFlags::empty()` similar to block statements

3. **Test Coverage** (`crates/oxc_semantic/tests/integration/scopes.rs`):
   - Added `test_with_statement` to verify scope creation
   - Tests both simple expressions and block statement bodies
   - Verifies proper scope tree structure

### Example

```javascript
const foo = {
  Object: class {
    constructor() { console.log('Constructor') }
  }
}
with (foo) {
  console.log(new Object()) // should print "Constructor"
}
```

Before this fix, `Object` inside the `with` block would be incorrectly identified as a global reference, potentially causing minification errors.

## Implementation Notes

While this implementation doesn't fully model the complex object environment semantics (where property lookups can dynamically affect identifier resolution at runtime), it ensures:

- References inside `with` blocks are no longer incorrectly marked as global
- The scope tree properly represents the lexical structure
- Provides a foundation for future improvements to object environment handling

## Testing

All existing tests pass, plus the new test verifies:
- `with` statements create scopes
- Scopes are properly nested in the scope tree
- Works correctly with both simple and block statement bodies
2025-10-16 10:02:06 +00:00
Boshen 08c05df60c perf(semantic): make CFG construction a compile-time feature (#13678)
part of #13646

## Summary

This PR converts the Control Flow Graph (CFG) functionality in `oxc_semantic` from runtime checks to a compile-time cargo feature, eliminating runtime overhead when CFG is not needed.

## Changes

- Added `cfg` cargo feature to `oxc_semantic/Cargo.toml` with `oxc_cfg` as optional dependency
- Feature-gated all CFG-related code using `#[cfg(feature = "cfg")]`
- Updated `oxc_linter` to enable the `cfg` feature (since it requires CFG)
- Made the `control_flow!` macro work correctly with and without the feature

## Benefits

- **Performance**: Eliminates runtime `Option<CFG>` checks when feature is disabled
- **Binary size**: Smaller binaries for crates that don't need CFG
- **Cleaner API**: CFG methods only available when feature is enabled

## Test Plan

- [x] All existing tests pass with `cargo test -p oxc_semantic --features cfg`
- [x] `oxc_linter` builds and works correctly (it enables the feature)
- [x] Feature is backward compatible - existing code continues to work

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-09-11 12:44:19 +00:00
overlookmotel c072e0120d refactor(all): add missing lifetimes in function return types (#12895)
Where a type being returned by a function has lifetimes, specify them with `'_` instead of omitting them entirely. `Cow<str>` -> `Cow<'_, str>`.

This is split out from Rust upgrade PR #12873, so can see the diff in that PR more clearly.

Note: This is very slightly different from what was in #12873. Clippy auto-fix introduced a couple of unnecessary and weird-looking anonymous lifetimes in function params, which this PR skips.
2025-08-08 08:40:13 +00:00
camc314 50b91ac7fa feat(ast)!: remove IdentifierReference from qualifier field of TSImportType (#12799)
closes #12042, #12797
2025-08-05 05:55:42 +00:00
overlookmotel 2aa65b900e test(semantic): remove unnecessary clone (#12667)
Remove an unnecessary `clone` from `SymbolTester`. Don't need to clone the `Reference` only to pass a reference to it to `filter`. Just use the original `&Reference`.
2025-07-31 15:31:57 +00:00
overlookmotel 65847c0ff5 style(semantic): reorder imports (#12671)
Re-order imports in `oxc_semantic` in order of furthest away (`std`) to closest (`mod`).
2025-07-31 12:36:29 +00:00
Boshen 3b03fd3559 feat(parser): produce correct syntax error for interface I extends (typeof T) (#11610)
closes #11571
2025-06-11 14:42:38 +00:00
Boshen 5d9344fbfa refactor(rust)!: clippy avoid-breaking-exported-api = false (#11088) 2025-05-17 02:21:26 +00:00
Dunqing faf0a95bb6 refactor(syntax): rename NameSpaceModule to NamespaceModule (#10917)
As much as possible, keep the name the same as `TypeScript`

https://github.com/microsoft/TypeScript/blob/8c62e08448e0ec76203bd519dd39608dbcb31705/src/compiler/types.ts#L5915
2025-05-09 14:24:24 +00:00
Dunqing dd2aef0bf2 fix(semantic): incorrect SymbolFlags of TSModuleDeclaration (#10350)
Based on TypeScript's [implementation](https://github.com/microsoft/TypeScript/blob/15392346d05045742e653eab5c87538ff2a3c863/src/compiler/binder.ts#L2384-L2393) to correct `SymbolFlags` of `TSModuleDeclaration`.

The `SymbolFlags::NamespaceModule` and `SymbolFlags::ValueModule` have a significant difference,

`NamespaceModule`: can only be referenced as a type.
`ValueModule`: can only be referenced as a value.

Let's take an example to see:

```ts
namespace NamespaceModule {
  export type A = string
}
namespace ValueModule {
  export const A = 0;
}
```

The following code is the JS output of the above example.

```js
"use strict";
var ValueModule;
(function (ValueModule) {
    ValueModule.A = 0;
})(ValueModule || (ValueModule = {}));
```

Only `ValueModule` will be preserved and transformed.

That means whether a `TSModuleDeclaration`  needs to be transformed or removed directly, we can determine by its `SymbolFlags`. We can use it to simplify the current `TSModuleDeclaration` transformation later.
2025-04-11 09:58:46 +00:00
Dunqing c37f048873 fix(semantic): do not declare a Symbol for an ModuleDeclaration where the id is not a BindingIdentifier (#10343)
In previous implementations, a symbol was declared for `ModuleDeclaration` but only inserted when `name` was a `BindingIdentifier`. This is incorrect and also causes a potential performance impact. See https://github.com/oxc-project/oxc/blob/bae53b9606b62fce58b4101497849997b0dc07b3/crates/oxc_semantic/src/stats.rs.

So we should only declare a symbol when its name is a `BindingIdentifier` because only `BindingIdentifier` can be inserted with a symbol ID.
2025-04-11 09:58:45 +00:00
Yuji Sugiura 49732ffb45 feat(ast)!: Re-introduce TSEnumBody AST node (#10284)
Fixes #10087 

---

Follow up for #10017 .

This PR eliminates the part where nodes were manually generated for
JS-land AST.

NOTE: This node was originally present, but was removed at #2509 and is
now being reintroduced to get the correct `Span` position for #9705 .

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-04-09 12:06:20 +01:00
overlookmotel 66a0001e64 style(all): remove unnecessary semi-colons (#10198)
Remove unnecessary semi-colons. Flagged by clippy in Rust 1.86.0.
2025-04-03 11:44:34 +00:00
Dunqing 6687f5b5fa fix(semantic): define a variable in a function expression whose name is the same as the function name which is considered a redeclaration (#10077)
```js
(function n(n) {})()
```

The function `n` symbol will insert into the function itself scope, which causes param `n` to be considered a redeclaration, but it is not.
2025-03-28 04:12:21 +00:00
camc314 3d4c5f3a20 fix(semantic): correctly visit IfStmt test when building cfg (#9864)
This PR fixes the construction of the cfg within `oxc_semantic`, by marking the `test` of `IfStatement` as unconditionally visited.

Given the following:
```ts
if (foo) {
  bar();
} else {
  baz();
}
```

Would produce the following graph:

```mermaid
graph TD
    0["bb0"]
    1["bb1 IfStatement"]
    2["bb2 Condition(IdentifierReference(foo))"]
    3["bb3 BlockStatement ExpressionStatement"]
    4["bb4 BlockStatement ExpressionStatement"]
    5["bb5"]

    1 -- "Error(Implicit)" --> 0
    2 -- "Error(Implicit)" --> 0
    3 -- "Error(Implicit)" --> 0
    4 -- "Error(Implicit)" --> 0
    5 -- "Error(Implicit)" --> 0
    1 -- "Normal" --> 2
    1 -- "Normal" --> 4
    3 -- "Normal" --> 5
    2 -- "Jump" --> 3
    4 -- "Normal" --> 5
```

After this change, it produces the following graph:

```mermaid
graph TD
    0["bb0"]
    1["bb1 IfStatement"]
    2["bb2 Condition(IdentifierReference(foo))"]
    3["bb3 BlockStatement ExpressionStatement"]
    4["bb4 BlockStatement ExpressionStatement"]
    5["bb5"]

    1 -- "Error(Implicit)" --> 0
    2 -- "Error(Implicit)" --> 0
    3 -- "Error(Implicit)" --> 0
    4 -- "Error(Implicit)" --> 0
    5 -- "Error(Implicit)" --> 0
    1 -- "Normal" --> 2
    3 -- "Normal" --> 5
    2 -- "Jump" --> 3
    2 -- "Jump" --> 4
    4 -- "Normal" --> 5
```

Rather than jumping from the if statment (`bb1\nIfStatement`) directly to the consequent (`bb4 BlockStatement ExpressionStatement`), it now unconditionally visits the `test` of the if statement. This can be seen in the after graph as the jump to `bb4 BlockStatement ExpressionStatement"` comes **from** `bb2 Condition(IdentifierReference(foo))` rather than from `bb1 IfStatement`.

As a result of this change, `rules_of_hooks`, does not have false positives when a hook is in a position such as:
```ts
if (useMe) {
```
As the cfg would previously think that `useMe` was called conditionally when in fact it was not

fixes https://github.com/oxc-project/oxc/issues/9795
related #9807
2025-03-19 01:07:07 +00:00
Boshen 3c6f1405af refactor(semantic)!: make Scoping methods consistent (#9628) 2025-03-09 12:00:00 +00:00
Boshen ef6e0cca39 refactor(semantic)!: combine SymbolTable and ScopeTree into Scoping (#9615)
closes #9607
2025-03-09 10:28:12 +00:00
Boshen 7331656286 refactor(semantic)!: rename SymbolTable and ScopeTree methods (#9613)
part of #9607
2025-03-09 10:28:11 +00:00
Boshen 23738bf9db refactor(semantic)!: introduce Scoping (#9611)
part of #9607
2025-03-09 10:28:11 +00:00
Boshen 1d81adac48 Rust Edition 2024 (#9289)
closes #9271

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-22 11:56:25 +08:00
renovate cf969e2bb7 chore(deps): update dependency rust to v1.85.0 (#9263)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rust](https://redirect.github.com/rust-lang/rust) | minor | `1.84.1` -> `1.85.0` |

---

### Release Notes

<details>
<summary>rust-lang/rust (rust)</summary>

### [`v1.85.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1850-2025-02-20)

[Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.84.1...1.85.0)

\==========================

<a id="1.85.0-Language"></a>

## Language

-   [The 2024 Edition is now stable.](https://redirect.github.com/rust-lang/rust/pull/133349)
    See [the edition guide](https://doc.rust-lang.org/nightly/edition-guide/rust-2024/index.html) for more details.
-   [Stabilize async closures](https://redirect.github.com/rust-lang/rust/pull/132706)
    See [RFC 3668](https://rust-lang.github.io/rfcs/3668-async-closures.html) for more details.
-   [Stabilize `#[diagnostic::do_not_recommend]`](https://redirect.github.com/rust-lang/rust/pull/132056)
-   [Add `unpredictable_function_pointer_comparisons` lint to warn against function pointer comparisons](https://redirect.github.com/rust-lang/rust/pull/118833)
-   [Lint on combining `#[no_mangle]` and `#[export_name]` attributes.](https://redirect.github.com/rust-lang/rust/pull/131558)

<a id="1.85.0-Compiler"></a>

## Compiler

-   [The unstable flag `-Zpolymorphize` has been removed](https://redirect.github.com/rust-lang/rust/pull/133883), see [https://github.com/rust-lang/compiler-team/issues/810](https://redirect.github.com/rust-lang/compiler-team/issues/810) for some background.

<a id="1.85.0-Platform-Support"></a>

## Platform Support

-   [Promote `powerpc64le-unknown-linux-musl` to tier 2 with host tools](https://redirect.github.com/rust-lang/rust/pull/133801)

Refer to Rust's \[platform support page]\[platform-support-doc]
for more information on Rust's tiered platform support.

<a id="1.85.0-Libraries"></a>

## Libraries

-   [Panics in the standard library now have a leading `library/` in their path](https://redirect.github.com/rust-lang/rust/pull/132390)
-   [`std::env::home_dir()` on Windows now ignores the non-standard `$HOME` environment variable](https://redirect.github.com/rust-lang/rust/pull/132515)

    It will be un-deprecated in a subsequent release.
-   [Add `AsyncFn*` to the prelude in all editions.](https://redirect.github.com/rust-lang/rust/pull/132611)

<a id="1.85.0-Stabilized-APIs"></a>

## Stabilized APIs

-   [`BuildHasherDefault::new`](https://doc.rust-lang.org/stable/std/hash/struct.BuildHasherDefault.html#method.new)
-   [`ptr::fn_addr_eq`](https://doc.rust-lang.org/std/ptr/fn.fn_addr_eq.html)
-   [`io::ErrorKind::QuotaExceeded`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#variant.QuotaExceeded)
-   [`io::ErrorKind::CrossesDevices`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#variant.CrossesDevices)
-   [`{float}::midpoint`](https://doc.rust-lang.org/core/primitive.f32.html#method.midpoint)
-   [Unsigned `{integer}::midpoint`](https://doc.rust-lang.org/std/primitive.u64.html#method.midpoint)
-   [`NonZeroU*::midpoint`](https://doc.rust-lang.org/std/num/type.NonZeroU32.html#method.midpoint)
-   [impl `std::iter::Extend` for tuples with arity 1 through 12](https://doc.rust-lang.org/stable/std/iter/trait.Extend.html#impl-Extend%3C\(A,\)%3E-for-\(EA,\))
-   [`FromIterator<(A, ...)>` for tuples with arity 1 through 12](https://doc.rust-lang.org/stable/std/iter/trait.FromIterator.html#impl-FromIterator%3C\(EA,\)%3E-for-\(A,\))
-   [`std::task::Waker::noop`](https://doc.rust-lang.org/stable/std/task/struct.Waker.html#method.noop)

These APIs are now stable in const contexts:

-   [`mem::size_of_val`](https://doc.rust-lang.org/stable/std/mem/fn.size_of_val.html)
-   [`mem::align_of_val`](https://doc.rust-lang.org/stable/std/mem/fn.align_of_val.html)
-   [`Layout::for_value`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.for_value)
-   [`Layout::align_to`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.align_to)
-   [`Layout::pad_to_align`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.pad_to_align)
-   [`Layout::extend`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.extend)
-   [`Layout::array`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.array)
-   [`std::mem::swap`](https://doc.rust-lang.org/stable/std/mem/fn.swap.html)
-   [`std::ptr::swap`](https://doc.rust-lang.org/stable/std/ptr/fn.swap.html)
-   [`NonNull::new`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.new)
-   [`HashMap::with_hasher`](https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html#method.with_hasher)
-   [`HashSet::with_hasher`](https://doc.rust-lang.org/stable/std/collections/struct.HashSet.html#method.with_hasher)
-   [`BuildHasherDefault::new`](https://doc.rust-lang.org/stable/std/hash/struct.BuildHasherDefault.html#method.new)
-   [`<float>::recip`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.recip)
-   [`<float>::to_degrees`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.to_degrees)
-   [`<float>::to_radians`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.to_radians)
-   [`<float>::max`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.max)
-   [`<float>::min`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.min)
-   [`<float>::clamp`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.clamp)
-   [`<float>::abs`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.abs)
-   [`<float>::signum`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.signum)
-   [`<float>::copysign`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.copysign)
-   [`MaybeUninit::write`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.write)

<a id="1.85.0-Cargo"></a>

## Cargo

-   [Add future-incompatibility warning against keywords in cfgs and add raw-idents](https://redirect.github.com/rust-lang/cargo/pull/14671/)
-   [Stabilize higher precedence trailing flags](https://redirect.github.com/rust-lang/cargo/pull/14900/)
-   [Pass `CARGO_CFG_FEATURE` to build scripts](https://redirect.github.com/rust-lang/cargo/pull/14902/)

<a id="1.85.0-Rustdoc"></a>

## Rustdoc

-   [Doc comment on impl blocks shows the first line, even when the impl block is collapsed](https://redirect.github.com/rust-lang/rust/pull/132155)

<a id="1.85.0-Compatibility-Notes"></a>

## Compatibility Notes

-   [`rustc` no longer treats the `test` cfg as a well known check-cfg](https://redirect.github.com/rust-lang/rust/pull/131729), instead it is up to the build systems and users of `--check-cfg`\[^check-cfg] to set it as a well known cfg using `--check-cfg=cfg(test)`.

    This is done to enable build systems like Cargo to set it conditionally, as not all source files are suitable for unit tests.
    [Cargo (for now) unconditionally sets the `test` cfg as a well known cfg](https://redirect.github.com/rust-lang/cargo/pull/14963).
    \[^check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html
-   [Disable potentially incorrect type inference if there are trivial and non-trivial where-clauses](https://redirect.github.com/rust-lang/rust/pull/132325)
-   `std::env::home_dir()` has been deprecated for years, because it can give surprising results in some Windows configurations if the `HOME` environment variable is set (which is not the normal configuration on Windows). We had previously avoided changing its behavior, out of concern for compatibility with code depending on this non-standard configuration. Given how long this function has been deprecated, we're now fixing its behavior as a bugfix. A subsequent release will remove the deprecation for this function.
-   [Make `core::ffi::c_char` signedness more closely match that of the platform-default `char`](https://redirect.github.com/rust-lang/rust/pull/132975)

    This changed `c_char` from an `i8` to `u8` or vice versa on many Tier 2 and 3
    targets (mostly Arm and RISC-V embedded targets). The new definition may
    result in compilation failures but fixes compatibility issues with C.

    The `libc` crate matches this change as of its 0.2.169 release.
-   [When compiling a nested `macro_rules` macro from an external crate, the content of the inner `macro_rules` is now built with the edition of the external crate, not the local crate.](https://redirect.github.com/rust-lang/rust/pull/133274)
-   [Increase `sparcv9-sun-solaris` and `x86_64-pc-solaris` Solaris baseline to 11.4.](https://redirect.github.com/rust-lang/rust/pull/133293)
-   [Show `abi_unsupported_vector_types` lint in future breakage reports](https://redirect.github.com/rust-lang/rust/pull/133374)
-   [Error if multiple super-trait instantiations of `dyn Trait` need associated types to be specified but only one is provided](https://redirect.github.com/rust-lang/rust/pull/133392)
-   [Change `powerpc64-ibm-aix` default `codemodel` to large](https://redirect.github.com/rust-lang/rust/pull/133811)

<a id="1.85.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.

-   [Build `x86_64-unknown-linux-gnu` with LTO for C/C++ code (e.g., `jemalloc`)](https://redirect.github.com/rust-lang/rust/pull/134690)

</details>

---

### Configuration

📅 **Schedule**: 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:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNzYuMiIsInVwZGF0ZWRJblZlciI6IjM5LjE3Ni4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2025-02-21 04:33:26 +00:00
Boshen dde05e3d97 feat(mangler): opt-out of direct eval (#9191)
Context:

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
* https://esbuild.github.io/content-types/#direct-eval
2025-02-18 10:31:24 +00:00
Boshen 66222ce45a chore(deps): update rust crates (#9002) 2025-02-10 07:54:24 +00:00
overlookmotel a4a8e7deda style(all): replace #[allow] with #[expect] (#8930)
Replace `#[allow]` with `#[expect]` through the whole codebase.

This also surfaced many places where the `#[allow]` attributes were outdated/pointless and could be removed entirely.

Only places `#[allow]` remains are:

1. In generated code and macros, where lint errors may or may not be triggered depending on the generated code.
2. A few places where clippy malfunctions. These use e.g. `#[allow(unused, clippy::allow_attributes)]`.
2025-02-07 14:50:02 +00:00
Dunqing c79206850c refactor(semantic): simplify ScopeTree::iter_bindings (#8723)
The previous implementation is a little weird, I think it should be a shortcut of `bindings.iter`, It is infrequent we need to iter all symbols and know its scope ID. Only two cases in tests, and no use case in `Rolldown`
2025-01-26 10:53:48 +00:00
Boshen a3dc4c3cbe refactor(crates): clean up snapshot files (#8680) 2025-01-23 14:43:32 +00:00
Valentinas Janeiko 4ce63298e8 fix(semantic)!: ensure program outlives semantic (#8455)
fixes: #8437 

In semantic builder make sure `Program` reference has a lifetime of the
Arena.

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-01-16 10:04:25 +08:00