You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isaacg1 opened this issue
Dec 3, 2017
· 1 comment
· Fixed by #10909
Labels
C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types
fn main() {
for a in vec![0] {
foo(a)
}
}
fn foo(a: i64) {
println!("{}", a)
}
Clippy will suggest changing vec![0] to &[0]. A & before the a in for a in is also needed, or similar. While the compiler will suggest this change, it'd be better to make this clear up front.
The text was updated successfully, but these errors were encountered:
oli-obk
added
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
T-middle
Type: Probably requires verifiying types
labels
Dec 3, 2017
camsteffen
added
C-bug
Category: Clippy is not doing the correct thing
and removed
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
labels
Nov 14, 2021
possibly this can be decorated further with a suggestion, seeing as the current implementation is, indeed, correct - the slice seems to be preferable here.
span_lint_and_sugg(
cx,
USELESS_VEC,
span,
"useless use of `vec!`",
"you can use a slice directly",
"consider making the value a reference",
snippet,
applicability,
);
C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types
In some cases, the useless_vec warning will suggest changing a
vec![...]
to a&[...]
. In this case, a*
or a&
may be required. This is not mentioned in the help text or in the extended help text at https://rust-lang-nursery.github.io/rust-clippy/master/index.html#useless_vecA test case reproducing this:
Clippy will suggest changing
vec![0]
to&[0]
. A&
before thea
infor a in
is also needed, or similar. While the compiler will suggest this change, it'd be better to make this clear up front.The text was updated successfully, but these errors were encountered: