Skip to content

Conversation

@RAprogramm
Copy link
Owner

Summary

  • refactor shorthand resolution to use irrefutable patterns and pointer-friendly projection handling
  • collapse conditional chains in the error trait generator and adjust option checks per Clippy
  • refresh projection documentation and trybuild coverage, including a nested projection pass case and updated stderr expectations

Testing

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

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

@RAprogramm RAprogramm merged commit b689970 into new_version Sep 20, 2025
1 of 2 checks passed
@RAprogramm RAprogramm deleted the codex/update-projection-parsing-and-coverage-tests branch September 20, 2025 05:42
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.

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".

Comment on lines 372 to +386
shorthand: &FormatArgShorthand,
placeholder: &TemplatePlaceholderSpec
) -> Result<ResolvedPlaceholderExpr, Error> {
match shorthand {
FormatArgShorthand::Named(ident) => {
let field = fields.get_named(&ident.to_string()).ok_or_else(|| {
Error::new(
ident.span(),
format!("unknown field `{}` in format arguments", ident)
)
})?;
Ok(struct_field_expr(field, placeholder.formatter))
}
FormatArgShorthand::Positional {
index,
span
} => {
let field = fields.get_positional(*index).ok_or_else(|| {
Error::new(
*span,
format!("field `{}` is not available in format arguments", index)
)
})?;
Ok(struct_field_expr(field, placeholder.formatter))
}
let FormatArgShorthand::Projection(projection) = shorthand;

let (expr, first_field, has_tail) = struct_projection_expr(fields, projection)?;

if !has_tail && let Some(field) = first_field {
return Ok(struct_field_expr(field, placeholder.formatter));
}

if needs_pointer_value(placeholder.formatter) {
Ok(ResolvedPlaceholderExpr::with(expr, false))
} else {
Ok(ResolvedPlaceholderExpr::new(quote!(&(#expr))))

Choose a reason for hiding this comment

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

[P1] Borrow nested projections before pointer formatting

When a shorthand projection resolves to more than one segment and the placeholder uses the pointer formatter ({:p}), the generated code returns the projection expression without taking a reference (ResolvedPlaceholderExpr::with(expr, false)). For projections like .inner.value where the final value is not itself a pointer, this expands to Pointer::fmt(self.inner.value, f) and fails to compile because i32 (and most values) do not implement Pointer. The simple-field path still borrows correctly, so the regression only appears for the new nested projections and affects both structs and variants. The expression should be wrapped in &(expr) unless the projection’s result is already a pointer type.

Useful? React with 👍 / 👎.

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.

2 participants