You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On unconstrained lifetime on impl block, suggest using it if there's an implicit borrow in the self type
```
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> $DIR/missing-lifetime-in-assoc-type-1.rs:4:6
|
LL | impl<'a> IntoIterator for &S {
| ^^ unconstrained lifetime parameter
|
help: consider using the named lifetime here instead of an implict lifetime
|
LL | impl<'a> IntoIterator for &'a S {
| ++
```
Copy file name to clipboardExpand all lines: tests/ui/lifetimes/missing-lifetime-in-assoc-type-1.stderr
+6-1
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
error: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
2
-
--> $DIR/missing-lifetime-in-assoc-type-1.rs:8:17
2
+
--> $DIR/missing-lifetime-in-assoc-type-1.rs:9:17
3
3
|
4
4
LL | impl<'a> IntoIterator for &S {
5
5
| ---- there is a named lifetime specified on the impl block you could use
@@ -17,6 +17,11 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
17
17
|
18
18
LL | impl<'a> IntoIterator for &S {
19
19
| ^^ unconstrained lifetime parameter
20
+
|
21
+
help: consider using the named lifetime here instead of an implict lifetime
error: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
2
+
--> $DIR/missing-lifetime-in-assoc-type-5.rs:9:17
3
+
|
4
+
LL | impl<'a> IntoIterator for &'_ S {
5
+
| ---- there is a named lifetime specified on the impl block you could use
6
+
...
7
+
LL | type Item = &T;
8
+
| ^ this lifetime must come from the implemented type
9
+
|
10
+
help: consider using the lifetime from the impl block
11
+
|
12
+
LL | type Item = &'a T;
13
+
| ++
14
+
15
+
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
16
+
--> $DIR/missing-lifetime-in-assoc-type-5.rs:4:6
17
+
|
18
+
LL | impl<'a> IntoIterator for &'_ S {
19
+
| ^^ unconstrained lifetime parameter
20
+
|
21
+
help: consider using the named lifetime here instead of an implict lifetime
22
+
|
23
+
LL | impl<'a> IntoIterator for &'a S {
24
+
| ~~
25
+
26
+
error: aborting due to 2 previous errors
27
+
28
+
For more information about this error, try `rustc --explain E0207`.
0 commit comments