Skip to content

impl jsstr_to_string and latin1_to_string using &JSContext#718

Open
sagudev wants to merge 4 commits into
servo:mainfrom
sagudev:to_string_safe
Open

impl jsstr_to_string and latin1_to_string using &JSContext#718
sagudev wants to merge 4 commits into
servo:mainfrom
sagudev:to_string_safe

Conversation

@sagudev
Copy link
Copy Markdown
Member

@sagudev sagudev commented Mar 15, 2026

Testing: Change is covered by existing tests.

Comment thread mozjs/src/conversions.rs
/// `String`.
///
/// Use [`latin1_to_string_safe`] if possible as this function will be eventually removed.
pub unsafe fn latin1_to_string(cx: *mut JSContext, s: NonNull<JSString>) -> String {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we perhaps add a deprecated annotation on it, or call it _legacy to make the comment about "will eventually be removed" more obvious at the usage sites?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The way we are currently doing is just adding comments without renames/deprecation notice for less friction in servo. But eventually we should start doing this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are only a couple of places left where we can't switch to the safe version yet; so with a companion pr that migrates the other instances to the safe version, we can start deprecating the unsafe one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did this now, but I do not have time for companion PR.

sagudev added 2 commits May 29, 2026 05:54
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
sagudev added 2 commits May 29, 2026 05:58
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
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.

3 participants