[rust] add Location line/column and chop methods#3890
Draft
[rust] add Location line/column and chop methods#3890
Location line/column and chop methods#3890Conversation
Location line/column and chop methods
Collaborator
|
Let's wait on #3860 for this. |
kddnewton
reviewed
Feb 18, 2026
rust/ruby-prism-sys/src/lib.rs
Outdated
| extern "C" { | ||
| /// Return the line and column number for the given byte offset relative to | ||
| /// the beginning of the source. | ||
| pub fn pm_newline_list_line_column( |
Collaborator
There was a problem hiding this comment.
This doesn't exist anymore, because it was renamed. Please rebase.
Port Ruby's `node_ext.rb` functionality to Rust bindings, providing `full_name` and `full_name_parts` methods for `ConstantReadNode`, `ConstantWriteNode`, `ConstantTargetNode`, `ConstantPathNode`, and `ConstantPathTargetNode`. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… `chop` methods for `Location` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…list_line_column Bindgen cannot generate bindings for these symbols on the WASM target, causing CI failures. Replace the bindgen allowlist entries with hand- written repr(C) struct and extern C declarations so they work on all targets (native and WASM). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add pm_line_offset_list_t to the bindgen allowlist and update the manual FFI declarations and usage to match the upstream rename. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b732d58 to
455afd6
Compare
froydnj
reviewed
Feb 18, 2026
Comment on lines
+39
to
+48
| /// Line and column information for a given byte offset relative to the | ||
| /// beginning of the source. | ||
| #[repr(C)] | ||
| #[derive(Debug, Clone, Copy)] | ||
| pub struct pm_line_column_t { | ||
| /// The 1-indexed line number relative to the start line configured on the | ||
| /// parser. | ||
| pub line: i32, | ||
| /// The 0-indexed column number in bytes. | ||
| pub column: u32, |
Contributor
There was a problem hiding this comment.
The commit message for this explains that these are troublesome for the WASM target...but why are they troublesome, and can that be fixed instead? They really shouldn't be treated any differently than other structures, and it would be better to not maintain these declarations by hand. I trust bindgen more than manual declarations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
start_line()method toLocation(Rust equivalent of Ruby'sLocation#start_line)end_line()method toLocation(Rust equivalent of Ruby'sLocation#end_line)start_column()method toLocation(Rust equivalent of Ruby'sLocation#start_column)end_column()method toLocation(Rust equivalent of Ruby'sLocation#end_column)chop()method toLocation(Rust equivalent of Ruby'sLocation#chop)These methods use the C API
pm_newline_list_line_columnfunction to compute line and column numbers.Public API Changes
Test plan
bundle exec rake cargo:testbundle exec rake cargo:lint🤖 Generated with Claude Code