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

Simplify Display impl #579

Merged
merged 1 commit into from
Aug 20, 2023
Merged

Simplify Display impl #579

merged 1 commit into from
Aug 20, 2023

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Aug 20, 2023

For some reason, fmt::Display for Error uses an unusual form match &self.inner { &Value(ref err) => err.fmt(f), ...}. It seems Value(err) will work just as well.

If this is actually needed, we should add some comment explaining why so

For some reason, `fmt::Display for Error` uses an unusual form `match &self.inner { &Value(ref err) => err.fmt(f), ...}`.  It seems `Value(err)` will work just as well.

If this is actually needed, we should add some comment explaining why so
Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was required in older rustc versions where you had to be explicit about whether you owned the variables (err and msg) or had a reference to them (ref err or ref msg). But the compiler got better at determining this for us, so now we can use cleaner code like this.

@KodrAus KodrAus merged commit b7ac2ba into rust-lang:master Aug 20, 2023
14 checks passed
@nyurik nyurik deleted the display-impl branch August 21, 2023 01:14
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.

3 participants