Skip to content

delegation: emit error when there is an error in lowered user-specified generic args#156953

Open
aerooneqq wants to merge 3 commits into
rust-lang:mainfrom
aerooneqq:delegation-emit-err-when-incorrect-gen-args
Open

delegation: emit error when there is an error in lowered user-specified generic args#156953
aerooneqq wants to merge 3 commits into
rust-lang:mainfrom
aerooneqq:delegation-emit-err-when-incorrect-gen-args

Conversation

@aerooneqq
Copy link
Copy Markdown
Contributor

@aerooneqq aerooneqq commented May 26, 2026

This PR checks if lowered user-specified generic args reference error and emits error if so. And get_delegation_user_specified_args is now query as we invoke it two times.

Somewhat similar to #156565.

Fixes #156848. Part of #118212.
r? @petrochenkov

@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. labels May 26, 2026
@aerooneqq aerooneqq changed the title delegation: emit error when there is an error in lowered user-specified generic args delegation: emit error when there is an error in lowered user-specified generic args May 26, 2026
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label May 26, 2026

// If self type is present skip it, as error will be emitted when self type will be accessed.
let skip_self = self_ty.is_some() as usize;
if parent_args.iter().skip(skip_self).chain(child_args).any(|arg| arg.references_error()) {
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov May 26, 2026

Choose a reason for hiding this comment

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

The referenced error here is constructed using ErrorGuaranteed from a span_delayed_bug in HIR->ty lowering.

Our conclusion here is that some regular error (not a delayed bug) needs to be reported there, instead of reporting this kind of "some unknown error happened in the past" message post-factum.

It's not very clear what that error should be, and whether the code from #156848 should compile or not at all, and how an explicitly passed '_ should be propagated.

View changes since the review

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2026
@rust-bors

This comment has been minimized.

@aerooneqq aerooneqq force-pushed the delegation-emit-err-when-incorrect-gen-args branch from bcc26f4 to cb59243 Compare June 1, 2026 06:22
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 1, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@aerooneqq
Copy link
Copy Markdown
Contributor Author

Now the error is emitted from re_infer which should be better than before.
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 1, 2026
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

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

Labels

F-fn_delegation `#![feature(fn_delegation)]` 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: unelided lifetime in signature

4 participants