summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs')
-rw-r--r--tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs b/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs
new file mode 100644
index 000000000..2ad92b794
--- /dev/null
+++ b/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs
@@ -0,0 +1,18 @@
+// Test that the borrow checker considers `#[non_exhaustive]` when checking
+// whether a match contains a discriminant read.
+
+// aux-build:monovariants.rs
+extern crate monovariants;
+
+use monovariants::NonExhaustiveMonovariant;
+
+fn main() {
+ let mut x = NonExhaustiveMonovariant::Variant(1);
+ let y = &mut x;
+ match x {
+ //~^ ERROR cannot use `x` because it was mutably borrowed
+ NonExhaustiveMonovariant::Variant(_) => {},
+ _ => {},
+ }
+ drop(y);
+}