Conversation
✅ Deploy Preview for shepmaster-snafu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generic libraries may need to preserve a typed failure without requiring the underlying value to implement
Erroror be'static. Currently, SNAFU’s construction and diagnostic requirements make this difficult without adding bounds to the public API or writing implementations manually.This change allows construction independently of diagnostic capabilities. Generated
Display,Error, andErrorCompatimplementations have their own bounds.This follows the model used by common derives such as
Debug,Default, andOrd: a generic type can derive a trait without requiring its type parameters to implement that trait at the type declaration. The derive adds the necessary bounds to the generated implementation instead, making that implementation available conditionally. Those derives can infer conservative bounds; the relevant principle here is where the constraints belong.For example:
attachaccepts borrowed payloads that implement neitherDebugnorError.ReadFailure<std::io::Error>still implementsErrorand exposes its source normally.Changes
IntoError<E>and the corresponding synchronous, future, and stream context adapters.display_bounds(...),error_bounds(...), anderror_compat_bounds(...)overrides. Each replaces inference for its corresponding implementation; an empty list disables that inference. Bounds declared on the type remain in effect.Compatibility and limitations
This includes breaking changes. Removing the bounds from
IntoError<E>can break generic code that previously obtainedE: Error + ErrorCompatfromC: IntoError<E>. Such code must state the capabilities it uses explicitly.Formatting inference is syntactic and best effort. Arbitrary expressions, such as a trait method call or transformation, may require explicit
display_bounds. Formatting itself remains delegated to Rust’s formatting macros.Source inference does not perform name resolution or arbitrary autoderef analysis. Aliases, custom pointers, and mutually recursive generic types may require explicit overrides. This can also require changes to existing definitions.
The generated
Errorimplementation still requiresSelf: Debug + Display. Sources exposed through the standard error chain must satisfy its'staticrequirement; this does not impose'staticon every context field.ErrorCompatremains independently available.Constructors that generate source-aware implicit data retain the source capabilities required by
GenerateImplicitData::generate_with_source. The implementation-bound overrides do not change those constructor requirements.Validation
Local validation passed for:
thumbv6m-none-eabibuilds on stable, Rust 1.81, and nightly, covering the applicable alloc, futures, and provider API combinations.The nightly checks used
rustc 1.100.0-nightly (feaadeeac 2026-09-19).Clippy completed with existing warnings. CI now includes additional generic-error checks for MSRV, embedded targets, and the provider API.
Feedback requested
This is a draft to discuss whether construction and diagnostic capabilities should be separated this way, whether the per-trait override attributes are the right API, and how the compatibility changes should be introduced.
AI assistance
OpenAI Codex assisted with the implementation, tests, documentation, and validation.