Skip to content

Commit

Permalink
Add ui test of temporary value in anyhow macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 28, 2020
1 parent f9419cd commit 91b970e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/ui/temporary-value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::anyhow;

fn main() {
let _ = anyhow!(&String::new());
}
9 changes: 9 additions & 0 deletions tests/ui/temporary-value.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/temporary-value.rs:4:22
|
4 | let _ = anyhow!(&String::new());
| ---------^^^^^^^^^^^^^-
| | |
| | creates a temporary which is freed while still in use
| temporary value is freed at the end of this statement
| argument requires that borrow lasts for `'static`

0 comments on commit 91b970e

Please sign in to comment.