-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Suppress warnings caused by todo!() #75277
Copy link
Copy link
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.L-unreachable_codeLint: unreachable_codeLint: unreachable_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.L-unreachable_codeLint: unreachable_codeLint: unreachable_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
todo!()is often used to quickly fill expressions that the developer currently does not have time/want to finish. However, use oftodo!()often leads to theunreachable_codewarning since it panics and the subsequent is not executable.It is currently possible to suppress this warning at the crate level,
#![allow(unreachable_code)], but this would result in suppressing legitimate unreachable code bugs as well. On the other hand, it is also possible to suppress this warning for each function that usestodo!(), but this introduces significantly more boilerplate (compare#[allow(unreachable_code)]26 chars, need to move cursor to declaring block, vstodo!(), 7 chars in place).According to the docs for
todo!(), "todo!conveys an intent of implementing the functionality later". This implies that the TODO itself is already implies the current code is meant to be somewhat incorrect, and it is unlikely that a developer writing code aftertodo!()does not know it is unreachable.Hence, subsequent code after
todo!()shall not be considered unreachable, and the compiler shall suppress such warnings that would not have happened withouttodo!().