Auto merge of #7810 - camsteffen:if-then-panic-pedantic, r=flip1995

Move if_then_panic to pedantic and rename to manual_assert
This commit is contained in:
bors 2021-10-28 14:43:40 +00:00 committed by flip1995
parent b7f3f7f608
commit e1225bf9a2
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
14 changed files with 41 additions and 48 deletions

View file

@ -2746,7 +2746,6 @@ Released 2018-09-13
[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching [`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else [`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else [`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none [`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond [`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone [`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
@ -2804,6 +2803,7 @@ Released 2018-09-13
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal [`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports [`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion [`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn [`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map [`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map [`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map

View file

@ -74,7 +74,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
LintId::of(get_last_with_len::GET_LAST_WITH_LEN), LintId::of(get_last_with_len::GET_LAST_WITH_LEN),
LintId::of(identity_op::IDENTITY_OP), LintId::of(identity_op::IDENTITY_OP),
LintId::of(if_let_mutex::IF_LET_MUTEX), LintId::of(if_let_mutex::IF_LET_MUTEX),
LintId::of(if_then_panic::IF_THEN_PANIC),
LintId::of(indexing_slicing::OUT_OF_BOUNDS_INDEXING), LintId::of(indexing_slicing::OUT_OF_BOUNDS_INDEXING),
LintId::of(infinite_iter::INFINITE_ITER), LintId::of(infinite_iter::INFINITE_ITER),
LintId::of(inherent_to_string::INHERENT_TO_STRING), LintId::of(inherent_to_string::INHERENT_TO_STRING),

View file

@ -156,7 +156,6 @@ store.register_lints(&[
identity_op::IDENTITY_OP, identity_op::IDENTITY_OP,
if_let_mutex::IF_LET_MUTEX, if_let_mutex::IF_LET_MUTEX,
if_not_else::IF_NOT_ELSE, if_not_else::IF_NOT_ELSE,
if_then_panic::IF_THEN_PANIC,
if_then_some_else_none::IF_THEN_SOME_ELSE_NONE, if_then_some_else_none::IF_THEN_SOME_ELSE_NONE,
implicit_hasher::IMPLICIT_HASHER, implicit_hasher::IMPLICIT_HASHER,
implicit_return::IMPLICIT_RETURN, implicit_return::IMPLICIT_RETURN,
@ -213,6 +212,7 @@ store.register_lints(&[
loops::WHILE_LET_ON_ITERATOR, loops::WHILE_LET_ON_ITERATOR,
macro_use::MACRO_USE_IMPORTS, macro_use::MACRO_USE_IMPORTS,
main_recursion::MAIN_RECURSION, main_recursion::MAIN_RECURSION,
manual_assert::MANUAL_ASSERT,
manual_async_fn::MANUAL_ASYNC_FN, manual_async_fn::MANUAL_ASYNC_FN,
manual_map::MANUAL_MAP, manual_map::MANUAL_MAP,
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE, manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,

View file

@ -48,6 +48,7 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
LintId::of(loops::EXPLICIT_INTO_ITER_LOOP), LintId::of(loops::EXPLICIT_INTO_ITER_LOOP),
LintId::of(loops::EXPLICIT_ITER_LOOP), LintId::of(loops::EXPLICIT_ITER_LOOP),
LintId::of(macro_use::MACRO_USE_IMPORTS), LintId::of(macro_use::MACRO_USE_IMPORTS),
LintId::of(manual_assert::MANUAL_ASSERT),
LintId::of(manual_ok_or::MANUAL_OK_OR), LintId::of(manual_ok_or::MANUAL_OK_OR),
LintId::of(match_on_vec_items::MATCH_ON_VEC_ITEMS), LintId::of(match_on_vec_items::MATCH_ON_VEC_ITEMS),
LintId::of(matches::MATCH_BOOL), LintId::of(matches::MATCH_BOOL),

View file

@ -27,7 +27,6 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![
LintId::of(functions::DOUBLE_MUST_USE), LintId::of(functions::DOUBLE_MUST_USE),
LintId::of(functions::MUST_USE_UNIT), LintId::of(functions::MUST_USE_UNIT),
LintId::of(functions::RESULT_UNIT_ERR), LintId::of(functions::RESULT_UNIT_ERR),
LintId::of(if_then_panic::IF_THEN_PANIC),
LintId::of(inherent_to_string::INHERENT_TO_STRING), LintId::of(inherent_to_string::INHERENT_TO_STRING),
LintId::of(len_zero::COMPARISON_TO_EMPTY), LintId::of(len_zero::COMPARISON_TO_EMPTY),
LintId::of(len_zero::LEN_WITHOUT_IS_EMPTY), LintId::of(len_zero::LEN_WITHOUT_IS_EMPTY),

View file

@ -227,7 +227,6 @@ mod get_last_with_len;
mod identity_op; mod identity_op;
mod if_let_mutex; mod if_let_mutex;
mod if_not_else; mod if_not_else;
mod if_then_panic;
mod if_then_some_else_none; mod if_then_some_else_none;
mod implicit_hasher; mod implicit_hasher;
mod implicit_return; mod implicit_return;
@ -254,6 +253,7 @@ mod literal_representation;
mod loops; mod loops;
mod macro_use; mod macro_use;
mod main_recursion; mod main_recursion;
mod manual_assert;
mod manual_async_fn; mod manual_async_fn;
mod manual_map; mod manual_map;
mod manual_non_exhaustive; mod manual_non_exhaustive;
@ -766,7 +766,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors)); store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
store.register_late_pass(move || Box::new(feature_name::FeatureName)); store.register_late_pass(move || Box::new(feature_name::FeatureName));
store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator)); store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
store.register_late_pass(move || Box::new(if_then_panic::IfThenPanic)); store.register_late_pass(move || Box::new(manual_assert::ManualAssert));
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send; let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send))); store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send)));
} }

View file

@ -26,14 +26,14 @@ declare_clippy_lint! {
/// let sad_people: Vec<&str> = vec![]; /// let sad_people: Vec<&str> = vec![];
/// assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people); /// assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);
/// ``` /// ```
pub IF_THEN_PANIC, pub MANUAL_ASSERT,
style, pedantic,
"`panic!` and only a `panic!` in `if`-then statement" "`panic!` and only a `panic!` in `if`-then statement"
} }
declare_lint_pass!(IfThenPanic => [IF_THEN_PANIC]); declare_lint_pass!(ManualAssert => [MANUAL_ASSERT]);
impl LateLintPass<'_> for IfThenPanic { impl LateLintPass<'_> for ManualAssert {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
if_chain! { if_chain! {
if let Expr { if let Expr {
@ -86,7 +86,7 @@ impl LateLintPass<'_> for IfThenPanic {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
IF_THEN_PANIC, MANUAL_ASSERT,
expr.span, expr.span,
"only a `panic!` in `if`-then statement", "only a `panic!` in `if`-then statement",
"try", "try",

View file

@ -1,5 +1,4 @@
#![deny(clippy::fallible_impl_from)] #![deny(clippy::fallible_impl_from)]
#![allow(clippy::if_then_panic)]
// docs example // docs example
struct Foo(i32); struct Foo(i32);

View file

@ -1,5 +1,5 @@
error: consider implementing `TryFrom` instead error: consider implementing `TryFrom` instead
--> $DIR/fallible_impl_from.rs:6:1 --> $DIR/fallible_impl_from.rs:5:1
| |
LL | / impl From<String> for Foo { LL | / impl From<String> for Foo {
LL | | fn from(s: String) -> Self { LL | | fn from(s: String) -> Self {
@ -15,13 +15,13 @@ LL | #![deny(clippy::fallible_impl_from)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
note: potential failure(s) note: potential failure(s)
--> $DIR/fallible_impl_from.rs:8:13 --> $DIR/fallible_impl_from.rs:7:13
| |
LL | Foo(s.parse().unwrap()) LL | Foo(s.parse().unwrap())
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: consider implementing `TryFrom` instead error: consider implementing `TryFrom` instead
--> $DIR/fallible_impl_from.rs:27:1 --> $DIR/fallible_impl_from.rs:26:1
| |
LL | / impl From<usize> for Invalid { LL | / impl From<usize> for Invalid {
LL | | fn from(i: usize) -> Invalid { LL | | fn from(i: usize) -> Invalid {
@ -34,14 +34,14 @@ LL | | }
| |
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
note: potential failure(s) note: potential failure(s)
--> $DIR/fallible_impl_from.rs:30:13 --> $DIR/fallible_impl_from.rs:29:13
| |
LL | panic!(); LL | panic!();
| ^^^^^^^^^ | ^^^^^^^^^
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: consider implementing `TryFrom` instead error: consider implementing `TryFrom` instead
--> $DIR/fallible_impl_from.rs:36:1 --> $DIR/fallible_impl_from.rs:35:1
| |
LL | / impl From<Option<String>> for Invalid { LL | / impl From<Option<String>> for Invalid {
LL | | fn from(s: Option<String>) -> Invalid { LL | | fn from(s: Option<String>) -> Invalid {
@ -54,7 +54,7 @@ LL | | }
| |
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
note: potential failure(s) note: potential failure(s)
--> $DIR/fallible_impl_from.rs:38:17 --> $DIR/fallible_impl_from.rs:37:17
| |
LL | let s = s.unwrap(); LL | let s = s.unwrap();
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -68,7 +68,7 @@ LL | panic!("{:?}", s);
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: consider implementing `TryFrom` instead error: consider implementing `TryFrom` instead
--> $DIR/fallible_impl_from.rs:54:1 --> $DIR/fallible_impl_from.rs:53:1
| |
LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid { LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid { LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
@ -81,7 +81,7 @@ LL | | }
| |
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
note: potential failure(s) note: potential failure(s)
--> $DIR/fallible_impl_from.rs:56:12 --> $DIR/fallible_impl_from.rs:55:12
| |
LL | if s.parse::<u32>().ok().unwrap() != 42 { LL | if s.parse::<u32>().ok().unwrap() != 42 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
// run-rustfix // run-rustfix
#![warn(clippy::if_then_panic)] #![warn(clippy::manual_assert)]
fn main() { fn main() {
let a = vec![1, 2, 3]; let a = vec![1, 2, 3];

View file

@ -1,5 +1,5 @@
// run-rustfix // run-rustfix
#![warn(clippy::if_then_panic)] #![warn(clippy::manual_assert)]
fn main() { fn main() {
let a = vec![1, 2, 3]; let a = vec![1, 2, 3];

View file

@ -1,15 +1,15 @@
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:19:5 --> $DIR/manual_assert.rs:19:5
| |
LL | / if !a.is_empty() { LL | / if !a.is_empty() {
LL | | panic!("qaqaq{:?}", a); LL | | panic!("qaqaq{:?}", a);
LL | | } LL | | }
| |_____^ help: try: `assert!(a.is_empty(), "qaqaq{:?}", a);` | |_____^ help: try: `assert!(a.is_empty(), "qaqaq{:?}", a);`
| |
= note: `-D clippy::if-then-panic` implied by `-D warnings` = note: `-D clippy::manual-assert` implied by `-D warnings`
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:22:5 --> $DIR/manual_assert.rs:22:5
| |
LL | / if !a.is_empty() { LL | / if !a.is_empty() {
LL | | panic!("qwqwq"); LL | | panic!("qwqwq");
@ -17,7 +17,7 @@ LL | | }
| |_____^ help: try: `assert!(a.is_empty(), "qwqwq");` | |_____^ help: try: `assert!(a.is_empty(), "qwqwq");`
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:39:5 --> $DIR/manual_assert.rs:39:5
| |
LL | / if b.is_empty() { LL | / if b.is_empty() {
LL | | panic!("panic1"); LL | | panic!("panic1");
@ -25,7 +25,7 @@ LL | | }
| |_____^ help: try: `assert!(!b.is_empty(), "panic1");` | |_____^ help: try: `assert!(!b.is_empty(), "panic1");`
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:42:5 --> $DIR/manual_assert.rs:42:5
| |
LL | / if b.is_empty() && a.is_empty() { LL | / if b.is_empty() && a.is_empty() {
LL | | panic!("panic2"); LL | | panic!("panic2");
@ -33,7 +33,7 @@ LL | | }
| |_____^ help: try: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` | |_____^ help: try: `assert!(!(b.is_empty() && a.is_empty()), "panic2");`
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:45:5 --> $DIR/manual_assert.rs:45:5
| |
LL | / if a.is_empty() && !b.is_empty() { LL | / if a.is_empty() && !b.is_empty() {
LL | | panic!("panic3"); LL | | panic!("panic3");
@ -41,7 +41,7 @@ LL | | }
| |_____^ help: try: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` | |_____^ help: try: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");`
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:48:5 --> $DIR/manual_assert.rs:48:5
| |
LL | / if b.is_empty() || a.is_empty() { LL | / if b.is_empty() || a.is_empty() {
LL | | panic!("panic4"); LL | | panic!("panic4");
@ -49,7 +49,7 @@ LL | | }
| |_____^ help: try: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` | |_____^ help: try: `assert!(!(b.is_empty() || a.is_empty()), "panic4");`
error: only a `panic!` in `if`-then statement error: only a `panic!` in `if`-then statement
--> $DIR/if_then_panic.rs:51:5 --> $DIR/manual_assert.rs:51:5
| |
LL | / if a.is_empty() || !b.is_empty() { LL | / if a.is_empty() || !b.is_empty() {
LL | | panic!("panic5"); LL | | panic!("panic5");

View file

@ -1,9 +1,4 @@
#![allow( #![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
unused,
clippy::many_single_char_names,
clippy::redundant_clone,
clippy::if_then_panic
)]
#![warn(clippy::ptr_arg)] #![warn(clippy::ptr_arg)]
use std::borrow::Cow; use std::borrow::Cow;

View file

@ -1,5 +1,5 @@
error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
--> $DIR/ptr_arg.rs:12:14 --> $DIR/ptr_arg.rs:7:14
| |
LL | fn do_vec(x: &Vec<i64>) { LL | fn do_vec(x: &Vec<i64>) {
| ^^^^^^^^^ help: change this to: `&[i64]` | ^^^^^^^^^ help: change this to: `&[i64]`
@ -7,25 +7,25 @@ LL | fn do_vec(x: &Vec<i64>) {
= note: `-D clippy::ptr-arg` implied by `-D warnings` = note: `-D clippy::ptr-arg` implied by `-D warnings`
error: writing `&String` instead of `&str` involves a new object where a slice will do error: writing `&String` instead of `&str` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:21:14 --> $DIR/ptr_arg.rs:16:14
| |
LL | fn do_str(x: &String) { LL | fn do_str(x: &String) {
| ^^^^^^^ help: change this to: `&str` | ^^^^^^^ help: change this to: `&str`
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:30:15 --> $DIR/ptr_arg.rs:25:15
| |
LL | fn do_path(x: &PathBuf) { LL | fn do_path(x: &PathBuf) {
| ^^^^^^^^ help: change this to: `&Path` | ^^^^^^^^ help: change this to: `&Path`
error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
--> $DIR/ptr_arg.rs:43:18 --> $DIR/ptr_arg.rs:38:18
| |
LL | fn do_vec(x: &Vec<i64>); LL | fn do_vec(x: &Vec<i64>);
| ^^^^^^^^^ help: change this to: `&[i64]` | ^^^^^^^^^ help: change this to: `&[i64]`
error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
--> $DIR/ptr_arg.rs:56:14 --> $DIR/ptr_arg.rs:51:14
| |
LL | fn cloned(x: &Vec<u8>) -> Vec<u8> { LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
| ^^^^^^^^ | ^^^^^^^^
@ -44,7 +44,7 @@ LL | x.to_owned()
| |
error: writing `&String` instead of `&str` involves a new object where a slice will do error: writing `&String` instead of `&str` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:65:18 --> $DIR/ptr_arg.rs:60:18
| |
LL | fn str_cloned(x: &String) -> String { LL | fn str_cloned(x: &String) -> String {
| ^^^^^^^ | ^^^^^^^
@ -67,7 +67,7 @@ LL | x.to_string()
| |
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:73:19 --> $DIR/ptr_arg.rs:68:19
| |
LL | fn path_cloned(x: &PathBuf) -> PathBuf { LL | fn path_cloned(x: &PathBuf) -> PathBuf {
| ^^^^^^^^ | ^^^^^^^^
@ -90,7 +90,7 @@ LL | x.to_path_buf()
| |
error: writing `&String` instead of `&str` involves a new object where a slice will do error: writing `&String` instead of `&str` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:81:44 --> $DIR/ptr_arg.rs:76:44
| |
LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) { LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
| ^^^^^^^ | ^^^^^^^
@ -109,13 +109,13 @@ LL | let c = y;
| ~ | ~
error: using a reference to `Cow` is not recommended error: using a reference to `Cow` is not recommended
--> $DIR/ptr_arg.rs:95:25 --> $DIR/ptr_arg.rs:90:25
| |
LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
| ^^^^^^^^^^^ help: change this to: `&[i32]` | ^^^^^^^^^^^ help: change this to: `&[i32]`
error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
--> $DIR/ptr_arg.rs:148:21 --> $DIR/ptr_arg.rs:143:21
| |
LL | fn foo_vec(vec: &Vec<u8>) { LL | fn foo_vec(vec: &Vec<u8>) {
| ^^^^^^^^ | ^^^^^^^^
@ -134,7 +134,7 @@ LL | let _ = vec.to_owned().clone();
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:153:23 --> $DIR/ptr_arg.rs:148:23
| |
LL | fn foo_path(path: &PathBuf) { LL | fn foo_path(path: &PathBuf) {
| ^^^^^^^^ | ^^^^^^^^
@ -153,7 +153,7 @@ LL | let _ = path.to_path_buf().clone();
| ~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~~
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:158:21 --> $DIR/ptr_arg.rs:153:21
| |
LL | fn foo_str(str: &PathBuf) { LL | fn foo_str(str: &PathBuf) {
| ^^^^^^^^ | ^^^^^^^^