]> git.lizzy.rs Git - rust.git/commitdiff
Sort `FxHashSet`'s contents before emitting errors for consistent output
authorEsteban Kuber <esteban@kuber.com.ar>
Tue, 14 Sep 2021 11:39:49 +0000 (11:39 +0000)
committerEsteban Kuber <esteban@kuber.com.ar>
Tue, 23 Nov 2021 20:37:24 +0000 (20:37 +0000)
compiler/rustc_interface/src/passes.rs
src/test/ui/parser/emoji-identifiers.stderr

index 67b5833ca4740748096c8333091d934fcba9dfe5..d3917dfb14ab3126bd4cedf61c2e79a2a175617d 100644 (file)
@@ -452,7 +452,10 @@ pub fn configure_and_expand(
 
     // Gate identifiers containing invalid Unicode codepoints that were recovered during lexing.
     sess.parse_sess.bad_unicode_identifiers.with_lock(|identifiers| {
-        for (ident, spans) in identifiers.drain() {
+        let mut identifiers: Vec<_> = identifiers.drain().collect();
+        identifiers.sort_by_key(|&(key, _)| key);
+        for (ident, mut spans) in identifiers.into_iter() {
+            spans.sort();
             sess.diagnostic().span_err(
                 MultiSpan::from(spans),
                 &format!("identifiers cannot contain emoji: `{}`", ident),
index a69a9c542d6e9f49e7437cf6d673155643d82074..5f9263c4c13e7416f913100f954b1b31fc853a58 100644 (file)
@@ -18,23 +18,11 @@ LL | fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ {
 LL |     let _ = i_like_to_๐Ÿ˜„_a_lot() โž– 4;
    |             ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_๐Ÿ˜…_a_lot`
 
-error: identifiers cannot contain emoji: `i_like_to_๐Ÿ˜„_a_lot`
-  --> $DIR/emoji-identifiers.rs:13:13
-   |
-LL |     let _ = i_like_to_๐Ÿ˜„_a_lot() โž– 4;
-   |             ^^^^^^^^^^^^^^^^^^
-
-error: identifiers cannot contain emoji: `full_of_โœจ`
-  --> $DIR/emoji-identifiers.rs:4:8
-   |
-LL |     fn full_of_โœจ() -> ๐Ÿ‘€ {
-   |        ^^^^^^^^^^
-
-error: identifiers cannot contain emoji: `full_ofโœจ`
-  --> $DIR/emoji-identifiers.rs:9:8
+error: identifiers cannot contain emoji: `ABig๐Ÿ‘ฉ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘งFamily`
+  --> $DIR/emoji-identifiers.rs:1:8
    |
-LL |     ๐Ÿ‘€::full_ofโœจ()
-   |         ^^^^^^^^^
+LL | struct ABig๐Ÿ‘ฉ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘งFamily;
+   |        ^^^^^^^^^^^^^^^^^^
 
 error: identifiers cannot contain emoji: `๐Ÿ‘€`
   --> $DIR/emoji-identifiers.rs:2:8
@@ -53,17 +41,29 @@ LL | fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ {
 LL |     ๐Ÿ‘€::full_ofโœจ()
    |     ^^
 
+error: identifiers cannot contain emoji: `full_of_โœจ`
+  --> $DIR/emoji-identifiers.rs:4:8
+   |
+LL |     fn full_of_โœจ() -> ๐Ÿ‘€ {
+   |        ^^^^^^^^^^
+
 error: identifiers cannot contain emoji: `i_like_to_๐Ÿ˜…_a_lot`
   --> $DIR/emoji-identifiers.rs:8:4
    |
 LL | fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ {
    |    ^^^^^^^^^^^^^^^^^^
 
-error: identifiers cannot contain emoji: `ABig๐Ÿ‘ฉ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘งFamily`
-  --> $DIR/emoji-identifiers.rs:1:8
+error: identifiers cannot contain emoji: `full_ofโœจ`
+  --> $DIR/emoji-identifiers.rs:9:8
    |
-LL | struct ABig๐Ÿ‘ฉ๐Ÿ‘ฉ๐Ÿ‘ง๐Ÿ‘งFamily;
-   |        ^^^^^^^^^^^^^^^^^^
+LL |     ๐Ÿ‘€::full_ofโœจ()
+   |         ^^^^^^^^^
+
+error: identifiers cannot contain emoji: `i_like_to_๐Ÿ˜„_a_lot`
+  --> $DIR/emoji-identifiers.rs:13:13
+   |
+LL |     let _ = i_like_to_๐Ÿ˜„_a_lot() โž– 4;
+   |             ^^^^^^^^^^^^^^^^^^
 
 error[E0599]: no function or associated item named `full_ofโœจ` found for struct `๐Ÿ‘€` in the current scope
   --> $DIR/emoji-identifiers.rs:9:8