]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-univariant-enum.rs
Rollup merge of #102488 - compiler-errors:gat-compatibility, r=oli-obk
[rust.git] / src / test / ui / borrowck / borrowck-univariant-enum.rs
1 // run-pass
2 #![allow(non_camel_case_types)]
3
4 use std::cell::Cell;
5
6 #[derive(Copy, Clone)]
7 enum newtype {
8     newvar(isize)
9 }
10
11 pub fn main() {
12
13     // Test that borrowck treats enums with a single variant
14     // specially.
15
16     let x = &Cell::new(5);
17     let y = &Cell::new(newtype::newvar(3));
18     let z = match y.get() {
19       newtype::newvar(b) => {
20         x.set(x.get() + 1);
21         x.get() * b
22       }
23     };
24     assert_eq!(z, 18);
25 }