Skip to content

mention the opaque when its hidden type cannot be inferred - #162172

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Albab-Hasan:opaque-hidden-type-inference-note
Sep 11, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Albab-Hasan:opaque-hidden-type-inference-note

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

when the hidden type of an opaque was never constrained, typeck reported E0282 with only the shared cannot infer type label. nothing in the output said an opaque was involved, so the error read like an ordinary local inference failure.

the unconstrained hidden type arm now adds a note naming the opaque as the source of the ambiguity.

fixes #146231

r? @lcnr

when the hidden type of an opaque was never constrained, typeck reported
E0282 with only the shared cannot infer type label. nothing in the output
said an opaque was involved, so the error read like an ordinary local
inference failure.

the unconstrained hidden type arm now adds a note naming the opaque as the
source of the ambiguity.

fixes rust-lang#146231
@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 2, 2026
@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

@rustbot reroll

@rustbot rustbot assigned chenyukang and unassigned lcnr Sep 10, 2026
@chenyukang

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c4c6569 has been approved by chenyukang

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 11, 2026
Rollup of 10 pull requests

Successful merges:

 - #162270 (Update `windows-bindgen` to 0.100.0)
 - #162492 (Revert "Rollup merge of #157518 - CAD97:xdg_basedir, r=aapoalas")
 - #162607 (Basic cleanup in `rustc_transmute`)
 - #162619 (Add test for the missing Clone requirement for Cow slices)
 - #162172 (mention the opaque when its hidden type cannot be inferred)
 - #162514 (Simplify diagnostic levels)
 - #162546 (Use lld by default on `loongarch64-unknown-linux-gnu` nightly)
 - #162564 (yeet StabilityLevel)
 - #162613 (iter::repeat_with, iter::successors, iter::from_fn added as diagnostic items)
 - #162616 (regression test for async main diagnostic)
@rust-bors
rust-bors Bot merged commit 8abb416 into rust-lang:main Sep 11, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 11, 2026
Rollup merge of #162172 - Albab-Hasan:opaque-hidden-type-inference-note, r=chenyukang

mention the opaque when its hidden type cannot be inferred

when the hidden type of an opaque was never constrained, typeck reported `E0282` with only the shared cannot infer type label. nothing in the output said an opaque was involved, so the error read like an ordinary local inference failure.

the unconstrained hidden type arm now adds a note naming the opaque as the source of the ambiguity.

fixes #146231

r? @lcnr
// The shared E0282 label only says "cannot infer type", which gives no
// hint that the ambiguity is in an opaque's hidden type rather than an
// ordinary local inference failure.
.with_note("cannot infer type of hidden type of opaque")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you change this to also point at the def_span of the opaque type 🤔 that feels like it would be really useful as some of the tests just point at some local assignment here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 14, 2026
…constrained-hidden-type, r=lcnr

point at the opaque when its hidden type cannot be inferred

the note added in rust-lang#162172 now points at the opaque definition, unless the error already points inside it.

r? @lcnr
rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
Rollup merge of #164309 - Albab-Hasan:point-at-opaque-for-unconstrained-hidden-type, r=lcnr

point at the opaque when its hidden type cannot be inferred

the note added in #162172 now points at the opaque definition, unless the error already points inside it.

r? @lcnr
josetorrs pushed a commit to josetorrs/miri that referenced this pull request Oct 16, 2026
…ed-hidden-type, r=lcnr

point at the opaque when its hidden type cannot be inferred

the note added in rust-lang/rust#162172 now points at the opaque definition, unless the error already points inside it.

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

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

-Znext-solver ambiguous opaque types in HIR typeck result in poor errors

4 participants