Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,12 +1136,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
if let Some((expected, found)) = expected_found {
match (terr, is_simple_error, expected == found) {
(&TypeError::Sorts(ref values), false, true) => {
let sort_string = | a_type: Ty<'tcx> |
if let ty::Opaque(def_id, _) = a_type.sty {
format!(" (opaque type at {})", self.tcx.sess.source_map()
.mk_substr_filename(self.tcx.def_span(def_id)))
} else {
format!(" ({})", a_type.sort_string(self.tcx))
};
diag.note_expected_found_extra(
&"type",
expected,
found,
&format!(" ({})", values.expected.sort_string(self.tcx)),
&format!(" ({})", values.found.sort_string(self.tcx)),
&sort_string(values.expected),
&sort_string(values.found),
);
}
(_, false, _) => {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/suggestions/opaque-type-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ LL | | thing_two()
LL | | }.await
| |_____- if and else have incompatible types
|
= note: expected type `impl std::future::Future` (opaque type)
found type `impl std::future::Future` (opaque type)
= note: expected type `impl std::future::Future` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
found type `impl std::future::Future` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
= note: distinct uses of `impl Trait` result in different opaque types
= help: if both `Future`s have the same `Output` type, consider `.await`ing on both of them

Expand Down