Use targetted diagnostic for borrow across yield error
This commit is contained in:
parent
6223744078
commit
bb90c4bf35
@ -373,11 +373,12 @@ pub(crate) fn cannot_borrow_across_coroutine_yield(
|
||||
span: Span,
|
||||
yield_span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind;
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
E0626,
|
||||
"borrow may still be in use when coroutine yields",
|
||||
"borrow may still be in use when {coroutine_kind:#} yields",
|
||||
);
|
||||
err.span_label(yield_span, "possible yield occurs here");
|
||||
err
|
||||
|
@ -6,7 +6,7 @@ fn main() {
|
||||
let mut x = {
|
||||
let mut x = gen {
|
||||
let y = 42;
|
||||
let z = &y; //~ ERROR: borrow may still be in use when coroutine yields
|
||||
let z = &y; //~ ERROR: borrow may still be in use when `gen` block yields
|
||||
yield 43;
|
||||
panic!("{z}");
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0626]: borrow may still be in use when coroutine yields
|
||||
error[E0626]: borrow may still be in use when `gen` block yields
|
||||
--> $DIR/self_referential_gen_block.rs:9:21
|
||||
|
|
||||
LL | let z = &y;
|
||||
|
Loading…
Reference in New Issue
Block a user