about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2020-05-05 23:24:34 +0800
committercsmoe <csmoe@msn.com>2020-05-05 23:24:34 +0800
commitfb81c429ebd45f9ba2b1810f548cf59a45feb222 (patch)
tree347b877ebd80b5b1bb831e1ae25142ce32d3acd5
parente07f63e79a618a0c5e53a71d053da0fa0dbc6970 (diff)
downloadrust-fb81c429ebd45f9ba2b1810f548cf59a45feb222.tar.gz
rust-fb81c429ebd45f9ba2b1810f548cf59a45feb222.zip
make yield span optional
-rw-r--r--src/librustc_middle/ty/context.rs2
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/suggestions.rs16
2 files changed, 10 insertions, 8 deletions
diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs
index e43eb01ad96..cc89e59096d 100644
--- a/src/librustc_middle/ty/context.rs
+++ b/src/librustc_middle/ty/context.rs
@@ -305,7 +305,7 @@ pub struct GeneratorInteriorTypeCause<'tcx> {
     /// Span of the scope of the captured binding.
     pub scope_span: Option<Span>,
     /// Span of `.await` or `yield` expression.
-    pub yield_span: Span,
+    pub yield_span: Option<Span>,
     /// Expr which the type evaluated from.
     pub expr: Option<hir::HirId>,
 }
diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
index 5ec2d68ab2a..cd1c75dc5f2 100644
--- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
@@ -127,7 +127,7 @@ pub trait InferCtxtExt<'tcx> {
         err: &mut DiagnosticBuilder<'_>,
         target_span: Span,
         scope_span: &Option<Span>,
-        await_span: Span,
+        yield_span: Option<Span>,
         expr: Option<hir::HirId>,
         snippet: String,
         inner_generator_body: Option<&hir::Body<'_>>,
@@ -1353,7 +1353,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
         err: &mut DiagnosticBuilder<'_>,
         target_span: Span,
         scope_span: &Option<Span>,
-        yield_span: Span,
+        yield_span: Option<Span>,
         expr: Option<hir::HirId>,
         snippet: String,
         inner_generator_body: Option<&hir::Body<'_>>,
@@ -1446,11 +1446,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                 "note_obligation_cause_for_async_await generator_interior_types: {:#?}",
                 tables.generator_interior_types
             );
-            let mut span = MultiSpan::from_span(yield_span);
-            span.push_span_label(
-                yield_span,
-                format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
-            );
+
+            if let Some(yield_span) = yield_span {
+                let mut span = MultiSpan::from_span(yield_span);
+                span.push_span_label(
+                    yield_span,
+                    format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
+                );
 
             span.push_span_label(
                 target_span,