Skip to content

Commit a97404e

Browse files
committed
Add test to check unicode identifier version
1 parent f33a8c6 commit a97404e

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
@@ -991,6 +991,13 @@ cc = ["@Zalathar"]
991991
[mentions."src/tools/opt-dist"]
992992
cc = ["@kobzol"]
993993

994+
[mentions."tests/ui-fulldeps/lexer/unicode-version.run.stdout"]
995+
message = """If the Unicode version changes are intentional,
996+
it should also be updated in the reference at
997+
https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md.
998+
"""
999+
cc = ["@ehuss"]
1000+
9941001
[assign]
9951002
warn_non_default_branch = true
9961003
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"

0 commit comments

Comments
 (0)