- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.8k
 
chore(useless_vec): clean-up #15952
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: master
Are you sure you want to change the base?
chore(useless_vec): clean-up #15952
Conversation
| 
           r? @Alexendoo rustbot has assigned @Alexendoo. Use   | 
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
        
          
                clippy_utils/src/lib.rs
              
                Outdated
          
        
      | pub fn is_allowed_vec_method(e: &Expr<'_>) -> bool { | ||
| if let ExprKind::MethodCall(path, _, [], _) = e.kind { | ||
| matches!(path.ident.name, sym::as_ptr | sym::is_empty | sym::len) | ||
| } else { | ||
| false | ||
| } | ||
| } | 
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.
This doesn't check that the method call actually is on a Vec, but I'm aware that would be redundant for the current callsites. Perhaps something more like more like Symbol -> bool would be fine, or it could be inlined
But if it's kept it needs a rename since which names are allowed doesn't make sense out of the original context
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.
Great point! I stripped it all the way down to a const array, which turned out to work rather nicely, even allowing to simplify the logic in ptr_arg.
I think the new name is pretty descriptive? Lmk what you think
will improve the diff for the next commit
- move `is_allowed_vec_method` (a stripped-down version of it, anyway, as the function doesn't make sense as is out of context) to utils, as it's shared between `useless_vec` and `ptr_arg` - add another test for non-standard macro brace case - rm unneeded `allow`s - rm duplicated tests - add comments to some tests
| 
           This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.  | 
    
changelog: none