Skip to content

Commit a721383

Browse files
committed
Provide consistent output order for suggestions
1 parent 1e1f33f commit a721383

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
738738
{
739739
let mut eraser = TypeParamEraser(self.tcx);
740740
let candidate_len = impl_candidates.len();
741-
let suggestions = impl_candidates.iter().map(|candidate| {
741+
let mut suggestions: Vec<_> = impl_candidates.iter().map(|candidate| {
742742
let candidate = candidate.super_fold_with(&mut eraser);
743743
vec![
744744
(expr.span.shrink_to_lo(), format!("{}::{}(", candidate, segment.ident)),
@@ -748,13 +748,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
748748
(expr.span.shrink_to_hi().with_hi(exprs[1].span.lo()), ", ".to_string())
749749
},
750750
]
751-
});
751+
}).collect();
752+
suggestions.sort_by(|a, b| a[0].1.cmp(&b[0].1));
752753
err.multipart_suggestions(
753754
&format!(
754755
"use the fully qualified path for the potential candidate{}",
755756
pluralize!(candidate_len),
756757
),
757-
suggestions,
758+
suggestions.into_iter(),
758759
Applicability::MaybeIncorrect,
759760
);
760761
}

src/test/ui/traits/issue-77982.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ LL | opts.get(opt.as_ref());
3636
- impl AsRef<str> for String;
3737
help: use the fully qualified path for the potential candidates
3838
|
39-
LL | opts.get(<str as AsRef<Path>>::as_ref(opt));
40-
| +++++++++++++++++++++++++++++ ~
41-
LL | opts.get(<str as AsRef<OsStr>>::as_ref(opt));
42-
| ++++++++++++++++++++++++++++++ ~
43-
LL | opts.get(<str as AsRef<str>>::as_ref(opt));
44-
| ++++++++++++++++++++++++++++ ~
45-
LL | opts.get(<str as AsRef<[u8]>>::as_ref(opt));
46-
| +++++++++++++++++++++++++++++ ~
39+
LL | opts.get(<String as AsRef<OsStr>>::as_ref(opt));
40+
| +++++++++++++++++++++++++++++++++ ~
41+
LL | opts.get(<String as AsRef<Path>>::as_ref(opt));
42+
| ++++++++++++++++++++++++++++++++ ~
43+
LL | opts.get(<String as AsRef<[u8]>>::as_ref(opt));
44+
| ++++++++++++++++++++++++++++++++ ~
45+
LL | opts.get(<String as AsRef<str>>::as_ref(opt));
46+
| +++++++++++++++++++++++++++++++ ~
4747
and 4 other candidates
4848

4949
error[E0283]: type annotations needed

0 commit comments

Comments
 (0)