Skip to content

feat: add #[diagnostic::on_unimplemented] to IntoResponse and IntoResponseParts#3723

Merged
yanns merged 3 commits intotokio-rs:mainfrom
dihannahdi:feat/into-response-diagnostic
Apr 15, 2026
Merged

feat: add #[diagnostic::on_unimplemented] to IntoResponse and IntoResponseParts#3723
yanns merged 3 commits intotokio-rs:mainfrom
dihannahdi:feat/into-response-diagnostic

Conversation

@dihannahdi
Copy link
Copy Markdown
Contributor

Motivation

The FromRequest, FromRequestParts, and Handler traits already use #[diagnostic::on_unimplemented] to provide helpful compiler messages when users encounter trait bound errors. However, IntoResponse and IntoResponseParts — two of the most commonly encountered traits in error messages — lack this attribute.

When users forget to implement IntoResponse on their custom response types (or return types that don't implement it), the compiler shows a bare "trait bound not satisfied" error without guidance.

Solution

Add #[diagnostic::on_unimplemented] to both IntoResponse and IntoResponseParts traits in axum-core, with links to the relevant documentation pages. This matches the existing pattern used by the extractor and handler traits.

…ponseParts

Add #[diagnostic::on_unimplemented] attributes to the IntoResponse and
IntoResponseParts traits, matching the pattern already used on
FromRequest, FromRequestParts, and Handler.

This improves compiler error messages when users forget to implement
these traits on their response types, providing a direct link to the
relevant documentation.
@dihannahdi dihannahdi force-pushed the feat/into-response-diagnostic branch from 14df507 to f3951a4 Compare April 12, 2026 13:20
@yanns yanns merged commit 309d1bd into tokio-rs:main Apr 15, 2026
17 checks passed
davidpdrsn pushed a commit that referenced this pull request May 5, 2026
davidpdrsn pushed a commit that referenced this pull request May 5, 2026
davidpdrsn added a commit that referenced this pull request May 5, 2026
… and `IntoResponseParts` (#3723)"

This reverts commit 7bf2f67.
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.

2 participants