diff options
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/traits/issue-77982.stderr | 16 |
2 files changed, 12 insertions, 11 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 623d655bcbb..465358de932 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -738,7 +738,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { { 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 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { (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, ); } diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr index 414e9e580c1..63c1cb3791e 100644 --- a/src/test/ui/traits/issue-77982.stderr +++ b/src/test/ui/traits/issue-77982.stderr @@ -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 |
