Skip to content

Introduce rustc-unicode crate for centralising Unicode version management - #165302

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
clubby789:rustc-unicode
Nov 23, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
clubby789:rustc-unicode

Conversation

@clubby789

@clubby789 clubby789 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Related to #165289.
I noticed that, while we check that UNICODE_VERSION is consistent across several crates, not all are included in the check. This introduces a new rustc-unicode crate which handles depending on any unicode-* crates, checks their versions are consistent, and re-exports them.
unicode-script is one such crate that wasn't being checked, so update the version of that crate.

@clubby789 clubby789 added the A-Unicode Area: Unicode label Nov 1, 2026
@rustbot

rustbot commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

If the Unicode version changes are intentional,
it should also be updated in the reference at
https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md.

cc @rust-lang/lang-docs

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 1, 2026
@rustbot

rustbot commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 22 candidates

[lib]

# Note that this crate purposefully does not depend on other rustc crates
# Note that this crate purposefully does not depend on other rustc crates other than `rustc-unicode`

@clubby789 clubby789 Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is appropriate, and how better to resolve this

View changes since the review

@fmease fmease Nov 1, 2026 •

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.

Well, the reason for this is the fact that rust-analyzer wants to depend on this crate (or rather their republish, ra-ap-rustc_lexer IIUC). Not sure if your change would break their process..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

I think it should be fine as long as rustc_unicode doesn't use unstable features.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Nov 1, 2026
@clubby789

Copy link
Copy Markdown
Contributor Author

Opened draft PRs to rustc-auto-publish and team to handle publishing this, if this change lands.

Comment thread compiler/rustc_unicode/src/lib.rs Resolved
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@fmease fmease left a comment •

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.

Some comments, then r=me.

(I assume this should get merged before both rust-analyzer/rustc-auto-publish#16 and rust-lang/team#2898.)

View changes since this review

Comment thread compiler/rustc_unicode/src/lib.rs Resolved
Comment thread compiler/rustc_unicode/src/lib.rs Resolved
Comment thread compiler/rustc_unicode/src/lib.rs Resolved
Comment thread compiler/rustc_unicode/src/lib.rs Outdated
let (major, minor, patch) = UNICODE_VERSION;
let (major_, minor_, patch_) = char::UNICODE_VERSION;
if major != major_ as u8 || minor != minor_ as u8 || patch != patch_ as u8 {
panic!("rustc_unicode::UNICODE_VERSION does not match char::UNICODE_VERSION",)

@fmease fmease Nov 22, 2026 •

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.

Today, the Unicode version upgrades for libcore and the compiler are independent. Well, recently there have been motions to make the lexer use char::xid_{start,continue} from the stdlib (once it's stable+available to the bootstrap compiler) but for that, the (implicit) policies have to be changed. CC rust-lang/reference#2403, #164841.

Until then, I think it'd be great if you could leave a comment above the panic explaining to the next person trying to upgrade libcore's Unicode version that at the time of writing it's okay if {self,char}::UNICODE_VERSION diverge temporarily by 1 major version and they should just temporarily update the code to something like

// FIXME: Upgrade the Unicode version of the language (needs lang FPC).
//if UNICODE_VERSION != char::UNICODE_VERSION {
//    panic!("...");
//}
let (lang_major, _, _) = UNICODE_VERSION;
let (lib_major, _, _) = char::UNICODE_VERSION;
if lang_major + 1 != lib_major {
    panic!("...");
}

(idk)

otherwise, if they wish to upgrade both in tandem, they need to request / start a lang pFCP on the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this as a const to flip rather than commented out code

Comment thread compiler/rustc_unicode/src/lib.rs Resolved
@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 22, 2026
@fmease fmease assigned fmease and unassigned jackh726 Nov 22, 2026
[lib]

# Note that this crate purposefully does not depend on other rustc crates
# Note that this crate purposefully does not depend on other rustc crates other than `rustc-unicode`

@fmease fmease Nov 22, 2026 •

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.

This comment could be made more precise by mentioning r-a's auto-publish script.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a comment, does this cover what you meant?

@clubby789
clubby789 force-pushed the rustc-unicode branch 2 times, most recently from e63b64b to c323adb Compare November 22, 2026 13:13
@rustbot

rustbot commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@fmease fmease left a comment •

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.

Perfect, thanks!

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b97cdbe has been approved by fmease

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 22, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
Rollup of 4 pull requests

Successful merges:

 - #166270 (Output type refactors & change analysis query into required_analysis)
 - #165302 (Introduce `rustc-unicode` crate for centralising Unicode version management)
 - #166249 (Tidy-sort and use more of `GeneratedAttr`)
 - #166370 (Disallow duplicates of `rustc_const_stable_indirect` and `allow_internal_unsafe` attributes)
@rust-bors
rust-bors Bot merged commit ca47e4d into rust-lang:main Nov 23, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
Rollup merge of #165302 - clubby789:rustc-unicode, r=fmease

Introduce `rustc-unicode` crate for centralising Unicode version management

Related to #165289.
I noticed that, while we check that `UNICODE_VERSION` is consistent across several crates, not all are included in the check. This introduces a new `rustc-unicode` crate which handles depending on any `unicode-*` crates, checks their versions are consistent, and re-exports them.
`unicode-script` is one such crate that wasn't being checked, so update the version of that crate.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 23, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#166270 (Output type refactors & change analysis query into required_analysis)
 - rust-lang/rust#165302 (Introduce `rustc-unicode` crate for centralising Unicode version management)
 - rust-lang/rust#166249 (Tidy-sort and use more of `GeneratedAttr`)
 - rust-lang/rust#166370 (Disallow duplicates of `rustc_const_stable_indirect` and `allow_internal_unsafe` attributes)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Nov 24, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#166270 (Output type refactors & change analysis query into required_analysis)
 - rust-lang/rust#165302 (Introduce `rustc-unicode` crate for centralising Unicode version management)
 - rust-lang/rust#166249 (Tidy-sort and use more of `GeneratedAttr`)
 - rust-lang/rust#166370 (Disallow duplicates of `rustc_const_stable_indirect` and `allow_internal_unsafe` attributes)
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 24, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#166270 (Output type refactors & change analysis query into required_analysis)
 - rust-lang/rust#165302 (Introduce `rustc-unicode` crate for centralising Unicode version management)
 - rust-lang/rust#166249 (Tidy-sort and use more of `GeneratedAttr`)
 - rust-lang/rust#166370 (Disallow duplicates of `rustc_const_stable_indirect` and `allow_internal_unsafe` attributes)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Nov 26, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#166270 (Output type refactors & change analysis query into required_analysis)
 - rust-lang/rust#165302 (Introduce `rustc-unicode` crate for centralising Unicode version management)
 - rust-lang/rust#166249 (Tidy-sort and use more of `GeneratedAttr`)
 - rust-lang/rust#166370 (Disallow duplicates of `rustc_const_stable_indirect` and `allow_internal_unsafe` attributes)
mehmettoplu-rs pushed a commit to mehmettoplu-rs/rustc_codegen_gcc that referenced this pull request Nov 27, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#166270 (Output type refactors & change analysis query into required_analysis)
 - rust-lang/rust#165302 (Introduce `rustc-unicode` crate for centralising Unicode version management)
 - rust-lang/rust#166249 (Tidy-sort and use more of `GeneratedAttr`)
 - rust-lang/rust#166370 (Disallow duplicates of `rustc_const_stable_indirect` and `allow_internal_unsafe` attributes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-Unicode Area: Unicode S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants