Skip to content
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

Incorrect hints from trivial_regex for bytes regexes #3647

Open
jeltz opened this issue Jan 9, 2019 · 0 comments
Open

Incorrect hints from trivial_regex for bytes regexes #3647

jeltz opened this issue Jan 9, 2019 · 0 comments

Comments

@jeltz
Copy link

jeltz commented Jan 9, 2019

The trivial_regex lint does not seem to make any difference between regex::Regex and regex::bytes::Regex when giving hints. I am not sure what should be used for non-anchored regexes, maybe the memchr crate, for anchored it should suggest slice::starts_with and slice::ends_with.

warning: trivial regex                                                                                   
 --> src/bin/foo.rs:2:30                                                                                 
  |                                                                                                      
2 |     regex::bytes::Regex::new("foo").unwrap();                                                        
  |                              ^^^^^                                                                   
  |                                                                                                      
  = note: #[warn(clippy::trivial_regex)] on by default                                                   
  = help: consider using `str::contains`                                                                 
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/master/index.html#trivial_regex
                                                                                                         
warning: trivial regex                                                                                   
 --> src/bin/foo.rs:3:30                                                                                 
  |                                                                                                      
3 |     regex::bytes::Regex::new("^bar").unwrap();                                                       
  |                              ^^^^^^                                                                  
  |                                                                                                      
  = help: consider using `str::starts_with`                                                              
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/master/index.html#trivial_regex

Version: clippy 0.0.212 (2e26fdc 2018-11-22)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant