-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Type inference of a diverging function is weird #20172
Comments
There is no longer a bottom type; it was removed (see issue #14973), replaced with treating a function returning It is not clear to me from the issue description whether the problem here is merely one of documentation needing updating, or if there is some more fundamental issue that needs to be addressed. |
@pnkfelix Oh, I didn't know it had already been removed. Then these statements should at least be updated accordingly:
The way I understood your explanation is: "diverging-ness" of a function is specific to each function marked with But then, I think |
The semicolon example not compiling doesn't have anything to do with bottom. |
These two codes compile fine:
but this does not (note the semicolon after
f()
):Though the Rust language reference seems to say there's an (inhabitable) type called the "bottom type," the behavior of
rustc
is almost as if the bottom type does not really exist in Rust. These examples gave me an impression that a type equation involving a diverging function is simply discarded (otherwiseR
in the last example should correctly be inferred as the bottom type and there should be no difference betweenfoo();
andpanic();
,) though I'm awarelibrustc/middle/infer/combine.rs
does consistency check ofFnDiverigng
...See also #20105 which was originally filed as a complaint for not allowing this code:
The text was updated successfully, but these errors were encountered: