Skip to content

Fix linker error by resolving regions for main return type obligations#151377

Open
xonx4l wants to merge 5 commits intorust-lang:mainfrom
xonx4l:main_termination
Open

Fix linker error by resolving regions for main return type obligations#151377
xonx4l wants to merge 5 commits intorust-lang:mainfrom
xonx4l:main_termination

Conversation

@xonx4l
Copy link
Contributor

@xonx4l xonx4l commented Jan 19, 2026

This PR fix linker error by resolving regions for main return type obligations as discussed in #148421

Added a final check . Now the compiler double-checks the lifetimes for main right away. If they don't work it stops and gives the user a clean compiler error instead of a linker crash.

@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 Jan 19, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 19, 2026

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

}

let region_errors =
infcx.resolve_regions(main_diagnostics_def_id, param_env, tcx.mk_type_list(&[]));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I'm slightly unsure about is the diagnostic span main_diagnostics_def_id as this points to the function as a whole.

Copy link
Contributor

Choose a reason for hiding this comment

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

This DefId is the context in which we're emitting the errors, so it should be the DefId of the whole body. This is correct. Please use ty::List::empty() instead of mk_type_list

Also, can you change this function to return Result<(), ErrorGuaranteed> and instead of using error = true just return Err(guar).

We shouldn't emit region errors if there are fulfillment errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lcnr sorry I was a bit busy . I have made the the changes you asked for . Thanks!

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot 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 Jan 22, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 22, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-log-analyzer

This comment has been minimized.

@xonx4l
Copy link
Contributor Author

xonx4l commented Feb 7, 2026

@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 Feb 7, 2026
@fee1-dead
Copy link
Member

Overall looks correct, but for signoff:

r? lcnr

@rustbot rustbot assigned lcnr and unassigned fee1-dead Feb 17, 2026
@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 21, 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.

@xonx4l
Copy link
Contributor Author

xonx4l commented Feb 23, 2026

@rustbot ready


if error {
return;
return Ok(());
Copy link
Contributor

Choose a reason for hiding this comment

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

?

we should return Err(ErrorGuaranteed) here

.is_err()
{
return;
return Ok(());
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants