Skip to content

Commit

Permalink
Improve error on temp value to point to the correct statement
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 28, 2020
1 parent 91b970e commit 86dd074
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ macro_rules! anyhow {
};
($err:expr $(,)?) => ({
use $crate::private::kind::*;
let error = $err;
(&error).anyhow_kind().new(error)
match $err {
error => (&error).anyhow_kind().new(error),
}
});
($fmt:expr, $($arg:tt)*) => {
$crate::private::new_adhoc(format!($fmt, $($arg)*))
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/temporary-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ error[E0716]: temporary value dropped while borrowed
--> $DIR/temporary-value.rs:4:22
|
4 | let _ = anyhow!(&String::new());
| ---------^^^^^^^^^^^^^-
| ---------^^^^^^^^^^^^^-- temporary value is freed at the end of this statement
| | |
| | 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 86dd074

Please sign in to comment.