-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Clippy version: clippy 0.0.212 (e3cb40e 2019-06-25)
Clippy suggests using a byte string literal b"string literal"
instead of "string literal".as_bytes()
.
The suggestion does not compile in the following case because the type of byte string literal &[u8; N]
does not implement std::io::Read
.
fn f(_: impl std::io::Read) {
}
fn main() {
f("string literal".as_bytes());
// ^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"string literal"`
// f(b"string literal"); // does not compile
// ^ the trait `std::io::Read` is not implemented for `&[u8; 14]`
f(&b"string literal"[..]); // compiles
}
Clippy should allow the above case or suggest &b"string literal"[..]
.
timotree3 and tsurai
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied