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

Remove unnecessary bounds on Error and Display implementations for TryLockError and PoisonError. #31589

Merged
merged 1 commit into from
Feb 14, 2016

Conversation

reem
Copy link
Contributor

@reem reem commented Feb 12, 2016

No description provided.

@sfackler
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 12, 2016

📌 Commit 8bbb70c has been approved by sfackler

@sfackler
Copy link
Member

Why is the Reflect bound there at all?

@reem
Copy link
Contributor Author

reem commented Feb 12, 2016

Error requires Reflect.

@sfackler
Copy link
Member

Ah

match *self {
TryLockError::Poisoned(..) => "poisoned lock: another task failed inside",
TryLockError::WouldBlock => "try_lock failed because the operation would block"
}.fmt(f)
Copy link
Member

Choose a reason for hiding this comment

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

How come this can't continue to delegate to the same implementation? It seems unfortunate to have to duplicate this with description above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling into the Error implementation via description would require adding a Reflect bound, which is not really needed here.

Copy link
Member

Choose a reason for hiding this comment

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

But you can't have an instance of TryLockError<T> where T isn't Reflect, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're dealing with a generic TryLockError<T> you would have to include the Reflect bound, which is annoying and impossible on stable, where you'd have to bound by Any, which is unnecessarily restrictive. You could do where TryLockError<T>: Display but this is also annoying if you have already asserted T: Display elsewhere.

EDIT: Actually under this definition you don't need any bounds on T, so that last line is wrong.

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Feb 13, 2016
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 13, 2016
bors added a commit that referenced this pull request Feb 13, 2016
@bors bors merged commit 8bbb70c into rust-lang:master Feb 14, 2016
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.

4 participants