-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
reduce unreachable-code churn after todo!()
#149543
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
base: main
Are you sure you want to change the base?
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
|
Could you please also add a link to the Zulip discussion? It would help provide context. Also, could you please add a test to demonstrate that it works? |
| && self.expr_guaranteed_to_constitute_read_for_never(expr) | ||
| { | ||
| self.diverges.set(self.diverges.get() | Diverges::always(expr.span)); | ||
| let diverges = if self.is_todo_macro(expr.span) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we find that this is too heavy on perf (which it would only be in macro-heavy crates where macros produce a lot of exprs of type !), we could first check that the expression has ExprKind::Call(path, [txt]) where path refers to core::panic::panic.
|
Here is the zulip thread. |
I added some code to the respective UI test. E.g. current rustc warns on |
|
r? @estebank |
310c17e to
af403c6
Compare
|
Open question: Should I add some docs to the |
|
I'd personally be happy to read a line about it in the docs, although I would understand that someone steps forward and explains whether/why it'd be off-topic? |
This was prompted by a rant by /u/matthieum on /r/rust. The idea here is that while writing the code, either rust-analyzer or ourselves may insert
todo!()at places we intend to implement later. Unfortunately, that marks all following code as unreachable, which will prompt some lint churn.So to combat that, I modify the lint to check whether the unreachability stems from a
todo!()macro and in this case omit the lint (by settingdivergestoDiverges::WarnedAlwaysinstead ofAlways(..)). Hopefully that makes the unreachable code lint less churn-y during development and improve the developer experience.I inserted the check after when we already found some unreachable code, so perf shouldn't suffer too badly.