about summary refs log tree commit diff
path: root/tests/ui/impl-header-lifetime-elision/ref-underscore.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-header-lifetime-elision/ref-underscore.rs')
-rw-r--r--tests/ui/impl-header-lifetime-elision/ref-underscore.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/impl-header-lifetime-elision/ref-underscore.rs b/tests/ui/impl-header-lifetime-elision/ref-underscore.rs
new file mode 100644
index 00000000000..5be04d08a09
--- /dev/null
+++ b/tests/ui/impl-header-lifetime-elision/ref-underscore.rs
@@ -0,0 +1,30 @@
+// Test that `impl MyTrait for &i32` works and is equivalent to any lifetime.
+
+// run-pass
+
+#![allow(warnings)]
+
+trait MyTrait { }
+
+impl MyTrait for &i32 {
+}
+
+fn impls_my_trait<T: MyTrait>() { }
+
+fn impls_my_trait_val<T: MyTrait>(_: T) {
+    impls_my_trait::<T>();
+}
+
+fn random_where_clause()
+where for<'a> &'a i32: MyTrait { }
+
+fn main() {
+    let x = 22;
+    let f = &x;
+
+    impls_my_trait_val(f);
+
+    impls_my_trait::<&'static i32>();
+
+    random_where_clause();
+}