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

Failed to inference return type of closure. #6352

Closed
12101111 opened this issue Oct 25, 2020 · 3 comments
Closed

Failed to inference return type of closure. #6352

12101111 opened this issue Oct 25, 2020 · 3 comments
Labels
A-ty type system / type inference / traits / method resolution

Comments

@12101111
Copy link

The code is https://github.com/rust-lang/rust/blob/master/src/bootstrap/config.rs#L560

image

The type of closure get_toml, toml and included_toml is inferenced to (), but it should be TomlConfig.

Even with a type annotation, the return type of get_toml is still ()
image

@flodiebold
Copy link
Member

flodiebold commented Oct 25, 2020

What happens if you move the local use std::process outside of the function? Or alternatively fully qualify the std::process:exit call.

@flodiebold flodiebold added the A-ty type system / type inference / traits / method resolution label Oct 25, 2020
@12101111
Copy link
Author

use std::process outside of the function:
image
use std::process:exit:
image

@flodiebold
Copy link
Member

So this is just a case of #1165; because the process::exit call isn't resolved when you're using a local import, we don't know that the error case diverges, so it gets typed as (), and since the type of table can be anything at that point, it'll get unified to () as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution
Projects
None yet
Development

No branches or pull requests

2 participants