Skip to content

Commit

Permalink
is_from_for_loop: document what first check matches
Browse files Browse the repository at this point in the history
Removing the first check will break a lot of for-loop UI tests and the
dogfood test.
  • Loading branch information
koivunej committed Aug 18, 2017
1 parent cf8e95e commit a5147e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clippy_lints/src/utils/higher.rs
Expand Up @@ -114,6 +114,13 @@ pub fn range(expr: &hir::Expr) -> Option<Range> {

/// Checks if a `let` decl is from a `for` loop desugaring.
pub fn is_from_for_desugar(decl: &hir::Decl) -> bool {
// This will detect plain for-loops without an actual variable binding:
//
// ```
// for x in some_vec {
// // do stuff
// }
// ```
if_let_chain! {[
let hir::DeclLocal(ref loc) = decl.node,
let Some(ref expr) = loc.init,
Expand Down

0 comments on commit a5147e8

Please sign in to comment.