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
Proposal: Attribute noreturn functions #764
Comments
Bonus points if the metadata can reuse the |
@AArnott Good catch. I was looking for an existing attribute and missed this one. I would definitely prefer this over a new one. |
Assigning to @sotteson1 to see about scraping this from the headers and emitting as DoesNotReturnAttribute. |
I'm wondering why a function that returns void needs an attribute to indicate it doesn't return anything. Isn't that what returning void means? |
It's not that it doesn't return anything - it's that it doesn't return at all. Functions like https://en.cppreference.com/w/cpp/language/attributes/noreturn |
Oh, got it. |
|
I propose that win32metadata emit an attribute (e.g.
Windows.Win32.Interop.NoReturnAttribute
) attached to functions and methods that do not return to the caller (e.g. FatalExit). This will allow languages, such as Rust (never, !
), to generate smarter bindings, enabling better optimization of noreturn code paths, detection of dead code paths (that is, code that is mistakenly placed after the call of a noreturn function), and other benefits.Some noreturn APIs are already annotated in the source material.
Continuing with the
FatalExit
example:Some other forms found in the source material to be aware of:
A theoretical example of how this could look in metadata:
The text was updated successfully, but these errors were encountered: