Skip to content

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

Open
xonx4l wants to merge 1 commit intorust-lang:mainfrom
xonx4l:main_termination
Open

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

Conversation

@xonx4l
Copy link
Copy Markdown
Contributor

@xonx4l xonx4l commented Jan 19, 2026

View all comments

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.

Fixes #148421.

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

This comment has been minimized.

@xonx4l
Copy link
Copy Markdown
Contributor Author

xonx4l commented Feb 23, 2026

@rustbot ready


if error {
return;
return Ok(());
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.

?

we should return Err(ErrorGuaranteed) 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.

I am sorry I got a bit busy and it just slipped out of my focus . Updated to enforce Err(ErrorGuaranteed). Thanks !

.is_err()
{
return;
return Ok(());
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.

and here

@rust-bors

This comment has been minimized.

@xonx4l xonx4l force-pushed the main_termination branch from 48c7506 to ce665cd Compare March 24, 2026 04:57
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 24, 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.

.and(items.par_opaques(|item| tcx.ensure_result().check_well_formed(item)));
super::entry::check_for_entry_fn(tcx);

super::entry::check_for_entry_fn(tcx)?;
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.

why not part of the and 🤔

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.

I kept it separate to make sure error is propagated.

@@ -0,0 +1,15 @@
// check-fail
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.

check-fail isn't necessary.

Can you add a comment for what this is testing (and link to the issue in the file (and not necessarily in the test name))

Copy link
Copy Markdown
Contributor Author

@xonx4l xonx4l Mar 26, 2026

Choose a reason for hiding this comment

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

Okay will add.

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 8, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

📌 Commit a39e746 has been approved by lcnr

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 Apr 8, 2026
@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 8, 2026

@bors squash="Fix linker error by resolving regions for main return type obligations"

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

Unknown command "squash". Run @bors help to see available commands.

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 8, 2026

@bors help

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

You can use the following commands:

PR management

  • r+ [p=<priority>] [rollup=<never|iffy|maybe|always>]: Approve this PR on your behalf
    • Optionally, you can specify the <priority> of the PR and if it is eligible for rollups (<rollup>).
  • r=<user> [p=<priority>] [rollup=<never|iffy|maybe|always>]: Approve this PR on behalf of <user>
    • Optionally, you can specify the <priority> of the PR and if it is eligible for rollups (<rollup>).
    • You can pass a comma-separated list of GitHub usernames.
  • r-: Unapprove this PR
  • p=<priority> or priority=<priority>: Set the priority of this PR
  • rollup=<never|iffy|maybe|always>: Set the rollup status of the PR
  • rollup: Short for rollup=always
  • rollup-: Short for rollup=maybe
  • delegate=<try|review>: Delegate permissions for running try builds or approving to the PR author
    • try allows the PR author to start try builds.
    • review allows the PR author to both start try builds and approve the PR.
  • delegate | delegate+: Delegate approval permissions to the PR author
    • Shortcut for delegate=review
  • delegate-: Remove any previously granted permission delegation
  • try [parent=<parent>] [job|jobs=<jobs>]: Start a try build.
    • Optionally, you can specify a <parent> SHA with which will the PR be merged. You can specify parent=last to use the same parent SHA as the previous try build.
    • Optionally, you can select a comma-separated list of CI <jobs> to run in the try build.
  • try cancel: Cancel a running try build on the current PR.
  • retry: Clear a failed auto build status from an approved PR. This will cause the merge queue to eventually attempt to merge the PR again.
  • cancel | yield: Cancel a running auto build on the current PR.
  • squash [msg|message=<commit-message>]: Squash the commits of a PR into a single commit.
    • Optionally, you can specify a <commit-message> for the created commit. If not specified, the commit messages of all squashed commits will be combined.
  • info: Get information about the current PR

Repository management

  • treeclosed=<priority>: Close the tree for PRs with priority less than <priority>
  • treeclosed- or treeopen: Open the repository tree for merging

Meta commands

  • ping: Check if the bot is alive
  • help: Print this help message

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 8, 2026

@bors squash

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

🚧 Squashing... this can take a few minutes.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

❗ Failed to push the squashed commit to xonx4l/rust:main_termination: Push timeouted

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 8, 2026

@bors r-

@bors delegate+

@rust-bors rust-bors bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 8, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

✌️ @xonx4l, you can now approve this pull request!

If @lcnr told you to "r=me" after making some further change, then please make that change and post @bors r=lcnr.

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 8, 2026
@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 8, 2026

can you please squash your commits, then r=me

@xonx4l xonx4l force-pushed the main_termination branch from a39e746 to dbc08cf Compare April 9, 2026 14:39
@xonx4l
Copy link
Copy Markdown
Contributor Author

xonx4l commented Apr 9, 2026

@bors r=lcnr

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 9, 2026

📌 Commit dbc08cf has been approved by lcnr

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 9, 2026
Fix linker error by resolving regions for main return type obligations

This PR fix linker error by resolving regions for main return type obligations as discussed in rust-lang#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.

Fixes rust-lang#148421.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 9, 2026
Fix linker error by resolving regions for main return type obligations

This PR fix linker error by resolving regions for main return type obligations as discussed in rust-lang#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.

Fixes rust-lang#148421.
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main() returning a type that implements Termination with an unsatisfied lifetime bound gives a linker error

5 participants