-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Compiler doesn't warn on infinite recursion in trait's method #78521
Comments
It's because the |
This isn't the case in your code because |
@jonas-schievink Ah you're correct, although to be honest I believe it should still warn, as otherwise you get abort at runtime without even knowing reason (since it is just stack overflow) @SNCPlay42 in my case it does call itself, which leads to stack overflow otherwise I wouldn't crate issue |
Seems like a duplicate of #78474. |
It does – but this issue actually invokes a diverging function, so the proposed fix for that issue in #78474 (comment) probably won't fix this one |
I think the idea of #78474 (comment) can fix it because the return type of |
|
I meant fn debug_assert_func(flg : bool) -> () {
if !flg {
panic!()
}
} Ah, but, it's a macro not a function. So, the type-based approach in #78474 may not be applicable here... |
Example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4782b3bebc1e92369e5ff7b3c5b4a6e1
Visible on both stable and nightly.
Compiler warns on infinite recursion in case of regular method:
Compiler doesn't issue the same warning in case of trait's method
I suspect it should?
The text was updated successfully, but these errors were encountered: