forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve output of argument anonymous borrow missing annotation involv…
…ing opaque return type Go from ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file8.rs:22:5 | 22 | / move || { 23 | | *dest = g.get(); 24 | | } | |_____^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1... --> file8.rs:18:1 | 18 | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a 19 | | where 20 | | G: Get<T> 21 | | { ... | 24 | | } 25 | | } | |_^ note: ...so that the types are compatible --> file8.rs:22:5 | 22 | / move || { //~ ERROR cannot infer an appropriate lifetime 23 | | *dest = g.get(); 24 | | } | |_____^ = note: expected `&mut T` found `&mut T` note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 18:8... --> file8.rs:18:8 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^ note: ...so that return value is valid for the call --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^^^^^^^^^^^^^^^^^^ ``` to ``` error[E0621]: explicit lifetime required in the type of `dest` --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required | | | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ```
- Loading branch information
Showing
7 changed files
with
37 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
error: lifetime may not live long enough | ||
error[E0621]: explicit lifetime required in the type of `items` | ||
--> $DIR/dyn-trait-underscore.rs:8:5 | ||
| | ||
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { | ||
| - let's call the lifetime of this reference `'1` | ||
| ---- help: add explicit lifetime `'static` to the type of `items`: `&'static [T]` | ||
LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` | ||
LL | Box::new(items.iter()) | ||
| ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` | ||
| ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0621`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 6 additions & 25 deletions
31
src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements | ||
--> $DIR/dyn-trait-underscore.rs:8:20 | ||
| | ||
LL | Box::new(items.iter()) | ||
| ^^^^ | ||
| | ||
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 6:1... | ||
--> $DIR/dyn-trait-underscore.rs:6:1 | ||
| | ||
LL | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { | ||
LL | | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` | ||
LL | | Box::new(items.iter()) | ||
LL | | } | ||
| |_^ | ||
note: ...so that reference does not outlive borrowed content | ||
--> $DIR/dyn-trait-underscore.rs:8:14 | ||
| | ||
LL | Box::new(items.iter()) | ||
| ^^^^^ | ||
= note: but, the lifetime must be valid for the static lifetime... | ||
note: ...so that the expression is assignable | ||
error[E0621]: explicit lifetime required in the type of `items` | ||
--> $DIR/dyn-trait-underscore.rs:8:5 | ||
| | ||
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { | ||
| ---- help: add explicit lifetime `'static` to the type of `items`: `&'static [T]` | ||
LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` | ||
LL | Box::new(items.iter()) | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>` | ||
found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>` | ||
| ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0495`. | ||
For more information about this error, try `rustc --explain E0621`. |