Skip to content

Remove Debug bound from Error downcast methods - #464

Open
00200200 wants to merge 1 commit into
dtolnay:masterfrom
00200200:downcast-display-only-context
Open

00200200 wants to merge 1 commit into
dtolnay:masterfrom
00200200:downcast-display-only-context

Conversation

@00200200

Copy link
Copy Markdown

Fixes #270.

.context() accepts a value that is Display + Send + Sync + 'static. is / downcast / downcast_ref / downcast_mut additionally required Debug, so a Display-only context could be attached and then not recovered.

Downcasting only needs TypeId, which does not depend on Debug.

Test plan

  • cargo test --test test_downcast test_downcast_display_only_context — failed to compile on master (E: Debug), passes after this change
  • cargo test --test test_downcast — all 8 tests pass
  • cargo test --tests — integration tests pass
  • cargo test --lib — unit tests pass

Context values only need Display, so Display-only context could be
attached but never recovered by is/downcast. Fixes dtolnay#270.
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.

Why does Error::downcast<E> and Error::is<E> require E: Debug

1 participant