summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/type-check-pointer-coercions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/nll/type-check-pointer-coercions.rs')
-rw-r--r--tests/ui/nll/type-check-pointer-coercions.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/nll/type-check-pointer-coercions.rs b/tests/ui/nll/type-check-pointer-coercions.rs
new file mode 100644
index 000000000..66da57248
--- /dev/null
+++ b/tests/ui/nll/type-check-pointer-coercions.rs
@@ -0,0 +1,37 @@
+fn shared_to_const<'a, 'b>(x: &&'a i32) -> *const &'b i32 {
+ x //~ ERROR
+}
+
+fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 {
+ x //~ ERROR
+}
+
+fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 {
+ // Two errors because *mut is invariant
+ x //~ ERROR
+ //~| ERROR
+}
+
+fn mut_to_const<'a, 'b>(x: *mut &'a i32) -> *const &'b i32 {
+ x //~ ERROR
+}
+
+fn array_elem<'a, 'b>(x: &'a i32) -> *const &'b i32 {
+ let z = &[x; 3];
+ let y = z as *const &i32;
+ y //~ ERROR
+}
+
+fn array_coerce<'a, 'b>(x: &'a i32) -> *const [&'b i32; 3] {
+ let z = &[x; 3];
+ let y = z as *const [&i32; 3];
+ y //~ ERROR
+}
+
+fn nested_array<'a, 'b>(x: &'a i32) -> *const [&'b i32; 2] {
+ let z = &[[x; 2]; 3];
+ let y = z as *const [&i32; 2];
+ y //~ ERROR
+}
+
+fn main() {}