Skip to content

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

Open
clubby789 wants to merge 2 commits into
rust-lang:mainfrom
clubby789:rustc-unicode
Open

clubby789 wants to merge 2 commits into
rust-lang:mainfrom
clubby789:rustc-unicode

Conversation

@clubby789

Copy link
Copy Markdown
Contributor

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 on lines +4 to +25
// If this changes, update https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md.
const UNICODE_VERSION: (u8, u8, u8) = (17, 0, 0);

macro_rules! reexport_and_check {
($($krate:ident),+ $(,)?) => {
$(
pub use $krate;
const _: () = {
let (major, minor, patch) = crate::UNICODE_VERSION;
let (major_, minor_, patch_) = $krate::UNICODE_VERSION;
if major != major_ as u8 || minor != minor_ as u8 || patch != patch_ as u8 {
panic!(
concat!(
stringify!($krate),
" does not have the correct Unicode version (`rustc-unicode::UNICODE_VERSION`)"
)
)
}
};
)+
}
}

@tgross35 tgross35 Nov 2, 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.

Presumably this should check char::UNICODE_VERSION as well, since that is relied upon pretty much everywhere. Cc #164841 (comment).

I assume some cfg(bootstrap) may be needed for that since we can't bump it independently.

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.

Since Unicode 18 is in use there, we won't be able to add that check until #165289 lands. Depending on the order of things getting merged I'll open up a followup PR, or update this PR to Unicode 18.

This branch has not been deployed

No deployments
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-review Status: Awaiting review from the assignee but also interested parties. 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