about summary refs log tree commit diff
path: root/tests/ui/self/elision/ref-struct.fixed
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-20 18:04:19 +0000
committerbors <bors@rust-lang.org>2024-05-20 18:04:19 +0000
commitbe71fd477243f253a735bb35e0cd23cc528cf30a (patch)
treec9e82040cf28f18b0cbd9f0187b7d4b0dea5ecdd /tests/ui/self/elision/ref-struct.fixed
parent474bee7bf540db9344ca975298b6c1646a74b772 (diff)
parent1640225b9d15da64e6af922b4dc3573b337138d0 (diff)
downloadrust-be71fd477243f253a735bb35e0cd23cc528cf30a.tar.gz
rust-be71fd477243f253a735bb35e0cd23cc528cf30a.zip
Auto merge of #125331 - matthiaskrgr:rollup-4kfrh4n, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124682 (Suggest setting lifetime in borrowck error involving types with elided lifetimes)
 - #124917 (Check whether the next_node is else-less if in get_return_block)
 - #125106 (coverage: Memoize and simplify counter expressions)
 - #125173 (Remove `Rvalue::CheckedBinaryOp`)
 - #125305 (add some codegen tests for issue 120493)
 - #125314 ( Add an experimental feature gate for global registration)
 - #125318 (Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/ui/self/elision/ref-struct.fixed')
-rw-r--r--tests/ui/self/elision/ref-struct.fixed37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/self/elision/ref-struct.fixed b/tests/ui/self/elision/ref-struct.fixed
new file mode 100644
index 00000000000..411f6013195
--- /dev/null
+++ b/tests/ui/self/elision/ref-struct.fixed
@@ -0,0 +1,37 @@
+//@ run-rustfix
+#![allow(non_snake_case, dead_code)]
+
+use std::pin::Pin;
+
+struct Struct {}
+
+impl Struct {
+    // Test using `&Struct` explicitly:
+
+    fn ref_Struct<'a>(self: &Struct, f: &'a u32) -> &'a u32 {
+        f
+        //~^ ERROR lifetime may not live long enough
+    }
+
+    fn box_ref_Struct<'a>(self: Box<&Struct>, f: &'a u32) -> &'a u32 {
+        f
+        //~^ ERROR lifetime may not live long enough
+    }
+
+    fn pin_ref_Struct<'a>(self: Pin<&Struct>, f: &'a u32) -> &'a u32 {
+        f
+        //~^ ERROR lifetime may not live long enough
+    }
+
+    fn box_box_ref_Struct<'a>(self: Box<Box<&Struct>>, f: &'a u32) -> &'a u32 {
+        f
+        //~^ ERROR lifetime may not live long enough
+    }
+
+    fn box_pin_Struct<'a>(self: Box<Pin<&Struct>>, f: &'a u32) -> &'a u32 {
+        f
+        //~^ ERROR lifetime may not live long enough
+    }
+}
+
+fn main() {}