feat(manual_is_variant): Check for .iter().any()
          #15989
        
          
      
                
     Open
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Now the linter checks for calling the
iterorinto_itermethodfollowed by calling the
alloranymethod.We have used these methods by mistake ourselves. The developer was not
familiar with the
is_some_andmethod. He tried to use theanymethod on an option. The compiler suggested using
iterfirst. Thedeveloper did not get to learn about the idiomatic method.
The lint
search_is_someinvolves converting a closure that takes thereference into one that takes the value. The code is split between the
function for the lint and a shared function. The new feature that we
are adding involves the same transformation. To do so it needs some of
the same code that is currently in the
search_is_somelint. So it ismoved from the lint into the shared function.
Before this patch, line 799 in the file
clippy_utils/src/sugg.rshad acheck. It made the function return none in case the closure did not
dereference the argument. However, the code for the lint
search_is_somewould then fall back to using the original closure.That achieved the same effect as the check not existing. So the check
is now removed.
changelog: [
manual_is_variant]: check for calling theiterorinto_itermethod followed by calling thealloranymethodchangelog: [
manual_is_variant]: skip the check when the MSRV is before1.70