Skip to content

Commit fb81c42

Browse files
committed
make yield span optional
1 parent e07f63e commit fb81c42

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/librustc_middle/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pub struct GeneratorInteriorTypeCause<'tcx> {
305305
/// Span of the scope of the captured binding.
306306
pub scope_span: Option<Span>,
307307
/// Span of `.await` or `yield` expression.
308-
pub yield_span: Span,
308+
pub yield_span: Option<Span>,
309309
/// Expr which the type evaluated from.
310310
pub expr: Option<hir::HirId>,
311311
}

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub trait InferCtxtExt<'tcx> {
127127
err: &mut DiagnosticBuilder<'_>,
128128
target_span: Span,
129129
scope_span: &Option<Span>,
130-
await_span: Span,
130+
yield_span: Option<Span>,
131131
expr: Option<hir::HirId>,
132132
snippet: String,
133133
inner_generator_body: Option<&hir::Body<'_>>,
@@ -1353,7 +1353,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13531353
err: &mut DiagnosticBuilder<'_>,
13541354
target_span: Span,
13551355
scope_span: &Option<Span>,
1356-
yield_span: Span,
1356+
yield_span: Option<Span>,
13571357
expr: Option<hir::HirId>,
13581358
snippet: String,
13591359
inner_generator_body: Option<&hir::Body<'_>>,
@@ -1446,11 +1446,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
14461446
"note_obligation_cause_for_async_await generator_interior_types: {:#?}",
14471447
tables.generator_interior_types
14481448
);
1449-
let mut span = MultiSpan::from_span(yield_span);
1450-
span.push_span_label(
1451-
yield_span,
1452-
format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
1453-
);
1449+
1450+
if let Some(yield_span) = yield_span {
1451+
let mut span = MultiSpan::from_span(yield_span);
1452+
span.push_span_label(
1453+
yield_span,
1454+
format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
1455+
);
14541456

14551457
span.push_span_label(
14561458
target_span,

0 commit comments

Comments
 (0)