Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Oct 8, 2021
1 parent 5481201 commit d7f8a06
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/issue-89606.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Regression test for #89606. Used to ICE.
//
// check-pass
// revisions: twenty_eighteen twenty_twentyone
// [twenty_eighteen]compile-flags: --edition 2018
// [twenty_twentyone]compile-flags: --edition 2021

struct S<'a>(Option<&'a mut i32>);

fn by_ref(s: &mut S<'_>) {
(|| {
let S(_o) = s;
s.0 = None;
})();
}

fn by_value(s: S<'_>) {
(|| {
let S(ref _o) = s;
let _g = s.0;
})();
}

struct V<'a>((Option<&'a mut i32>,));

fn nested(v: &mut V<'_>) {
(|| {
let V((_o,)) = v;
v.0 = (None, );
})();
}

fn main() {
let mut s = S(None);
by_ref(&mut s);
by_value(s);

let mut v = V((None, ));
nested(&mut v);
}

0 comments on commit d7f8a06

Please sign in to comment.