Skip to content

Commit 30f9807

Browse files
committed
Sort FxHashSet's contents before emitting errors for consistent output
1 parent 76713c9 commit 30f9807

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

compiler/rustc_interface/src/passes.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,10 @@ pub fn configure_and_expand(
447447

448448
// Gate identifiers containing invalid Unicode codepoints that were recovered during lexing.
449449
sess.parse_sess.bad_unicode_identifiers.with_lock(|identifiers| {
450-
for (ident, spans) in identifiers.drain() {
450+
let mut identifiers: Vec<_> = identifiers.drain().collect();
451+
identifiers.sort_by_key(|&(key, _)| key);
452+
for (ident, mut spans) in identifiers.into_iter() {
453+
spans.sort();
451454
sess.diagnostic().span_err(
452455
MultiSpan::from(spans),
453456
&format!("identifiers cannot contain emoji: `{}`", ident),

src/test/ui/parser/emoji-identifiers.stderr

+20-20
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,11 @@ LL | fn i_like_to_😅_a_lot() -> 👀 {
1818
LL | let _ = i_like_to_😄_a_lot() ➖ 4;
1919
| ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_😅_a_lot`
2020

21-
error: identifiers cannot contain emoji: `i_like_to_😄_a_lot`
22-
--> $DIR/emoji-identifiers.rs:13:13
23-
|
24-
LL | let _ = i_like_to_😄_a_lot() ➖ 4;
25-
| ^^^^^^^^^^^^^^^^^^
26-
27-
error: identifiers cannot contain emoji: `full_of_✨`
28-
--> $DIR/emoji-identifiers.rs:4:8
29-
|
30-
LL | fn full_of_✨() -> 👀 {
31-
| ^^^^^^^^^^
32-
33-
error: identifiers cannot contain emoji: `full_of✨`
34-
--> $DIR/emoji-identifiers.rs:9:8
21+
error: identifiers cannot contain emoji: `ABig👩👩👧👧Family`
22+
--> $DIR/emoji-identifiers.rs:1:8
3523
|
36-
LL | 👀::full_of✨()
37-
| ^^^^^^^^^
24+
LL | struct ABig👩👩👧👧Family;
25+
| ^^^^^^^^^^^^^^^^^^
3826

3927
error: identifiers cannot contain emoji: `👀`
4028
--> $DIR/emoji-identifiers.rs:2:8
@@ -53,17 +41,29 @@ LL | fn i_like_to_😅_a_lot() -> 👀 {
5341
LL | 👀::full_of✨()
5442
| ^^
5543

44+
error: identifiers cannot contain emoji: `full_of_✨`
45+
--> $DIR/emoji-identifiers.rs:4:8
46+
|
47+
LL | fn full_of_✨() -> 👀 {
48+
| ^^^^^^^^^^
49+
5650
error: identifiers cannot contain emoji: `i_like_to_😅_a_lot`
5751
--> $DIR/emoji-identifiers.rs:8:4
5852
|
5953
LL | fn i_like_to_😅_a_lot() -> 👀 {
6054
| ^^^^^^^^^^^^^^^^^^
6155

62-
error: identifiers cannot contain emoji: `ABig👩👩👧👧Family`
63-
--> $DIR/emoji-identifiers.rs:1:8
56+
error: identifiers cannot contain emoji: `full_of✨`
57+
--> $DIR/emoji-identifiers.rs:9:8
6458
|
65-
LL | struct ABig👩👩👧👧Family;
66-
| ^^^^^^^^^^^^^^^^^^
59+
LL | 👀::full_of✨()
60+
| ^^^^^^^^^
61+
62+
error: identifiers cannot contain emoji: `i_like_to_😄_a_lot`
63+
--> $DIR/emoji-identifiers.rs:13:13
64+
|
65+
LL | let _ = i_like_to_😄_a_lot() ➖ 4;
66+
| ^^^^^^^^^^^^^^^^^^
6767

6868
error[E0599]: no function or associated item named `full_of✨` found for struct `👀` in the current scope
6969
--> $DIR/emoji-identifiers.rs:9:8

0 commit comments

Comments
 (0)