Skip to content

Commit 0cb12f9

Browse files
authored
Rollup merge of rust-lang#134043 - ehuss:unicode-version, r=jieyouxu
Add test to check unicode identifier version This adds a test to verify which version of Unicode is used for identifiers. This is part of the language, documented at https://doc.rust-lang.org/nightly/reference/identifiers.html#r-ident.unicode. The version here often changes implicitly due to dependency updates pulling in new versions, and thus we often don't notice it has changed leaving the documentation out of date. The intent here is to have a canary to give us a notification when it changes so that we can update the documentation.
2 parents b282774 + a97404e commit 0cb12f9

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

Diff for: compiler/rustc_lexer/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub mod unescape;
3333
mod tests;
3434

3535
use unicode_properties::UnicodeEmoji;
36+
pub use unicode_xid::UNICODE_VERSION as UNICODE_XID_VERSION;
3637

3738
use self::LiteralKind::*;
3839
use self::TokenKind::*;

Diff for: compiler/rustc_parse/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_data_structures::sync::Lrc;
2424
use rustc_errors::{Diag, FatalError, PResult};
2525
use rustc_session::parse::ParseSess;
2626
use rustc_span::{FileName, SourceFile, Span};
27+
pub use unicode_normalization::UNICODE_VERSION as UNICODE_NORMALIZATION_VERSION;
2728

2829
pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments");
2930

Diff for: tests/ui-fulldeps/lexer/unicode-version.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test is used to validate which version of Unicode is used for parsing
2+
// identifiers. If the Unicode version changes, it should also be updated in
3+
// the reference at
4+
// https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md.
5+
6+
//@ run-pass
7+
//@ check-run-results
8+
//@ ignore-cross-compile
9+
//@ reference: ident.unicode
10+
//@ reference: ident.normalization
11+
12+
#![feature(rustc_private)]
13+
14+
extern crate rustc_driver;
15+
extern crate rustc_lexer;
16+
extern crate rustc_parse;
17+
18+
fn main() {
19+
println!("Checking if Unicode version changed.");
20+
println!(
21+
"If the Unicode version changes are intentional, \
22+
it should also be updated in the reference at \
23+
https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md."
24+
);
25+
println!("Unicode XID version is: {:?}", rustc_lexer::UNICODE_XID_VERSION);
26+
println!("Unicode normalization version is: {:?}", rustc_parse::UNICODE_NORMALIZATION_VERSION);
27+
}

Diff for: tests/ui-fulldeps/lexer/unicode-version.run.stdout

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Checking if Unicode version changed.
2+
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.
3+
Unicode XID version is: (16, 0, 0)
4+
Unicode normalization version is: (16, 0, 0)

Diff for: triagebot.toml

+7
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,13 @@ cc = ["@Zalathar"]
983983
[mentions."src/tools/opt-dist"]
984984
cc = ["@kobzol"]
985985

986+
[mentions."tests/ui-fulldeps/lexer/unicode-version.run.stdout"]
987+
message = """If the Unicode version changes are intentional,
988+
it should also be updated in the reference at
989+
https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md.
990+
"""
991+
cc = ["@ehuss"]
992+
986993
[assign]
987994
warn_non_default_branch = true
988995
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"

0 commit comments

Comments
 (0)