[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>
Thu, 6 Aug 2020 20:11:39 +0000 (21:11 +0100)
Gbp-Pq: Name u-1629fed4c0bdc6d3246ea63a91f600bcb8874626.patch

src/librustc_typeck/check/method/suggest.rs

index 7ca3eb884d88fc5d82eee63b5099f214946dfa39..3e8c5aabfd99ae8d634211e022b206c49c302686 100644 (file)
@@ -676,6 +676,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!(
@@ -686,7 +689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                             format!(
                                 "{} {}",
                                 if empty_where { " where" } else { "," },
-                                obligations.into_iter().collect::<Vec<_>>().join(", ")
+                                obligations.join(", ")
                             ),
                             Applicability::MaybeIncorrect,
                         );