-
Couldn't load subscription status.
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
Using str without the std::str prefix to specify the module generates unhelpful error messages (especially since the distinction between the std::str module and the str primitive is not very nicely thought out due to technical restrictions I wish we could revisit).
Example code:
fn main() {
let bytes = "hello world".as_bytes();
let string = unsafe {
str::from_utf8(bytes)
};
println!("{}", string);
}This causes the compiler to emit the following error:
error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
--> ./test.rs:4:9
|
4 | str::from_utf8(bytes)
| ^^^^^^^^^^^^^^
error: aborting due to previous errorA recommendation to specify std:: to access the module function with the same name would be most helpful. In fact, anything the compiler could do to blur the distinction between the type and the primitive would be most appreciated.
Marwes, TylerHorth, samsieber, boehm-s, linouxis9 and 4 more
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.