Repository navigation
Introduce rustc-unicode crate for centralising Unicode version management - #165302
Conversation
|
If the Unicode version changes are intentional, cc @rust-lang/lang-docs These commits modify the If this was unintentional then you should revert the changes before this PR is merged. The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| [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` |
There was a problem hiding this comment.
Not sure if this is appropriate, and how better to resolve this
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
There was a problem hiding this comment.
I think it should be fine as long as rustc_unicode doesn't use unstable features.
57b2272 to
02dd39e
Compare
This comment has been minimized.
This comment has been minimized.
02dd39e to
6de7046
Compare
|
Opened draft PRs to |
This comment has been minimized.
This comment has been minimized.
6de7046 to
a66af0b
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Some comments, then r=me.
(I assume this should get merged before both rust-analyzer/rustc-auto-publish#16 and rust-lang/team#2898.)
| 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",) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Added this as a const to flip rather than commented out code
| [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` |
There was a problem hiding this comment.
This comment could be made more precise by mentioning r-a's auto-publish script.
There was a problem hiding this comment.
Added a comment, does this cover what you meant?
e63b64b to
c323adb
Compare
c323adb to
b97cdbe
Compare
|
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. |
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)
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.
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)
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)
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)
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)
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)
View all comments
Related to #165289.
I noticed that, while we check that
UNICODE_VERSIONis consistent across several crates, not all are included in the check. This introduces a newrustc-unicodecrate which handles depending on anyunicode-*crates, checks their versions are consistent, and re-exports them.unicode-scriptis one such crate that wasn't being checked, so update the version of that crate.