2022-08-08 20:31:53 +00:00
|
|
|
// run-rustfix
|
|
|
|
|
2022-08-02 20:37:40 +00:00
|
|
|
#![warn(clippy::collapsible_str_replace)]
|
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
fn get_filter() -> char {
|
|
|
|
'u'
|
2022-08-04 21:46:41 +00:00
|
|
|
}
|
|
|
|
|
2022-08-02 20:37:40 +00:00
|
|
|
fn main() {
|
2022-08-14 16:33:55 +00:00
|
|
|
let d = 'd';
|
2022-08-02 20:37:40 +00:00
|
|
|
let p = 'p';
|
|
|
|
let s = 's';
|
|
|
|
let u = 'u';
|
2022-08-05 19:08:43 +00:00
|
|
|
let l = "l";
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let mut iter = ["l", "z"].iter();
|
|
|
|
|
2022-08-04 21:46:41 +00:00
|
|
|
// LINT CASES
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace('s', "l").replace('u', "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace('s', l).replace('u', l);
|
2022-08-05 19:08:43 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace('s', "l").replace('u', "l").replace('p', "l");
|
2022-08-05 19:08:43 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd"
|
2022-08-08 20:02:26 +00:00
|
|
|
.replace('s', "l")
|
|
|
|
.replace('u', "l")
|
|
|
|
.replace('p', "l")
|
|
|
|
.replace('d', "l");
|
2022-08-05 19:08:43 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo world".replace(s, "l").replace('u', "l");
|
2022-08-05 19:08:43 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(s, "l").replace('u', "l").replace('p', "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace('p', "l");
|
2022-08-08 20:02:26 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace(p, "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worlp".replace('s', "l").replace('u', "l").replace('p', "d");
|
|
|
|
|
|
|
|
let _ = "hesuo worpd".replace('s', "x").replace('u', "l").replace('p', "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
// Note: Future iterations could lint `replace(|c| matches!(c, "su" | 'd' | 'p'), "l")`
|
|
|
|
let _ = "hesudo worpd".replace("su", "l").replace('d', "l").replace('p', "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesudo worpd".replace(d, "l").replace('p', "l").replace("su", "l");
|
|
|
|
|
|
|
|
let _ = "hesuo world".replace(get_filter(), "l").replace('s', "l");
|
|
|
|
|
|
|
|
// NO LINT CASES
|
|
|
|
let _ = "hesuo world".replace('s', "l").replace('u', "p");
|
2022-08-07 12:08:09 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace('s', "l").replace('p', l);
|
2022-08-04 21:46:41 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesudo worpd".replace('d', "l").replace("su", "l").replace('p', "l");
|
2022-08-04 21:46:41 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
// Note: Future iterations of `collapsible_str_replace` might lint this and combine to `[s, u, p]`
|
|
|
|
let _ = "hesuo worpd".replace([s, u], "l").replace([u, p], "l");
|
2022-08-04 21:46:41 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(['s', 'u'], "l").replace(['u', 'p'], "l");
|
2022-08-04 21:46:41 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace('s', "l").replace(['u', 'p'], "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(['s', 'u', 'p'], "l").replace('r', "l");
|
2022-08-08 20:02:26 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(['s', 'u', 'p'], l).replace('r', l);
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace(['s', u, 'p'], "l").replace('r', "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
let _ = "hesuo worpd".replace([s, u], "l").replace(p, "l");
|
2022-08-02 20:37:40 +00:00
|
|
|
|
2022-08-14 16:33:55 +00:00
|
|
|
// Regression test
|
|
|
|
let _ = "hesuo worpd"
|
|
|
|
.replace('u', iter.next().unwrap())
|
|
|
|
.replace('s', iter.next().unwrap());
|
2022-08-02 20:37:40 +00:00
|
|
|
}
|