]> git.lizzy.rs Git - rust.git/commitdiff
Provide consistent output order for suggestions
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 24 Apr 2022 00:54:11 +0000 (17:54 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 24 Apr 2022 00:54:11 +0000 (17:54 -0700)
compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
src/test/ui/traits/issue-77982.stderr

index 623d655bcbb30b3330e0ca0d208cae9a0cacb2a5..465358de932c3f2740ad746453b225ac5cc4b036 100644 (file)
@@ -738,7 +738,7 @@ pub fn emit_inference_failure_err(
                 {
                     let mut eraser = TypeParamEraser(self.tcx);
                     let candidate_len = impl_candidates.len();
-                    let suggestions = impl_candidates.iter().map(|candidate| {
+                    let mut suggestions: Vec<_> = impl_candidates.iter().map(|candidate| {
                         let candidate = candidate.super_fold_with(&mut eraser);
                         vec![
                             (expr.span.shrink_to_lo(), format!("{}::{}(", candidate, segment.ident)),
@@ -748,13 +748,14 @@ pub fn emit_inference_failure_err(
                                 (expr.span.shrink_to_hi().with_hi(exprs[1].span.lo()), ", ".to_string())
                             },
                         ]
-                    });
+                    }).collect();
+                    suggestions.sort_by(|a, b| a[0].1.cmp(&b[0].1));
                     err.multipart_suggestions(
                         &format!(
                             "use the fully qualified path for the potential candidate{}",
                             pluralize!(candidate_len),
                         ),
-                        suggestions,
+                        suggestions.into_iter(),
                         Applicability::MaybeIncorrect,
                     );
                 }
index 414e9e580c19d0221ee07f453f0df1ed675685f5..63c1cb3791edf4144f239cff2393d5918eb86f16 100644 (file)
@@ -36,14 +36,14 @@ LL |     opts.get(opt.as_ref());
            - impl AsRef<str> for String;
 help: use the fully qualified path for the potential candidates
    |
-LL |     opts.get(<str as AsRef<Path>>::as_ref(opt));
-   |              +++++++++++++++++++++++++++++   ~
-LL |     opts.get(<str as AsRef<OsStr>>::as_ref(opt));
-   |              ++++++++++++++++++++++++++++++   ~
-LL |     opts.get(<str as AsRef<str>>::as_ref(opt));
-   |              ++++++++++++++++++++++++++++   ~
-LL |     opts.get(<str as AsRef<[u8]>>::as_ref(opt));
-   |              +++++++++++++++++++++++++++++   ~
+LL |     opts.get(<String as AsRef<OsStr>>::as_ref(opt));
+   |              +++++++++++++++++++++++++++++++++   ~
+LL |     opts.get(<String as AsRef<Path>>::as_ref(opt));
+   |              ++++++++++++++++++++++++++++++++   ~
+LL |     opts.get(<String as AsRef<[u8]>>::as_ref(opt));
+   |              ++++++++++++++++++++++++++++++++   ~
+LL |     opts.get(<String as AsRef<str>>::as_ref(opt));
+   |              +++++++++++++++++++++++++++++++   ~
      and 4 other candidates
 
 error[E0283]: type annotations needed