Skip to content

Infer default source/backtrace fields#65

Merged
RAprogramm merged 1 commit intonew_versionfrom
codex/update-field-attribute-inference-for-sources
Sep 19, 2025
Merged

Infer default source/backtrace fields#65
RAprogramm merged 1 commit intonew_versionfrom
codex/update-field-attribute-inference-for-sources

Conversation

@RAprogramm
Copy link
Owner

Summary

  • infer FieldAttrs metadata for unannotated source and Backtrace members so the derive matches thiserror
  • update code generation to rely on the new has_source/has_backtrace flags instead of raw attributes
  • extend derive tests for structs and enums without explicit #[source] / #[backtrace]
  • bump crate versions to 0.5.8 / 0.1.4, update README and changelog entries

Testing

  • cargo +nightly fmt --
  • cargo +1.90.0 clippy -- -D warnings
  • cargo +1.90.0 build --all-targets
  • cargo +1.90.0 test --all
  • cargo +1.90.0 doc --no-deps
  • cargo +1.90.0 audit
  • cargo +1.90.0 deny check

https://chatgpt.com/codex/tasks/task_e_68ccf855ef10832baf1cd8aee6264f3f

@RAprogramm RAprogramm merged commit 73955b8 into new_version Sep 19, 2025
1 of 2 checks passed
@RAprogramm RAprogramm deleted the codex/update-field-attribute-inference-for-sources branch September 19, 2025 06:49
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

if result.source.is_none() && ident.is_some_and(|ident| ident == "source") {
result.inferred_source = true;
}
if result.backtrace.is_none() {
if is_option_type(ty) {
if option_inner_type(ty).is_some_and(is_backtrace_type) {
result.inferred_backtrace = true;
}
} else if is_backtrace_type(ty) {
result.inferred_backtrace = true;

[P1] Restrict backtrace inference to std::backtrace::Backtrace

The new inference treats any field whose type name ends with Backtrace as a backtrace (even when it comes from another crate). If a project defines struct Error { trace: other_crate::Backtrace } without any attributes, the derive now generates a fn backtrace(&self) -> Option<&std::backtrace::Backtrace> and tries to return &self.trace, which does not type‑check because other_crate::Backtrace is unrelated to std::backtrace::Backtrace. This behaviour is a regression from the previous release (where such fields were ignored unless explicitly annotated) and will break existing users that rely on custom Backtrace types. Consider verifying the full path is std::backtrace::Backtrace/Option<std::backtrace::Backtrace> before setting inferred_backtrace.


Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant