Fix linker error by resolving regions for main return type obligations#151377
Fix linker error by resolving regions for main return type obligations#151377xonx4l wants to merge 5 commits intorust-lang:mainfrom
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
| } | ||
|
|
||
| let region_errors = | ||
| infcx.resolve_regions(main_diagnostics_def_id, param_env, tcx.mk_type_list(&[])); |
There was a problem hiding this comment.
One thing I'm slightly unsure about is the diagnostic span main_diagnostics_def_id as this points to the function as a whole.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@lcnr sorry I was a bit busy . I have made the the changes you asked for . Thanks!
This comment has been minimized.
This comment has been minimized.
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
|
Overall looks correct, but for signoff: r? lcnr |
This comment has been minimized.
This comment has been minimized.
ddf220c to
48c7506
Compare
|
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. |
|
@rustbot ready |
|
|
||
| if error { | ||
| return; | ||
| return Ok(()); |
There was a problem hiding this comment.
?
we should return Err(ErrorGuaranteed) here
| .is_err() | ||
| { | ||
| return; | ||
| return Ok(()); |
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.