[PATCH] Presort restrictions to make output consistent
authorYuki Okushi <huyuumi.dev@gmail.com>
Fri, 31 Jul 2020 00:03:14 +0000 (09:03 +0900)
committerXimin Luo <infinity0@debian.org>
Sat, 29 Aug 2020 15:54:36 +0000 (16:54 +0100)
Gbp-Pq: Name u-1629fed4c0bdc6d3246ea63a91f600bcb8874626.patch

src/librustc_typeck/check/method/suggest.rs

index 44ffabc4c266222617f11b17708e22c0330cf386..e63c7c14bee6babb34cc5faf8bc45508fd9e2fde 100644 (file)
@@ -674,6 +674,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                         .collect::<Vec<(usize, String)>>();
                     for ((span, empty_where), obligations) in type_params.into_iter() {
                         restrict_type_params = true;
+                        // #74886: Sort here so that the output is always the same.
+                        let mut obligations = obligations.into_iter().collect::<Vec<_>>();
+                        obligations.sort();
                         err.span_suggestion_verbose(
                             span,
                             &format!(
@@ -684,7 +687,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                             format!(
                                 "{} {}",
                                 if empty_where { " where" } else { "," },
-                                obligations.into_iter().collect::<Vec<_>>().join(", ")
+                                obligations.join(", ")
                             ),
                             Applicability::MaybeIncorrect,
                         );