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
Copy file name to clipboardExpand all lines: compiler/rustc_resolve/messages.ftl
+5-1
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,10 @@ resolve_added_macro_use =
11
11
resolve_ancestor_only =
12
12
visibilities can only be restricted to ancestor modules
13
13
14
+
resolve_anonymous_livetime_non_gat_report_error =
15
+
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
16
+
.label = this lifetime must come from the implemented type
17
+
14
18
resolve_arguments_macro_use_not_allowed = arguments to `macro_use` are not allowed here
associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type.
242
+
associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
239
243
.note = you can't create an `Iterator` that borrows each `Item` from itself, but you can instead create a new type that borrows your existing type and implement `Iterator` for that new type.
Copy file name to clipboardExpand all lines: tests/ui/impl-header-lifetime-elision/assoc-type.rs
+1-1
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ trait MyTrait {
9
9
10
10
implMyTraitfor&i32{
11
11
typeOutput = &i32;
12
-
//~^ ERROR `&` without an explicit lifetime name cannot be used here
12
+
//~^ ERROR 11:19: 11:20: 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
Copy file name to clipboardExpand all lines: tests/ui/impl-header-lifetime-elision/assoc-type.stderr
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
error[E0637]: `&` without an explicit lifetime name cannot be used here
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
2
--> $DIR/assoc-type.rs:11:19
3
3
|
4
4
LL | type Output = &i32;
5
-
| ^ explicit lifetime name needed here
5
+
| ^ this lifetime must come from the implemented type
Copy file name to clipboardExpand all lines: tests/ui/lifetimes/no_lending_iterators.rs
+24-1
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,34 @@ struct Data(String);
2
2
3
3
implIteratorforData{
4
4
typeItem = &str;
5
-
//~^ ERROR 4:17: 4:18: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type.
5
+
//~^ ERROR 4:17: 4:18: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
6
6
7
7
fnnext(&mutself) -> Option<Self::Item>{
8
8
Some(&self.0)
9
9
}
10
10
}
11
11
12
+
traitBar{
13
+
typeItem;
14
+
fnpoke(&mutself,item:Self::Item);
15
+
}
16
+
17
+
implBarforusize{
18
+
typeItem = &usize;
19
+
//~^ ERROR 18:17: 18:18: 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
20
+
21
+
fnpoke(&mutself,item:Self::Item){
22
+
self += *item;
23
+
}
24
+
}
25
+
26
+
implBarforisize{
27
+
typeItem<'a> = &'aisize;
28
+
//~^ ERROR 27:14: 27:18: lifetime parameters or bounds on type `Item` do not match the trait declaration [E0195]
Copy file name to clipboardExpand all lines: tests/ui/lifetimes/no_lending_iterators.stderr
+18-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
error: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type.
1
+
error: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
2
2
--> $DIR/no_lending_iterators.rs:4:17
3
3
|
4
4
LL | type Item = &str;
@@ -10,5 +10,21 @@ note: you can't create an `Iterator` that borrows each `Item` from itself, but y
10
10
LL | impl Iterator for Data {
11
11
| ^^^^
12
12
13
-
error: aborting due to 1 previous error
13
+
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
14
+
--> $DIR/no_lending_iterators.rs:18:17
15
+
|
16
+
LL | type Item = &usize;
17
+
| ^ this lifetime must come from the implemented type
18
+
19
+
error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration
20
+
--> $DIR/no_lending_iterators.rs:27:14
21
+
|
22
+
LL | type Item;
23
+
| - lifetimes in impl do not match this type in trait
24
+
...
25
+
LL | type Item<'a> = &'a isize;
26
+
| ^^^^ lifetimes do not match type in trait
27
+
28
+
error: aborting due to 3 previous errors
14
29
30
+
For more information about this error, try `rustc --explain E0195`.
0 commit comments