mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Suggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call.
This commit is contained in:
parent
0767a0f9c7
commit
9f7f8b71a6
3 changed files with 11 additions and 11 deletions
|
@ -2183,7 +2183,7 @@ fn lint_expect_fun_call(
|
|||
span_replace_word,
|
||||
&format!("use of `{}` followed by a function call", name),
|
||||
"try this",
|
||||
format!("unwrap_or_else({} {{ panic!({}) }})", closure_args, arg_root_snippet),
|
||||
format!("unwrap_or_else({} {{ panic!(\"{{}}\", {}) }})", closure_args, arg_root_snippet),
|
||||
applicability,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -74,12 +74,12 @@ fn main() {
|
|||
"foo"
|
||||
}
|
||||
|
||||
Some("foo").unwrap_or_else(|| { panic!(get_string()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!(get_string()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!(get_string()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!("{}", get_string()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!("{}", get_string()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!("{}", get_string()) });
|
||||
|
||||
Some("foo").unwrap_or_else(|| { panic!(get_static_str()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!("{}", get_static_str()) });
|
||||
Some("foo").unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) });
|
||||
}
|
||||
|
||||
//Issue #3839
|
||||
|
|
|
@ -34,31 +34,31 @@ error: use of `expect` followed by a function call
|
|||
--> $DIR/expect_fun_call.rs:77:21
|
||||
|
|
||||
LL | Some("foo").expect(&get_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:78:21
|
||||
|
|
||||
LL | Some("foo").expect(get_string().as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:79:21
|
||||
|
|
||||
LL | Some("foo").expect(get_string().as_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:81:21
|
||||
|
|
||||
LL | Some("foo").expect(get_static_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_static_str()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_static_str()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:82:21
|
||||
|
|
||||
LL | Some("foo").expect(get_non_static_str(&0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) })`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })`
|
||||
|
||||
error: use of `expect` followed by a function call
|
||||
--> $DIR/expect_fun_call.rs:86:16
|
||||
|
|
Loading…
Reference in a new issue