diff options
Diffstat (limited to 'tests/ui/drop/static-issue-17302.rs')
| -rw-r--r-- | tests/ui/drop/static-issue-17302.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/drop/static-issue-17302.rs b/tests/ui/drop/static-issue-17302.rs new file mode 100644 index 00000000000..060f5564efd --- /dev/null +++ b/tests/ui/drop/static-issue-17302.rs @@ -0,0 +1,29 @@ +//@ run-pass + +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + +static mut DROPPED: [bool; 2] = [false, false]; + +struct A(usize); +struct Foo { _a: A, _b: isize } + +impl Drop for A { + fn drop(&mut self) { + let A(i) = *self; + unsafe { DROPPED[i] = true; } + } +} + +fn main() { + { + Foo { + _a: A(0), + ..Foo { _a: A(1), _b: 2 } + }; + } + unsafe { + assert!(DROPPED[0]); + assert!(DROPPED[1]); + } +} |
