-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Playground: https://play.rust-lang.org/?gist=935daee28b05c2afcdf61423fdfb40f8&version=stable
fn parse_bytes(s: &[u8]) {
// do something
}
fn main() {
parse_bytes("hello");
}
This includes the error:
error[E0308]: mismatched types
--> src/main.rs:6:17
|
6 | parse_bytes("hello");
| ^^^^^^^ expected slice, found str
|
= note: expected type `&[u8]`
found type `&'static str`
= help: here are some functions which might fulfill your needs:
- .as_bytes()
Whereas it could be much better suggesting the user to type b"hello"
instead of supplying "hello".as_bytes()
.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.