Skip to content

Commit 2ae115c

Browse files
committed
Remove workarounds and writeup of the emoji-in-unknown-prefix bug
This bug is now fixed in stable rustc. See rust-lang/rust#123696 rust-lang/rust#123752
1 parent 095df3e commit 2ae115c

File tree

4 files changed

+3
-40
lines changed

4 files changed

+3
-40
lines changed

src/proptesting.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use proptest::{
44
strategy::{BoxedStrategy, Strategy},
55
test_runner::{Config, TestCaseError, TestError, TestRunner},
66
};
7-
use regex::Regex;
87

98
use crate::Edition;
109
use crate::{
@@ -17,13 +16,6 @@ use self::strategies::SIMPLE_STRATEGIES;
1716

1817
mod strategies;
1918

20-
macro_rules! make_regex_with_default_flags {
21-
($re:literal $(,)?) => {{
22-
static RE: ::std::sync::OnceLock<regex::Regex> = ::std::sync::OnceLock::new();
23-
RE.get_or_init(|| Regex::new($re).unwrap())
24-
}};
25-
}
26-
2719
/// Implements the `proptest` cli subcommand.
2820
pub fn run_proptests(strategy_name: &str, count: u32, verbosity: Verbosity, edition: Edition) {
2921
println!("Running property tests with strategy {strategy_name} for {count} iterations");
@@ -60,16 +52,7 @@ pub fn run_proptests(strategy_name: &str, count: u32, verbosity: Verbosity, edit
6052
///
6153
/// Returns Unsupported for input that may trigger known problems.
6254
fn check_lexing(input: &str, edition: Edition) -> ComparisonStatus {
63-
if edition == Edition::E2015 {
64-
// In Rust 2015 and 2018, emoji in unknown prefixes aren't reported as an error.
65-
// I think this is a rustc bug, so exclude such cases from testing.
66-
// See https://github.com/rust-lang/rust/issues/123696
67-
let re =
68-
make_regex_with_default_flags!(r#"[\p{EMOJI}--!-~][\p{XID_Continue}\p{EMOJI}]*[#'"]"#);
69-
if re.is_match(input) {
70-
return ComparisonStatus::Unsupported("emoji-in-unknown-prefix".into());
71-
}
72-
}
55+
// See the history of this function for how to use `Unsupported`
7356

7457
let rustc = regularised_from_rustc(input, edition);
7558
let lexlucid = regularised_from_lexlucid(input, edition);

src/testcases.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ pub const LONGLIST: &[&str] = [
214214
"qr# ",
215215
"qr#x",
216216

217-
// This is accepted in Rust 2015, but I think that's a rustc bug.
218-
// https://github.com/rust-lang/rust/issues/123696
217+
// See https://github.com/rust-lang/rust/issues/123696
218+
// (Fixed in rustc 1.79)
219219
"🦁#",
220220

221221
//// Double-quote forms

writeup/introduction.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ This description aims to accept input exactly if `rustc`'s lexer would.
4242
Specifically, it aims to model what's accepted as input to a function-like macro
4343
(a procedural macro or a by-example macro using the `tt` fragment specifier).
4444

45-
> See [emoji-in-unknown-prefix] for an exception
46-
4745
It's not attempting to accurately model `rustc`'s "reasons" for rejecting input,
4846
or to provide enough information to reproduce error messages similar to `rustc`'s.
4947

@@ -92,5 +90,3 @@ The source code for this document and the accompanying lexer implementation is a
9290
[rfc3349]: https://rust-lang.github.io/rfcs/3349-mixed-utf8-literals.html
9391
[rfc3593]: https://github.com/rust-lang/rfcs/pull/3593
9492

95-
[emoji-in-unknown-prefix]: rustc_oddities.md#emoji-in-unknown-prefix
96-

writeup/rustc_oddities.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
## Rustc oddities
22

3-
### emoji-in-unknown-prefix in Rust 2015/2018 { #emoji-in-unknown-prefix }
4-
5-
Rust 2015 and 2018 accept a form like `🦁#`
6-
(as input to a function-like macro),
7-
treating it as an identifier `🦁` followed by punctuation `#`.
8-
9-
This is surprising, because `🦁` would normally be rejected as an identifier.
10-
11-
I assume this is just a bug (filed as [#123696]).
12-
13-
This document doesn't attempt to characterise this behaviour,
14-
and the comparable implementation doesn't attempt to imitate it.
15-
16-
173
### NFC normalisation for lifetime/label { #nfc-lifetime }
184

195
Identifiers are normalised to NFC,
@@ -36,5 +22,3 @@ reaction to being given a spec to review.
3622
[playground-ident]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=aad27eb75b2774f16fc6b0981b770d56
3723

3824
[rfc2457]: https://rust-lang.github.io/rfcs/2457-non-ascii-idents.html
39-
40-
[#123696]: https://github.com/rust-lang/rust/issues/123696

0 commit comments

Comments
 (0)