Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize associated type projections when checking return type of main #88706

Merged
merged 2 commits into from
Oct 6, 2021

Conversation

ThePuzzlemaker
Copy link
Contributor

This fixes #88609.

Previously, the return type of fn main() would not have any associated type projections within normalized before checking if it implements the standard library trait std::process::Termination. This commit appears to fix it.

This feels vaguely symptomatic of a problem in the underlying trait solving engine, but I am not sure how I would solve that. I am unsure why the example in #88609 with assert_impl_termination and fn foo() work, but simply fn main() doesn't. The way that I solved this is also probably not the best way to do this, so please let me know if there is a better way to do this.

I have added a build-pass regression test for this issue.

@rust-highfive
Copy link
Collaborator

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 6, 2021
@ThePuzzlemaker
Copy link
Contributor Author

This is my first time actually touching anything within typechecking, so please let me know if I accidentally silently broke something or did something wrong. 😅

This fixes rust-lang#88609.

Previously, the return type of `fn main()` would not have any associated
type projections within normalized before checking if it implements the
standard library trait `std::process::Termination`. This commit appears
to fix it.

This feels vaguely symptomatic of a problem in the underlying trait
solving engine, but I am not sure how I would solve that. I am unsure
why the example in rust-lang#88609 with `assert_impl_termination` and `fn foo()`
work, but simply `fn main()` doesn't. The way that I solved this is also
probably not the best way to do this, so please let me know if there is
a better way to do this.

I have added a build-pass regression test for this issue.
@rust-log-analyzer

This comment has been minimized.

@jackh726
Copy link
Member

jackh726 commented Sep 6, 2021

r? @jackh726

@rust-highfive rust-highfive assigned jackh726 and unassigned nagisa Sep 6, 2021
Use register_predicate_obligations rather than a for loop, since I
didn't see that before. Also destructure in the `let` rather than
projecting the fields individually
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 27, 2021
Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

I wanted to think more about this, if there's a better way to do this. But I think this is fine for now.

@jackh726
Copy link
Member

jackh726 commented Oct 5, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 5, 2021

📌 Commit 33a2825 has been approved by jackh726

@bors bors 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 Oct 5, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2021
…arth

Rollup of 10 pull requests

Successful merges:

 - rust-lang#88706 (Normalize associated type projections when checking return type of main)
 - rust-lang#88828 (Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock)
 - rust-lang#88871 (Fix suggestion for nested struct patterns)
 - rust-lang#89317 (Move generic error message to separate branches)
 - rust-lang#89351 (for signed wrapping remainder, do not compare lhs with MIN)
 - rust-lang#89442 (Add check for duplicated doc aliases)
 - rust-lang#89502 (Fix Lower/UpperExp formatting for integers and precision zero)
 - rust-lang#89523 (Make `proc_macro_derive_resolution_fallback` a future-breakage lint)
 - rust-lang#89532 (Document behavior of  `MaybeLiveLocals` regarding enums and field-senstivity)
 - rust-lang#89546 (Make an initial guess for metadata size to reduce buffer resizes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 960e49e into rust-lang:master Oct 6, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 6, 2021
@ThePuzzlemaker ThePuzzlemaker deleted the issue-88609 branch October 6, 2021 01:33
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checking that main's output type implements Termination doesn't normalize associated types
8 participants