Skip to content
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

Add test to check unicode identifier version #134043

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub mod unescape;
mod tests;

use unicode_properties::UnicodeEmoji;
pub use unicode_xid::UNICODE_VERSION as UNICODE_XID_VERSION;

use self::LiteralKind::*;
use self::TokenKind::*;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::{Diag, FatalError, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::{FileName, SourceFile, Span};
pub use unicode_normalization::UNICODE_VERSION as UNICODE_NORMALIZATION_VERSION;

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

Expand Down
27 changes: 27 additions & 0 deletions tests/ui-fulldeps/lexer/unicode-version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This test is used to validate which version of Unicode is used for parsing
// identifiers. If the Unicode version changes, it should also be updated in
// the reference at
// https://github.com/rust-lang/reference/blob/HEAD/src/identifiers.md.

//@ run-pass
//@ check-run-results
//@ ignore-cross-compile
//@ reference: ident.unicode
//@ reference: ident.normalization

#![feature(rustc_private)]

extern crate rustc_driver;
extern crate rustc_lexer;
extern crate rustc_parse;

fn main() {
println!("Checking if Unicode version changed.");
println!(
"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."
);
println!("Unicode XID version is: {:?}", rustc_lexer::UNICODE_XID_VERSION);
println!("Unicode normalization version is: {:?}", rustc_parse::UNICODE_NORMALIZATION_VERSION);
}
4 changes: 4 additions & 0 deletions tests/ui-fulldeps/lexer/unicode-version.run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Checking if Unicode version changed.
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.
Unicode XID version is: (16, 0, 0)
Unicode normalization version is: (16, 0, 0)
7 changes: 7 additions & 0 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,13 @@ cc = ["@Zalathar"]
[mentions."src/tools/opt-dist"]
cc = ["@kobzol"]

[mentions."tests/ui-fulldeps/lexer/unicode-version.run.stdout"]
message = """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 = ["@ehuss"]

[assign]
warn_non_default_branch = true
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
Expand Down
Loading