Skip to content

Comments

feat: show import declaration location in AssignToImport errors#8222

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-assign-to-import-error
Feb 7, 2026
Merged

feat: show import declaration location in AssignToImport errors#8222
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-assign-to-import-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

  • Understand the current AssignToImport error structure
  • Add optional import_declaration_span field to AssignToImport struct
  • Update constructor to accept the new field
  • Modify on_diagnostic to show import declaration span as a second label
  • Update call sites in import_analyzer.rs to retrieve and pass import declaration span from named_imports
  • Update test snapshots to verify the new error format
  • Build and test the changes
  • Fix formatting issues
  • Fix namespace import labels to show namespace name instead of property name
  • Fix namespace import span to highlight only the identifier, not the entire * as x specifier
  • Fix named import and default import spans to highlight only the local identifier
  • Fix clippy lint for inline format args
  • Use symbol table to get local binding span instead of modifying span_imported semantics
Original prompt

Show the import name declaration span for AssignToImport error message


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link

netlify bot commented Feb 6, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 316ad84
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69874a5758a7b9000851b364

Copilot AI changed the title [WIP] Fix AssignToImport error message display Show import declaration location in AssignToImport errors Feb 6, 2026
Copilot AI requested a review from sapphi-red February 6, 2026 13:19
@sapphi-red sapphi-red changed the title Show import declaration location in AssignToImport errors feat: show import declaration location in AssignToImport errors Feb 7, 2026
@sapphi-red
Copy link
Member

@copilot fix lint

Copy link
Contributor Author

Copilot AI commented Feb 7, 2026

@copilot fix lint

Fixed in d3e9fa2. Changed the format string to use inline variable syntax as required by clippy.

Copilot AI requested a review from sapphi-red February 7, 2026 10:46
@sapphi-red sapphi-red marked this pull request as ready for review February 7, 2026 10:52
Copilot AI review requested due to automatic review settings February 7, 2026 10:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the ASSIGN_TO_IMPORT diagnostic by adding a secondary label that points to where the import binding was declared, making it easier to understand where the immutable import originates.

Changes:

  • Extended AssignToImport to optionally carry an import-declaration span (and an optional imported/binding name for labeling).
  • Updated the assign_to_import constructor and the import analyzer call sites to pass import declaration context.
  • Updated snapshot tests to verify the new multi-label diagnostic output.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rolldown_error/src/build_diagnostic/events/assign_to_import.rs Adds an optional second label pointing at the import declaration.
crates/rolldown_error/src/build_diagnostic/constructors.rs Extends assign_to_import constructor to accept the new optional fields.
crates/rolldown/src/ast_scanner/import_analyzer.rs Threads import declaration span + namespace binding name into the diagnostic.
crates/rolldown/src/ast_scanner/mod.rs Changes which spans are recorded for named/default imports.
crates/rolldown/tests//assign_to_import/.snap Updates snapshots to match the new diagnostic label output.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Benchmarks Rust

  • target: main(a3f2b53)
  • pr: copilot/fix-assign-to-import-error(d3e9fa2)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     70.6±2.27ms        ? ?/sec    1.00     70.6±2.22ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.04     79.5±3.23ms        ? ?/sec    1.00     76.7±1.86ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00     99.0±2.69ms        ? ?/sec    1.03    101.6±1.94ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    111.6±2.69ms        ? ?/sec    1.01    113.2±2.18ms        ? ?/sec
bundle/bundle@threejs                                        1.00     35.6±2.52ms        ? ?/sec    1.03     36.7±0.66ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     39.7±0.71ms        ? ?/sec    1.04     41.5±0.97ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    365.3±5.01ms        ? ?/sec    1.01    370.7±7.58ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    423.8±8.12ms        ? ?/sec    1.00    422.6±5.09ms        ? ?/sec
scan/scan@rome_ts                                            1.00     79.9±1.66ms        ? ?/sec    1.02     81.6±1.83ms        ? ?/sec
scan/scan@threejs                                            1.00     27.5±0.47ms        ? ?/sec    1.04     28.6±1.88ms        ? ?/sec
scan/scan@threejs10x                                         1.00    279.8±5.07ms        ? ?/sec    1.03    289.2±4.38ms        ? ?/sec

@sapphi-red sapphi-red self-requested a review February 7, 2026 11:54
@sapphi-red sapphi-red marked this pull request as ready for review February 7, 2026 14:17
Copilot AI review requested due to automatic review settings February 7, 2026 14:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Copy link
Member

sapphi-red commented Feb 7, 2026

Merge activity

  • Feb 7, 2:20 PM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 7, 2:20 PM UTC: sapphi-red added this pull request to the Graphite merge queue.
  • Feb 7, 2:30 PM UTC: Merged by the Graphite merge queue.

- [x] Understand the current AssignToImport error structure
- [x] Add optional import_declaration_span field to AssignToImport struct
- [x] Update constructor to accept the new field
- [x] Modify on_diagnostic to show import declaration span as a second label
- [x] Update call sites in import_analyzer.rs to retrieve and pass import declaration span from named_imports
- [x] Update test snapshots to verify the new error format
- [x] Build and test the changes
- [x] Fix formatting issues
- [x] Fix namespace import labels to show namespace name instead of property name
- [x] Fix namespace import span to highlight only the identifier, not the entire `* as x` specifier
- [x] Fix named import and default import spans to highlight only the local identifier
- [x] Fix clippy lint for inline format args
- [x] Use symbol table to get local binding span instead of modifying span_imported semantics

<!-- START COPILOT CODING AGENT SUFFIX -->

<!-- START COPILOT ORIGINAL PROMPT -->

<details>

<summary>Original prompt</summary>

> Show the import name declaration span for AssignToImport error message

</details>

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
@graphite-app graphite-app bot force-pushed the copilot/fix-assign-to-import-error branch from 2302354 to 316ad84 Compare February 7, 2026 14:21
@graphite-app graphite-app bot merged commit 316ad84 into main Feb 7, 2026
34 checks passed
@graphite-app graphite-app bot deleted the copilot/fix-assign-to-import-error branch February 7, 2026 14:30
This was referenced Feb 11, 2026
shulaoda added a commit that referenced this pull request Feb 11, 2026
## [1.0.0-rc.4] - 2026-02-11

💡 Granular `comments` Option
- New `output.comments` option provides fine-grained control over comment preservation
- The `output.legalComments` option is now deprecated and use `comments.legal` instead

### 🚀 Features

- rename error name to `RolldownError` from `RollupError` (#8262) by @sapphi-red
- add hidden `resolve_tsconfig` function for Vite (#8257) by @sapphi-red
- rust: introduce `rolldown_watcher` (#8161) by @hyf0
- unify `comments` and `legalComments` into a single granular `comments` option (#8229) by @IWANABETHATGUY
- add builtin plugin for visualizing chunk graph (#8162) by @IWANABETHATGUY
- show import declaration location in AssignToImport errors (#8222) by @Copilot
- show import declaration span in CannotCallNamespace error (#8223) by @Copilot
- emit error when plugin accidentally removes runtime module symbols (#8203) by @IWANABETHATGUY
- support tsconfig loading & inputMap for `transform` (#8180) by @sapphi-red
- rolldown_plugin_vite_reporter: update warning message to link to Rolldown docs (#8205) by @sapphi-red

### 🐛 Bug Fixes

- avoid panic on untranspiled JSX syntax by reporting a diagnostic error (#8226) by @IWANABETHATGUY
- rolldown_plugin_vite_import_glob: relax absolute path check and improve invalid glob warning (#8219) by @shulaoda
- merge chunks after detect circular reference (#8154) by @IWANABETHATGUY
- rust: detect runtime module side effects based on its content (#8209) by @hyf0

### 🚜 Refactor

- rename `other` to `jsdoc` in comments options (#8256) by @IWANABETHATGUY
- rename chunk-visualize plugin with bundle-analyzer plugin (#8255) by @IWANABETHATGUY
- remove EXPORT_UNDEFINED_VARIABLE error (#8228) by @Copilot
- consolidate missing runtime symbol errors into a single diagnostic (#8220) by @IWANABETHATGUY
- stabilize `parse` and `parseSync` (#8215) by @sapphi-red
- return errors instead of panicking on builtin plugin conversion failure (#8217) by @shulaoda
- expose `parse` / `minify` / `transform` from `rolldown/utils` (#8214) by @sapphi-red
- prepare defer chunk merging (#8153) by @IWANABETHATGUY

### 📚 Documentation

- remove `<script>` escape behavior difference note from `platform` option (#8253) by @sapphi-red
- TypeScript & JSX support by plugins (#8183) by @sapphi-red

### 🧪 Testing

- ensure runtime module is preserved even if it's not used but has side effects (#8213) by @hyf0

### ⚙️ Miscellaneous Tasks

- deps: update oxc to v0.113.0 (#8267) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.12.0 (#8272) by @renovate[bot]
- deps: update oxc apps (#8269) by @renovate[bot]
- deps: update test262 submodule for tests (#8261) by @sapphi-red
- deps: update crate-ci/typos action to v1.43.4 (#8260) by @renovate[bot]
- deps: update dependency esbuild to v0.27.3 (#8250) by @renovate[bot]
- deps: update rust crates (#8244) by @renovate[bot]
- deps: update dependency semver to v7.7.4 (#8247) by @renovate[bot]
- deps: update github-actions (#8243) by @renovate[bot]
- deps: update npm packages (#8245) by @renovate[bot]
- deps: update oxc resolver to v11.17.1 (#8240) by @renovate[bot]
- deps: update rust crate oxc_sourcemap to v6.0.2 (#8241) by @renovate[bot]
- rust: handle ignored `RUSTSEC-2025-0141` cargo check error (#8235) by @hyf0
- deps: update dependency oxlint-tsgolint to v0.11.5 (#8233) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.22.0 (#8232) by @renovate[bot]
- deps: update crate-ci/typos action to v1.43.3 (#8225) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.21.9 (#8224) by @renovate[bot]
- deps: update crate-ci/typos action to v1.43.2 (#8212) by @renovate[bot]
- remove rolldown_plugin_vite_wasm_helper (#8207) by @shulaoda
- build docs for production (#8206) by @sapphi-red

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants