about summary refs log tree commit diff
path: root/tests/ui/binding
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/binding')
-rw-r--r--tests/ui/binding/match-with-at-binding-8391.rs10
-rw-r--r--tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs16
-rw-r--r--tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr14
-rw-r--r--tests/ui/binding/ref-pattern-drop-behavior-8860.rs52
4 files changed, 92 insertions, 0 deletions
diff --git a/tests/ui/binding/match-with-at-binding-8391.rs b/tests/ui/binding/match-with-at-binding-8391.rs
new file mode 100644
index 00000000000..bc4e7be7989
--- /dev/null
+++ b/tests/ui/binding/match-with-at-binding-8391.rs
@@ -0,0 +1,10 @@
+// https://github.com/rust-lang/rust/issues/8391
+//@ run-pass
+
+fn main() {
+    let x = match Some(1) {
+        ref _y @ Some(_) => 1,
+        None => 2,
+    };
+    assert_eq!(x, 1);
+}
diff --git a/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs
new file mode 100644
index 00000000000..4cb04cdf5be
--- /dev/null
+++ b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs
@@ -0,0 +1,16 @@
+// https://github.com/rust-lang/rust/issues/7092
+enum Whatever {
+}
+
+fn foo(x: Whatever) {
+    match x { //~ NOTE this expression has type `Whatever`
+        Some(field) =>
+//~^ ERROR mismatched types
+//~| NOTE expected `Whatever`, found `Option<_>`
+//~| NOTE expected enum `Whatever`
+//~| NOTE found enum `Option<_>`
+            field.access(),
+    }
+}
+
+fn main(){}
diff --git a/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr
new file mode 100644
index 00000000000..1f8ff2d8df1
--- /dev/null
+++ b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/method-call-nonsensical-pattern-binding-7092.rs:7:9
+   |
+LL |     match x {
+   |           - this expression has type `Whatever`
+LL |         Some(field) =>
+   |         ^^^^^^^^^^^ expected `Whatever`, found `Option<_>`
+   |
+   = note: expected enum `Whatever`
+              found enum `Option<_>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/binding/ref-pattern-drop-behavior-8860.rs b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs
new file mode 100644
index 00000000000..1a67caf021c
--- /dev/null
+++ b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs
@@ -0,0 +1,52 @@
+// https://github.com/rust-lang/rust/issues/8860
+//@ run-pass
+// FIXME(static_mut_refs): this could use an atomic
+#![allow(static_mut_refs)]
+#![allow(dead_code)]
+
+static mut DROP: isize = 0;
+static mut DROP_S: isize = 0;
+static mut DROP_T: isize = 0;
+
+struct S;
+impl Drop for S {
+    fn drop(&mut self) {
+        unsafe {
+            DROP_S += 1;
+            DROP += 1;
+        }
+    }
+}
+fn f(ref _s: S) {}
+
+struct T { i: isize }
+impl Drop for T {
+    fn drop(&mut self) {
+        unsafe {
+            DROP_T += 1;
+            DROP += 1;
+        }
+    }
+}
+fn g(ref _t: T) {}
+
+fn do_test() {
+    let s = S;
+    f(s);
+    unsafe {
+        assert_eq!(1, DROP);
+        assert_eq!(1, DROP_S);
+    }
+    let t = T { i: 1 };
+    g(t);
+    unsafe { assert_eq!(1, DROP_T); }
+}
+
+fn main() {
+    do_test();
+    unsafe {
+        assert_eq!(2, DROP);
+        assert_eq!(1, DROP_S);
+        assert_eq!(1, DROP_T);
+    }
+}