Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place
This commit is contained in:
parent
b14d8b2ef2
commit
69b690f0f6
2 changed files with 24 additions and 1 deletions
|
@ -154,6 +154,14 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
|
||||||
}) {
|
}) {
|
||||||
let (child_field_idx, child_capture) = child_captures.next().unwrap();
|
let (child_field_idx, child_capture) = child_captures.next().unwrap();
|
||||||
|
|
||||||
|
// This analysis only makes sense if the parent capture is a
|
||||||
|
// prefix of the child capture.
|
||||||
|
assert!(
|
||||||
|
child_capture.place.projections.len() >= parent_capture.place.projections.len(),
|
||||||
|
"parent capture ({parent_capture:#?}) expected to be prefix of \
|
||||||
|
child capture ({child_capture:#?})"
|
||||||
|
);
|
||||||
|
|
||||||
// Store this set of additional projections (fields and derefs).
|
// Store this set of additional projections (fields and derefs).
|
||||||
// We need to re-apply them later.
|
// We need to re-apply them later.
|
||||||
let child_precise_captures =
|
let child_precise_captures =
|
||||||
|
@ -244,7 +252,6 @@ fn child_prefix_matches_parent_projections(
|
||||||
bug!("expected capture to be an upvar");
|
bug!("expected capture to be an upvar");
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(child_capture.place.projections.len() >= parent_capture.place.projections.len());
|
|
||||||
parent_base.var_path.hir_id == child_base.var_path.hir_id
|
parent_base.var_path.hir_id == child_base.var_path.hir_id
|
||||||
&& std::iter::zip(&child_capture.place.projections, &parent_capture.place.projections)
|
&& std::iter::zip(&child_capture.place.projections, &parent_capture.place.projections)
|
||||||
.all(|(child, parent)| child.kind == parent.kind)
|
.all(|(child, parent)| child.kind == parent.kind)
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
//@ check-pass
|
||||||
|
//@ edition: 2021
|
||||||
|
// issue: rust-lang/rust#123697
|
||||||
|
|
||||||
|
#![feature(async_closure)]
|
||||||
|
|
||||||
|
struct S { t: i32 }
|
||||||
|
|
||||||
|
fn test(s: &S, t: &i32) {
|
||||||
|
async || {
|
||||||
|
println!("{}", s.t);
|
||||||
|
println!("{}", t);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue