Skip to content

Commit db152a5

Browse files
committed
Enable to type unit via ZeroSized
1 parent 85e48e2 commit db152a5

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/analyze/basic_block.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
213213
chc::Term::bool(val.try_to_bool().unwrap()),
214214
)
215215
}
216+
(mir_ty::TyKind::Tuple(tys), _) if tys.is_empty() => {
217+
PlaceType::with_ty_and_term(rty::Type::unit(), chc::Term::tuple(vec![]))
218+
}
216219
(
217220
mir_ty::TyKind::Ref(_, elem, Mutability::Not),
218221
ConstValue::Scalar(Scalar::Ptr(ptr, _)),

tests/ui/fail/closure_mut_0.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@error-in-other-file: Unsat
2+
//@compile-flags: -C debug-assertions=off
3+
4+
fn main() {
5+
let mut x = 1;
6+
x += 1;
7+
let mut incr = || {
8+
x += 1;
9+
};
10+
incr();
11+
assert!(x == 2);
12+
}

tests/ui/pass/closure_mut_0.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@check-pass
2+
//@compile-flags: -C debug-assertions=off
3+
4+
fn main() {
5+
let mut x = 1;
6+
let mut incr = || {
7+
x += 1;
8+
};
9+
incr();
10+
assert!(x == 2);
11+
}

0 commit comments

Comments
 (0)