Skip to content

Explain unsatisfied trait bounds on borrowed values - #1643

Merged
sbillig merged 4 commits into
masterfrom
fix/trait-bound-diag-view-capability
Oct 2, 2026
Merged

sbillig merged 4 commits into
masterfrom
fix/trait-bound-diag-view-capability

Conversation

@cburgdorf

Copy link
Copy Markdown
Collaborator

When a borrowed value (e.g. a non-Copy T parameter declared without own) was put into a tuple or struct passed to a bounded function, the error printed "(String<25>, T, String<6>) doesn't implement AsBytes" and "trait bound T: AsBytes is not satisfied", although T: AsBytes holds. The failing type is the borrowed T, whose capability the type printer hides because it has no source syntax.

When the bound holds for the underlying type, the error now replaces the misleading sub-goal line with "the T value here is only borrowed, so the AsBytes impl for T does not apply", explains that parameters declared without own are borrowed, and suggests taking the value as own T (or requiring T: Copy for generic parameters). Types are still printed as before.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T16:57:30.757167Z c2f7162 New commits
🔒 Security Review ✅ Completed 2026-09-30T01:22:27.163238Z cfd46a6 New commits
ℹ️ 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
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: 5c2dadfdec

ℹ️ 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
  • 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 address that feedback".

Comment thread crates/hir/src/analysis/diagnostics.rs Resolved
@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from 5c2dadf to ef8fcfa Compare September 29, 2026 21:57

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: ef8fcfaec8

ℹ️ 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
  • 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 address that feedback".

Comment thread crates/hir/src/analysis/diagnostics.rs Resolved
@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from ef8fcfa to 8f2ad96 Compare September 29, 2026 22:15

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: 8f2ad96b95

ℹ️ 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
  • 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 address that feedback".

@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch 2 times, most recently from fad9020 to 2666793 Compare September 29, 2026 22:40

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: 2666793547

ℹ️ 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
  • 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 address that feedback".

@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch 2 times, most recently from 2666793 to 1fbf3e9 Compare September 29, 2026 22:58

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: 1fbf3e9706

ℹ️ 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
  • 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 address that feedback".

Comment thread crates/hir/src/analysis/diagnostics.rs Resolved
@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from 1fbf3e9 to 4bf452f Compare September 29, 2026 23:18

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: 4bf452fb58

ℹ️ 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
  • 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 address that feedback".

@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from 4bf452f to f4b4c16 Compare September 29, 2026 23:40

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: f4b4c166cb

ℹ️ 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
  • 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 address that feedback".

@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from f4b4c16 to cab8067 Compare September 30, 2026 00:03

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: cab8067db6

ℹ️ 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
  • 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 address that feedback".

@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from cab8067 to c108024 Compare September 30, 2026 00:27

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: c108024f4d

ℹ️ 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
  • 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 address that feedback".

@cburgdorf
cburgdorf force-pushed the fix/trait-bound-diag-view-capability branch from c108024 to c5b7880 Compare September 30, 2026 00:52

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: c5b7880c2f

ℹ️ 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
  • 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 address that feedback".

cburgdorf and others added 2 commits October 1, 2026 20:30
When a borrowed value (e.g. a non-Copy `T` parameter declared without
`own`) was put into a tuple or struct passed to a bounded function, the
error printed "`([u8; 25], T, [u8; 6])` doesn't implement `AsBytes`"
and "trait bound `T: AsBytes` is not satisfied", although `T: AsBytes`
holds. The failing type is the borrowed `T`, whose capability the type
printer hides because it has no source syntax.

When owning the borrowed type would satisfy the bound, the error now
replaces the misleading sub-goal line with "`T` is only borrowed here;
the bound would be satisfied if it were owned" and explains that values
reached through parameters declared without `own` are borrowed. No impl
is named and no edit is suggested. This is only reported when it is
provably true: the borrowed type must occur exactly once in the bound's
self type (trait arguments and associated type bindings that the
declared bound writes in terms of its self type alone, as in `X: Eq` or
`Out<Item = (X,)>`, follow it and are recomputed for the owned type), and
the bound must hold with it owned. Types are still printed as before.
@sbillig
sbillig force-pushed the fix/trait-bound-diag-view-capability branch from cfd46a6 to 9b4af07 Compare October 2, 2026 03:31
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

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

Copy link
Copy Markdown

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 automated review suggestions for this pull request.

Reviewed commit: 9b4af07f4e

ℹ️ 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
  • 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 address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@sbillig
sbillig merged commit 1fe8d20 into master Oct 2, 2026
9 checks passed
@sbillig
sbillig deleted the fix/trait-bound-diag-view-capability branch October 2, 2026 17:57
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