From 4d2e9651060c984d18cf8863ceacf215ec00446c Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 27 Jan 2022 16:34:28 +0000 Subject: [PATCH] Make a span more useful --- .../src/traits/error_reporting/suggestions.rs | 1 + src/test/ui/generator/issue-88653.stderr | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 9eed03bb223..51b8c9aca78 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1328,6 +1328,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ty::Generator(..) => "generator", _ => "function", }; + let span = self.tcx.sess.source_map().guess_head_span(span); let mut err = struct_span_err!( self.tcx.sess, span, diff --git a/src/test/ui/generator/issue-88653.stderr b/src/test/ui/generator/issue-88653.stderr index a44e273f854..eaa90a8e60a 100644 --- a/src/test/ui/generator/issue-88653.stderr +++ b/src/test/ui/generator/issue-88653.stderr @@ -1,18 +1,11 @@ error[E0631]: type mismatch in generator arguments --> $DIR/issue-88653.rs:9:5 | -LL | |bar| { - | ^---- - | | - | _____found signature of `fn(bool) -> _` - | | -LL | | -LL | | -LL | | -... | -LL | | } -LL | | } - | |_____^ expected signature of `fn((bool,)) -> _` +LL | |bar| { + | ^^^^^ + | | + | expected signature of `fn((bool,)) -> _` + | found signature of `fn(bool) -> _` error: aborting due to previous error