File tree 2 files changed +49
-0
lines changed
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std:: pin:: Pin ;
2
+ trait Trait {
3
+ fn method < ' a > ( self : Pin < & Self > , f : & ' a u32 ) -> & ' a u32 {
4
+ f
5
+ }
6
+ }
7
+
8
+ impl < P > Trait for Pin < P > {
9
+ // This should not hide `&Self`, which would cause this to compile.
10
+ fn method ( self : Pin < & Self > , f : & u32 ) -> & u32 {
11
+ //~^ ERROR `impl` item signature doesn't match `trait`
12
+ f
13
+ //~^ ERROR lifetime may not live long enough
14
+ }
15
+ }
16
+
17
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: `impl` item signature doesn't match `trait` item signature
2
+ --> $DIR/no-shadow-pin-self.rs:10:5
3
+ |
4
+ LL | fn method<'a>(self: Pin<&Self>, f: &'a u32) -> &'a u32 {
5
+ | ------------------------------------------------------ expected `fn(Pin<&'1 Pin<P>>, &'a u32) -> &'a u32`
6
+ ...
7
+ LL | fn method(self: Pin<&Self>, f: &u32) -> &u32 {
8
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(Pin<&'1 Pin<P>>, &'2 u32) -> &'1 u32`
9
+ |
10
+ = note: expected signature `fn(Pin<&'1 Pin<P>>, &'a u32) -> &'a u32`
11
+ found signature `fn(Pin<&'1 Pin<P>>, &'2 u32) -> &'1 u32`
12
+ = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
13
+ = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
14
+
15
+ error: lifetime may not live long enough
16
+ --> $DIR/no-shadow-pin-self.rs:12:9
17
+ |
18
+ LL | fn method(self: Pin<&Self>, f: &u32) -> &u32 {
19
+ | - - let's call the lifetime of this reference `'1`
20
+ | |
21
+ | let's call the lifetime of this reference `'2`
22
+ LL |
23
+ LL | f
24
+ | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
25
+ |
26
+ help: consider introducing a named lifetime parameter and update trait if needed
27
+ |
28
+ LL | fn method<'a>(self: Pin<&Self>, f: &'a u32) -> &'a u32 {
29
+ | ++++ ++ ++
30
+
31
+ error: aborting due to 2 previous errors
32
+
You can’t perform that action at this time.
0 commit comments