Skip to content

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

Open
estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:required-bound-context
Open

estebank wants to merge 1 commit 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

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`
```
@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

Copy link
Copy Markdown
Collaborator

The job test-tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
downloading https://static.rust-lang.org/dist/2026-08-30/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz
extracting /checkout/obj/build/cache/2026-08-30/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz to /checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt
[TIMING:end] format::InternalRustfmt {  } -- 10.099
Diff in /checkout/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs:3962:
                 let short_item_name = with_forced_trimmed_paths!(tcx.def_path_str(item_def_id));
                 let mut multispan = MultiSpan::from(span);
                 let sm = tcx.sess.source_map();
-                if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = tcx.def_kind(item_def_id)
+                if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy =
+                    tcx.def_kind(item_def_id)
                     && let Some(ident) = tcx.opt_item_ident(tcx.parent(item_def_id))
                 {
                     multispan.push_span_context(ident.span);
fmt: checked 7278 files
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1665
Build completed unsuccessfully in 0:00:38

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