Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error on temp value to point to the correct statement #133

Merged
merged 2 commits into from Dec 28, 2020
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Dec 28, 2020

The error used to point to a statement "inside" the macro invocation, rather than a real statement that makes sense from the user's point of view.

Before:

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`

After:

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
  |             argument requires that borrow lasts for `'static`

@dtolnay dtolnay merged commit c1fa241 into master Dec 28, 2020
@dtolnay dtolnay deleted the temp branch December 28, 2020 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant