Repository navigation
Introduce rustc-unicode crate for centralising Unicode version management
#165302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [package] | ||
| name = "rustc_unicode" | ||
| version = "0.0.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] | ||
| # tidy-alphabetical-start | ||
| unicode-ident = "=1.0.24" | ||
| unicode-normalization = "=0.1.25" | ||
| unicode-properties = { version = "=0.1.4", default-features = false, features = ["emoji"] } | ||
| unicode-script = "=0.5.8" | ||
| unicode-security = "=0.1.2" | ||
| unicode-width = "=0.2.2" | ||
| # tidy-alphabetical-end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //! Unified crate for re-exporting Unicode crates for the compiler. | ||
| //! Used to avoid having multiple different Unicode versions in use. | ||
|
|
||
| // 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`)" | ||
| ) | ||
| ) | ||
| } | ||
| }; | ||
| )+ | ||
| } | ||
| } | ||
|
Comment on lines
+4
to
+25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably this should check I assume some
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| reexport_and_check!( | ||
| // tidy-alphabetical-start | ||
| unicode_ident, | ||
| unicode_normalization, | ||
| unicode_properties, | ||
| // FIXME: Update to version supporting Unicode 17 | ||
| // unicode_security, | ||
| unicode_script, | ||
| unicode_width, | ||
| // tidy-alphabetical-end | ||
| ); | ||
| pub use unicode_security; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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_lexerIIUC). Not sure if your change would break their process..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/would.20using.20rustc_unicode.20be.20okay.3F/with/636737291
Right now, it would
There was a problem hiding this comment.
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.