make yield span optional
This commit is contained in:
parent
e07f63e79a
commit
fb81c429eb
2 changed files with 10 additions and 8 deletions
|
|
@ -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>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue