]> git.lizzy.rs Git - rust.git/commitdiff
coerce reborrow multi arg test
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Sat, 30 May 2020 18:54:14 +0000 (20:54 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Fri, 19 Jun 2020 09:06:21 +0000 (11:06 +0200)
src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs [new file with mode: 0644]
src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr [new file with mode: 0644]
src/test/ui/coercion/coerce-reborrow-multi-arg.rs [new file with mode: 0644]

diff --git a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs
new file mode 100644 (file)
index 0000000..48be2d3
--- /dev/null
@@ -0,0 +1,6 @@
+fn test<T>(_a: T, _b: T) {}
+
+fn main() {
+    test(&mut 7, &7);
+    //~^ mismatched types
+}
diff --git a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr
new file mode 100644 (file)
index 0000000..59b0ec4
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/coerce-reborrow-multi-arg-fail.rs:4:18
+   |
+LL |     test(&mut 7, &7);
+   |                  ^^ types differ in mutability
+   |
+   = note: expected mutable reference `&mut {integer}`
+                      found reference `&{integer}`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/coercion/coerce-reborrow-multi-arg.rs b/src/test/ui/coercion/coerce-reborrow-multi-arg.rs
new file mode 100644 (file)
index 0000000..93cd0bb
--- /dev/null
@@ -0,0 +1,9 @@
+// build-pass
+fn test<T>(_a: T, _b: T) {}
+
+fn main() {
+    test(&7, &7);
+    test(&7, &mut 7);
+    test::<&i32>(&mut 7, &7);
+    test::<&i32>(&mut 7, &mut 7);
+}