Skip to content

Commit def1d0a

Browse files
test: add if let test for partial capture
Signed-off-by: Embers-of-the-Fire <stellarishs@163.com>
1 parent 4d78fd1 commit def1d0a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/ui/closures/2229_closure_analysis/run_pass/if-let-capture.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,9 @@ fn main() {
4747

4848
assert_eq!(if_let_size, match_size);
4949
assert_eq!(if_let_size, let_size);
50-
assert_ne!(if_let_size, size_of::<Thing>());
50+
51+
// The closure should capture only the moved field, so its size should be
52+
// less than the size of `Thing`, which would indicate that it captures the
53+
// entire struct.
54+
assert!(if_let_size <= size_of::<Thing>());
5155
}

0 commit comments

Comments
 (0)