Skip to content

Use span context for enclosing item(s) of unmet bound - #163057

Open
estebank wants to merge 3 commits into
rust-lang:mainfrom
estebank:required-bound-context
Open

estebank wants to merge 3 commits into
rust-lang:mainfrom
estebank:required-bound-context

Conversation

@estebank

Copy link
Copy Markdown
Contributor

Point at item that introduced an unmet bound and in the case of associated items, their container (trait/impl), without using a span label. This adds bits of code to the diagnostic, without explicitly pointing to it.

error[E0277]: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
  --> $DIR/issue-54108.rs:23:17
   |
LL |     type Size = <Self as SubEncoder>::ActualSize;
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<T as SubEncoder>::ActualSize + <T as SubEncoder>::ActualSize`
   |
   = help: the trait `Add` is not implemented for `<T as SubEncoder>::ActualSize`
note: required by a bound in `Encoder::Size`
  --> $DIR/issue-54108.rs:8:16
   |
LL | pub trait Encoder {
LL |     type Size: Add<Output = Self::Size>;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`

r? @oli-obk

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 20, 2026
@rust-log-analyzer

This comment has been minimized.

Point at item that introduced an unmet bound and in the case of associated items, their container (trait/impl), without using a span label. This adds bits of code to the diagnostic, without explicitly pointing to it.

```
error[E0277]: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
  --> $DIR/issue-54108.rs:23:17
   |
LL |     type Size = <Self as SubEncoder>::ActualSize;
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<T as SubEncoder>::ActualSize + <T as SubEncoder>::ActualSize`
   |
   = help: the trait `Add` is not implemented for `<T as SubEncoder>::ActualSize`
note: required by a bound in `Encoder::Size`
  --> $DIR/issue-54108.rs:8:16
   |
LL | pub trait Encoder {
LL |     type Size: Add<Output = Self::Size>;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`
```
@estebank
estebank force-pushed the required-bound-context branch from 522cd43 to 65dd911 Compare September 20, 2026 17:36
@rust-log-analyzer

This comment has been minimized.

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants